whiteoutlib 0.1.4

Read and write Blizzard game assets from Rust: models (MDX, M2, M3), textures (BLP, DDS, PNG, JPEG, BMP, TGA, TIFF, GIF) and archives (CASC, MPQ).
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
// SPDX-License-Identifier: BSD-3-Clause
// Copyright (c) 2026 Fernando Sahmkow
// AUTOGENERATED by tools/codegen/emit_rust_abi.py — do not edit.
// Regenerate via:  python -m tools.codegen.codegen <any> --backend rust-abi-source

#include <whiteout/vector_types.h>
#include <whiteout/textures/texture.h>

#include <cstring>
#include <type_traits>

#include "whiteout_v.h"

namespace {

// The C structs and the C++ types are layout-identical by construction
// (see the static_asserts below). memcpy is the conversion with the
// laxest preconditions — it needs only trivial copyability — and every
// compiler folds it away entirely at -O1 and above.
template <typename Cpp, typename C>
inline Cpp fromC_impl(const C& v) {
    static_assert(sizeof(Cpp) == sizeof(C), "value ABI layout mismatch");
    static_assert(std::is_trivially_copyable<Cpp>::value, "not trivially copyable");
    Cpp out;
    std::memcpy(&out, &v, sizeof(out));
    return out;
}

template <typename C, typename Cpp>
inline C toC_impl(const Cpp& v) {
    static_assert(sizeof(Cpp) == sizeof(C), "value ABI layout mismatch");
    C out;
    std::memcpy(&out, &v, sizeof(out));
    return out;
}

inline whiteout::Vector2f fromC(const whiteout_v_Vector2f& v) { return fromC_impl<whiteout::Vector2f>(v); }
inline whiteout_v_Vector2f toC(const whiteout::Vector2f& v) { return toC_impl<whiteout_v_Vector2f>(v); }
inline whiteout::Vector3f fromC(const whiteout_v_Vector3f& v) { return fromC_impl<whiteout::Vector3f>(v); }
inline whiteout_v_Vector3f toC(const whiteout::Vector3f& v) { return toC_impl<whiteout_v_Vector3f>(v); }
inline whiteout::Vector4f fromC(const whiteout_v_Vector4f& v) { return fromC_impl<whiteout::Vector4f>(v); }
inline whiteout_v_Vector4f toC(const whiteout::Vector4f& v) { return toC_impl<whiteout_v_Vector4f>(v); }
inline whiteout::Quaternion fromC(const whiteout_v_Quaternion& v) { return fromC_impl<whiteout::Quaternion>(v); }
inline whiteout_v_Quaternion toC(const whiteout::Quaternion& v) { return toC_impl<whiteout_v_Quaternion>(v); }
inline whiteout::Matrix33f fromC(const whiteout_v_Matrix33f& v) { return fromC_impl<whiteout::Matrix33f>(v); }
inline whiteout_v_Matrix33f toC(const whiteout::Matrix33f& v) { return toC_impl<whiteout_v_Matrix33f>(v); }
inline whiteout::Matrix44f fromC(const whiteout_v_Matrix44f& v) { return fromC_impl<whiteout::Matrix44f>(v); }
inline whiteout_v_Matrix44f toC(const whiteout::Matrix44f& v) { return toC_impl<whiteout_v_Matrix44f>(v); }

// Layout contract — a mismatch here is a compile error, not a runtime surprise.
static_assert(sizeof(whiteout::Vector2f) == 8, "whiteout::Vector2f changed size");
static_assert(sizeof(whiteout_v_Vector2f) == 8, "whiteout_v_Vector2f changed size");
static_assert(sizeof(whiteout::Vector3f) == 12, "whiteout::Vector3f changed size");
static_assert(sizeof(whiteout_v_Vector3f) == 12, "whiteout_v_Vector3f changed size");
static_assert(sizeof(whiteout::Vector4f) == 16, "whiteout::Vector4f changed size");
static_assert(sizeof(whiteout_v_Vector4f) == 16, "whiteout_v_Vector4f changed size");
static_assert(sizeof(whiteout::Quaternion) == 16, "whiteout::Quaternion changed size");
static_assert(sizeof(whiteout_v_Quaternion) == 16, "whiteout_v_Quaternion changed size");
static_assert(sizeof(whiteout::Matrix33f) == 36, "whiteout::Matrix33f changed size");
static_assert(sizeof(whiteout_v_Matrix33f) == 36, "whiteout_v_Matrix33f changed size");
static_assert(sizeof(whiteout::Matrix44f) == 64, "whiteout::Matrix44f changed size");
static_assert(sizeof(whiteout_v_Matrix44f) == 64, "whiteout_v_Matrix44f changed size");

}  // namespace

extern "C" {

whiteout_v_Layout whiteout_v_layout(void) {
    whiteout_v_Layout l;
    l.abi_version = WHITEOUT_V_ABI_VERSION;
    l.vector2f = (uint32_t)sizeof(whiteout_v_Vector2f);
    l.vector3f = (uint32_t)sizeof(whiteout_v_Vector3f);
    l.vector4f = (uint32_t)sizeof(whiteout_v_Vector4f);
    l.quaternion = (uint32_t)sizeof(whiteout_v_Quaternion);
    l.matrix33f = (uint32_t)sizeof(whiteout_v_Matrix33f);
    l.matrix44f = (uint32_t)sizeof(whiteout_v_Matrix44f);
    return l;
}

// ── Vector2f ──────────────────────────────────────────
float whiteout_v_Vector2f_dot(whiteout_v_Vector2f self, whiteout_v_Vector2f other) {
    const whiteout::Vector2f __self = fromC(self);
    const whiteout::Vector2f __other = fromC(other);
    return __self.dot(__other);
}

float whiteout_v_Vector2f_length(whiteout_v_Vector2f self) {
    const whiteout::Vector2f __self = fromC(self);
    return __self.length();
}

float whiteout_v_Vector2f_length_squared(whiteout_v_Vector2f self) {
    const whiteout::Vector2f __self = fromC(self);
    return __self.length_squared();
}

void whiteout_v_Vector2f_normalize(whiteout_v_Vector2f* self) {
    whiteout::Vector2f __self = fromC(*self);
    __self.normalize();
    *self = toC(__self);
}

whiteout_v_Vector2f whiteout_v_Vector2f_normalized(whiteout_v_Vector2f self) {
    const whiteout::Vector2f __self = fromC(self);
    return toC(__self.normalized());
}

whiteout_v_Vector2f whiteout_v_Vector2f_add(whiteout_v_Vector2f self, whiteout_v_Vector2f other) {
    const whiteout::Vector2f __self = fromC(self);
    const whiteout::Vector2f __other = fromC(other);
    return toC(__self + __other);
}

whiteout_v_Vector2f whiteout_v_Vector2f_sub(whiteout_v_Vector2f self, whiteout_v_Vector2f other) {
    const whiteout::Vector2f __self = fromC(self);
    const whiteout::Vector2f __other = fromC(other);
    return toC(__self - __other);
}

whiteout_v_Vector2f whiteout_v_Vector2f_mul(whiteout_v_Vector2f self, whiteout_v_Vector2f other) {
    const whiteout::Vector2f __self = fromC(self);
    const whiteout::Vector2f __other = fromC(other);
    return toC(__self * __other);
}

whiteout_v_Vector2f whiteout_v_Vector2f_div(whiteout_v_Vector2f self, whiteout_v_Vector2f other) {
    const whiteout::Vector2f __self = fromC(self);
    const whiteout::Vector2f __other = fromC(other);
    return toC(__self / __other);
}

whiteout_v_Vector2f whiteout_v_Vector2f_mul_scalar(whiteout_v_Vector2f self, float scalar) {
    const whiteout::Vector2f __self = fromC(self);
    return toC(__self * scalar);
}

whiteout_v_Vector2f whiteout_v_Vector2f_div_scalar(whiteout_v_Vector2f self, float scalar) {
    const whiteout::Vector2f __self = fromC(self);
    return toC(__self / scalar);
}

whiteout_v_Vector2f whiteout_v_Vector2f_negate(whiteout_v_Vector2f self) {
    const whiteout::Vector2f __self = fromC(self);
    return toC(-__self);
}

int32_t whiteout_v_Vector2f_equals(whiteout_v_Vector2f self, whiteout_v_Vector2f other) {
    const whiteout::Vector2f __self = fromC(self);
    const whiteout::Vector2f __other = fromC(other);
    return (__self == __other) ? 1 : 0;
}

whiteout_v_Vector2f whiteout_v_Vector2f_lerp(whiteout_v_Vector2f start, whiteout_v_Vector2f end, float t) {
    const whiteout::Vector2f __start = fromC(start);
    const whiteout::Vector2f __end = fromC(end);
    return toC(whiteout::Vector2f::lerp(__start, __end, t));
}

whiteout_v_Vector2f whiteout_v_Vector2f_tcb_in_tangent(whiteout_v_Vector2f prev, whiteout_v_Vector2f current, whiteout_v_Vector2f next, float tension, float continuity, float bias) {
    const whiteout::Vector2f __prev = fromC(prev);
    const whiteout::Vector2f __current = fromC(current);
    const whiteout::Vector2f __next = fromC(next);
    return toC(whiteout::Vector2f::tcb_in_tangent(__prev, __current, __next, tension, continuity, bias));
}

whiteout_v_Vector2f whiteout_v_Vector2f_tcb_out_tangent(whiteout_v_Vector2f prev, whiteout_v_Vector2f current, whiteout_v_Vector2f next, float tension, float continuity, float bias) {
    const whiteout::Vector2f __prev = fromC(prev);
    const whiteout::Vector2f __current = fromC(current);
    const whiteout::Vector2f __next = fromC(next);
    return toC(whiteout::Vector2f::tcb_out_tangent(__prev, __current, __next, tension, continuity, bias));
}

whiteout_v_Vector2f whiteout_v_Vector2f_bezier_lerp(whiteout_v_Vector2f start, whiteout_v_Vector2f outtan, whiteout_v_Vector2f intan, whiteout_v_Vector2f end, float t) {
    const whiteout::Vector2f __start = fromC(start);
    const whiteout::Vector2f __outtan = fromC(outtan);
    const whiteout::Vector2f __intan = fromC(intan);
    const whiteout::Vector2f __end = fromC(end);
    return toC(whiteout::Vector2f::bezier_lerp(__start, __outtan, __intan, __end, t));
}

whiteout_v_Vector2f whiteout_v_Vector2f_hermite_lerp(whiteout_v_Vector2f prev, whiteout_v_Vector2f start, whiteout_v_Vector2f end, whiteout_v_Vector2f next, float t) {
    const whiteout::Vector2f __prev = fromC(prev);
    const whiteout::Vector2f __start = fromC(start);
    const whiteout::Vector2f __end = fromC(end);
    const whiteout::Vector2f __next = fromC(next);
    return toC(whiteout::Vector2f::hermite_lerp(__prev, __start, __end, __next, t));
}

// ── Vector3f ──────────────────────────────────────────
float whiteout_v_Vector3f_dot(whiteout_v_Vector3f self, whiteout_v_Vector3f other) {
    const whiteout::Vector3f __self = fromC(self);
    const whiteout::Vector3f __other = fromC(other);
    return __self.dot(__other);
}

float whiteout_v_Vector3f_length(whiteout_v_Vector3f self) {
    const whiteout::Vector3f __self = fromC(self);
    return __self.length();
}

float whiteout_v_Vector3f_length_squared(whiteout_v_Vector3f self) {
    const whiteout::Vector3f __self = fromC(self);
    return __self.length_squared();
}

void whiteout_v_Vector3f_normalize(whiteout_v_Vector3f* self) {
    whiteout::Vector3f __self = fromC(*self);
    __self.normalize();
    *self = toC(__self);
}

whiteout_v_Vector3f whiteout_v_Vector3f_normalized(whiteout_v_Vector3f self) {
    const whiteout::Vector3f __self = fromC(self);
    return toC(__self.normalized());
}

whiteout_v_Vector3f whiteout_v_Vector3f_add(whiteout_v_Vector3f self, whiteout_v_Vector3f other) {
    const whiteout::Vector3f __self = fromC(self);
    const whiteout::Vector3f __other = fromC(other);
    return toC(__self + __other);
}

whiteout_v_Vector3f whiteout_v_Vector3f_sub(whiteout_v_Vector3f self, whiteout_v_Vector3f other) {
    const whiteout::Vector3f __self = fromC(self);
    const whiteout::Vector3f __other = fromC(other);
    return toC(__self - __other);
}

whiteout_v_Vector3f whiteout_v_Vector3f_mul(whiteout_v_Vector3f self, whiteout_v_Vector3f other) {
    const whiteout::Vector3f __self = fromC(self);
    const whiteout::Vector3f __other = fromC(other);
    return toC(__self * __other);
}

whiteout_v_Vector3f whiteout_v_Vector3f_div(whiteout_v_Vector3f self, whiteout_v_Vector3f other) {
    const whiteout::Vector3f __self = fromC(self);
    const whiteout::Vector3f __other = fromC(other);
    return toC(__self / __other);
}

whiteout_v_Vector3f whiteout_v_Vector3f_mul_scalar(whiteout_v_Vector3f self, float scalar) {
    const whiteout::Vector3f __self = fromC(self);
    return toC(__self * scalar);
}

whiteout_v_Vector3f whiteout_v_Vector3f_div_scalar(whiteout_v_Vector3f self, float scalar) {
    const whiteout::Vector3f __self = fromC(self);
    return toC(__self / scalar);
}

whiteout_v_Vector3f whiteout_v_Vector3f_negate(whiteout_v_Vector3f self) {
    const whiteout::Vector3f __self = fromC(self);
    return toC(-__self);
}

int32_t whiteout_v_Vector3f_equals(whiteout_v_Vector3f self, whiteout_v_Vector3f other) {
    const whiteout::Vector3f __self = fromC(self);
    const whiteout::Vector3f __other = fromC(other);
    return (__self == __other) ? 1 : 0;
}

whiteout_v_Vector3f whiteout_v_Vector3f_lerp(whiteout_v_Vector3f start, whiteout_v_Vector3f end, float t) {
    const whiteout::Vector3f __start = fromC(start);
    const whiteout::Vector3f __end = fromC(end);
    return toC(whiteout::Vector3f::lerp(__start, __end, t));
}

whiteout_v_Vector3f whiteout_v_Vector3f_tcb_in_tangent(whiteout_v_Vector3f prev, whiteout_v_Vector3f current, whiteout_v_Vector3f next, float tension, float continuity, float bias) {
    const whiteout::Vector3f __prev = fromC(prev);
    const whiteout::Vector3f __current = fromC(current);
    const whiteout::Vector3f __next = fromC(next);
    return toC(whiteout::Vector3f::tcb_in_tangent(__prev, __current, __next, tension, continuity, bias));
}

whiteout_v_Vector3f whiteout_v_Vector3f_tcb_out_tangent(whiteout_v_Vector3f prev, whiteout_v_Vector3f current, whiteout_v_Vector3f next, float tension, float continuity, float bias) {
    const whiteout::Vector3f __prev = fromC(prev);
    const whiteout::Vector3f __current = fromC(current);
    const whiteout::Vector3f __next = fromC(next);
    return toC(whiteout::Vector3f::tcb_out_tangent(__prev, __current, __next, tension, continuity, bias));
}

whiteout_v_Vector3f whiteout_v_Vector3f_bezier_lerp(whiteout_v_Vector3f start, whiteout_v_Vector3f outtan, whiteout_v_Vector3f intan, whiteout_v_Vector3f end, float t) {
    const whiteout::Vector3f __start = fromC(start);
    const whiteout::Vector3f __outtan = fromC(outtan);
    const whiteout::Vector3f __intan = fromC(intan);
    const whiteout::Vector3f __end = fromC(end);
    return toC(whiteout::Vector3f::bezier_lerp(__start, __outtan, __intan, __end, t));
}

whiteout_v_Vector3f whiteout_v_Vector3f_hermite_lerp(whiteout_v_Vector3f prev, whiteout_v_Vector3f start, whiteout_v_Vector3f end, whiteout_v_Vector3f next, float t) {
    const whiteout::Vector3f __prev = fromC(prev);
    const whiteout::Vector3f __start = fromC(start);
    const whiteout::Vector3f __end = fromC(end);
    const whiteout::Vector3f __next = fromC(next);
    return toC(whiteout::Vector3f::hermite_lerp(__prev, __start, __end, __next, t));
}

// ── Vector4f ──────────────────────────────────────────
float whiteout_v_Vector4f_dot(whiteout_v_Vector4f self, whiteout_v_Vector4f other) {
    const whiteout::Vector4f __self = fromC(self);
    const whiteout::Vector4f __other = fromC(other);
    return __self.dot(__other);
}

float whiteout_v_Vector4f_length(whiteout_v_Vector4f self) {
    const whiteout::Vector4f __self = fromC(self);
    return __self.length();
}

float whiteout_v_Vector4f_length_squared(whiteout_v_Vector4f self) {
    const whiteout::Vector4f __self = fromC(self);
    return __self.length_squared();
}

void whiteout_v_Vector4f_normalize(whiteout_v_Vector4f* self) {
    whiteout::Vector4f __self = fromC(*self);
    __self.normalize();
    *self = toC(__self);
}

whiteout_v_Vector4f whiteout_v_Vector4f_normalized(whiteout_v_Vector4f self) {
    const whiteout::Vector4f __self = fromC(self);
    return toC(__self.normalized());
}

whiteout_v_Vector4f whiteout_v_Vector4f_add(whiteout_v_Vector4f self, whiteout_v_Vector4f other) {
    const whiteout::Vector4f __self = fromC(self);
    const whiteout::Vector4f __other = fromC(other);
    return toC(__self + __other);
}

whiteout_v_Vector4f whiteout_v_Vector4f_sub(whiteout_v_Vector4f self, whiteout_v_Vector4f other) {
    const whiteout::Vector4f __self = fromC(self);
    const whiteout::Vector4f __other = fromC(other);
    return toC(__self - __other);
}

whiteout_v_Vector4f whiteout_v_Vector4f_mul(whiteout_v_Vector4f self, whiteout_v_Vector4f other) {
    const whiteout::Vector4f __self = fromC(self);
    const whiteout::Vector4f __other = fromC(other);
    return toC(__self * __other);
}

whiteout_v_Vector4f whiteout_v_Vector4f_div(whiteout_v_Vector4f self, whiteout_v_Vector4f other) {
    const whiteout::Vector4f __self = fromC(self);
    const whiteout::Vector4f __other = fromC(other);
    return toC(__self / __other);
}

whiteout_v_Vector4f whiteout_v_Vector4f_mul_scalar(whiteout_v_Vector4f self, float scalar) {
    const whiteout::Vector4f __self = fromC(self);
    return toC(__self * scalar);
}

whiteout_v_Vector4f whiteout_v_Vector4f_div_scalar(whiteout_v_Vector4f self, float scalar) {
    const whiteout::Vector4f __self = fromC(self);
    return toC(__self / scalar);
}

whiteout_v_Vector4f whiteout_v_Vector4f_negate(whiteout_v_Vector4f self) {
    const whiteout::Vector4f __self = fromC(self);
    return toC(-__self);
}

int32_t whiteout_v_Vector4f_equals(whiteout_v_Vector4f self, whiteout_v_Vector4f other) {
    const whiteout::Vector4f __self = fromC(self);
    const whiteout::Vector4f __other = fromC(other);
    return (__self == __other) ? 1 : 0;
}

whiteout_v_Vector4f whiteout_v_Vector4f_lerp(whiteout_v_Vector4f start, whiteout_v_Vector4f end, float t) {
    const whiteout::Vector4f __start = fromC(start);
    const whiteout::Vector4f __end = fromC(end);
    return toC(whiteout::Vector4f::lerp(__start, __end, t));
}

whiteout_v_Vector4f whiteout_v_Vector4f_tcb_in_tangent(whiteout_v_Vector4f prev, whiteout_v_Vector4f current, whiteout_v_Vector4f next, float tension, float continuity, float bias) {
    const whiteout::Vector4f __prev = fromC(prev);
    const whiteout::Vector4f __current = fromC(current);
    const whiteout::Vector4f __next = fromC(next);
    return toC(whiteout::Vector4f::tcb_in_tangent(__prev, __current, __next, tension, continuity, bias));
}

whiteout_v_Vector4f whiteout_v_Vector4f_tcb_out_tangent(whiteout_v_Vector4f prev, whiteout_v_Vector4f current, whiteout_v_Vector4f next, float tension, float continuity, float bias) {
    const whiteout::Vector4f __prev = fromC(prev);
    const whiteout::Vector4f __current = fromC(current);
    const whiteout::Vector4f __next = fromC(next);
    return toC(whiteout::Vector4f::tcb_out_tangent(__prev, __current, __next, tension, continuity, bias));
}

whiteout_v_Vector4f whiteout_v_Vector4f_bezier_lerp(whiteout_v_Vector4f start, whiteout_v_Vector4f outtan, whiteout_v_Vector4f intan, whiteout_v_Vector4f end, float t) {
    const whiteout::Vector4f __start = fromC(start);
    const whiteout::Vector4f __outtan = fromC(outtan);
    const whiteout::Vector4f __intan = fromC(intan);
    const whiteout::Vector4f __end = fromC(end);
    return toC(whiteout::Vector4f::bezier_lerp(__start, __outtan, __intan, __end, t));
}

whiteout_v_Vector4f whiteout_v_Vector4f_hermite_lerp(whiteout_v_Vector4f prev, whiteout_v_Vector4f start, whiteout_v_Vector4f end, whiteout_v_Vector4f next, float t) {
    const whiteout::Vector4f __prev = fromC(prev);
    const whiteout::Vector4f __start = fromC(start);
    const whiteout::Vector4f __end = fromC(end);
    const whiteout::Vector4f __next = fromC(next);
    return toC(whiteout::Vector4f::hermite_lerp(__prev, __start, __end, __next, t));
}

// ── Quaternion ──────────────────────────────────────────
float whiteout_v_Quaternion_dot(whiteout_v_Quaternion self, whiteout_v_Quaternion other) {
    const whiteout::Quaternion __self = fromC(self);
    const whiteout::Quaternion __other = fromC(other);
    return __self.dot(__other);
}

float whiteout_v_Quaternion_length(whiteout_v_Quaternion self) {
    const whiteout::Quaternion __self = fromC(self);
    return __self.length();
}

float whiteout_v_Quaternion_length_squared(whiteout_v_Quaternion self) {
    const whiteout::Quaternion __self = fromC(self);
    return __self.length_squared();
}

void whiteout_v_Quaternion_normalize(whiteout_v_Quaternion* self) {
    whiteout::Quaternion __self = fromC(*self);
    __self.normalize();
    *self = toC(__self);
}

whiteout_v_Quaternion whiteout_v_Quaternion_normalized(whiteout_v_Quaternion self) {
    const whiteout::Quaternion __self = fromC(self);
    return toC(__self.normalized());
}

whiteout_v_Quaternion whiteout_v_Quaternion_add(whiteout_v_Quaternion self, whiteout_v_Quaternion other) {
    const whiteout::Quaternion __self = fromC(self);
    const whiteout::Quaternion __other = fromC(other);
    return toC(__self + __other);
}

whiteout_v_Quaternion whiteout_v_Quaternion_sub(whiteout_v_Quaternion self, whiteout_v_Quaternion other) {
    const whiteout::Quaternion __self = fromC(self);
    const whiteout::Quaternion __other = fromC(other);
    return toC(__self - __other);
}

whiteout_v_Quaternion whiteout_v_Quaternion_mul(whiteout_v_Quaternion self, whiteout_v_Quaternion other) {
    const whiteout::Quaternion __self = fromC(self);
    const whiteout::Quaternion __other = fromC(other);
    return toC(__self * __other);
}

whiteout_v_Quaternion whiteout_v_Quaternion_mul_scalar(whiteout_v_Quaternion self, float scalar) {
    const whiteout::Quaternion __self = fromC(self);
    return toC(__self * scalar);
}

whiteout_v_Quaternion whiteout_v_Quaternion_div_scalar(whiteout_v_Quaternion self, float scalar) {
    const whiteout::Quaternion __self = fromC(self);
    return toC(__self / scalar);
}

whiteout_v_Quaternion whiteout_v_Quaternion_negate(whiteout_v_Quaternion self) {
    const whiteout::Quaternion __self = fromC(self);
    return toC(-__self);
}

int32_t whiteout_v_Quaternion_equals(whiteout_v_Quaternion self, whiteout_v_Quaternion other) {
    const whiteout::Quaternion __self = fromC(self);
    const whiteout::Quaternion __other = fromC(other);
    return (__self == __other) ? 1 : 0;
}

whiteout_v_Quaternion whiteout_v_Quaternion_conjugate(whiteout_v_Quaternion self) {
    const whiteout::Quaternion __self = fromC(self);
    return toC(__self.conjugate());
}

whiteout_v_Quaternion whiteout_v_Quaternion_inverse(whiteout_v_Quaternion self) {
    const whiteout::Quaternion __self = fromC(self);
    return toC(__self.inverse());
}

whiteout_v_Quaternion whiteout_v_Quaternion_log(whiteout_v_Quaternion self) {
    const whiteout::Quaternion __self = fromC(self);
    return toC(__self.log());
}

whiteout_v_Quaternion whiteout_v_Quaternion_exp(whiteout_v_Quaternion self) {
    const whiteout::Quaternion __self = fromC(self);
    return toC(__self.exp());
}

whiteout_v_Vector3f whiteout_v_Quaternion_to_euler_angles(whiteout_v_Quaternion self) {
    const whiteout::Quaternion __self = fromC(self);
    return toC(__self.to_euler_angles());
}

whiteout_v_Vector3f whiteout_v_Quaternion_rotate_vector(whiteout_v_Quaternion self, whiteout_v_Vector3f v) {
    const whiteout::Quaternion __self = fromC(self);
    const whiteout::Vector3f __v = fromC(v);
    return toC(__self.rotate_vector(__v));
}

whiteout_v_Quaternion whiteout_v_Quaternion_identity(void) {
    return toC(whiteout::Quaternion::identity());
}

whiteout_v_Quaternion whiteout_v_Quaternion_from_axis_angle(whiteout_v_Vector3f axis, float angle_rad) {
    const whiteout::Vector3f __axis = fromC(axis);
    return toC(whiteout::Quaternion::from_axis_angle(__axis, angle_rad));
}

whiteout_v_Quaternion whiteout_v_Quaternion_from_euler_angles(whiteout_v_Vector3f euler_rad) {
    const whiteout::Vector3f __euler_rad = fromC(euler_rad);
    return toC(whiteout::Quaternion::from_euler_angles(__euler_rad));
}

whiteout_v_Quaternion whiteout_v_Quaternion_slerp(whiteout_v_Quaternion a, whiteout_v_Quaternion b, float t) {
    const whiteout::Quaternion __a = fromC(a);
    const whiteout::Quaternion __b = fromC(b);
    return toC(whiteout::Quaternion::slerp(__a, __b, t));
}

whiteout_v_Quaternion whiteout_v_Quaternion_squad(whiteout_v_Quaternion start, whiteout_v_Quaternion outtan, whiteout_v_Quaternion inttan, whiteout_v_Quaternion end, float t) {
    const whiteout::Quaternion __start = fromC(start);
    const whiteout::Quaternion __outtan = fromC(outtan);
    const whiteout::Quaternion __inttan = fromC(inttan);
    const whiteout::Quaternion __end = fromC(end);
    return toC(whiteout::Quaternion::squad(__start, __outtan, __inttan, __end, t));
}

whiteout_v_Quaternion whiteout_v_Quaternion_ln_dif(whiteout_v_Quaternion a, whiteout_v_Quaternion b) {
    const whiteout::Quaternion __a = fromC(a);
    const whiteout::Quaternion __b = fromC(b);
    return toC(whiteout::Quaternion::ln_dif(__a, __b));
}

// ── Matrix33f ──────────────────────────────────────────
whiteout_v_Matrix33f whiteout_v_Matrix33f_add(whiteout_v_Matrix33f self, whiteout_v_Matrix33f other) {
    const whiteout::Matrix33f __self = fromC(self);
    const whiteout::Matrix33f __other = fromC(other);
    return toC(__self + __other);
}

whiteout_v_Matrix33f whiteout_v_Matrix33f_sub(whiteout_v_Matrix33f self, whiteout_v_Matrix33f other) {
    const whiteout::Matrix33f __self = fromC(self);
    const whiteout::Matrix33f __other = fromC(other);
    return toC(__self - __other);
}

whiteout_v_Matrix33f whiteout_v_Matrix33f_mul(whiteout_v_Matrix33f self, whiteout_v_Matrix33f other) {
    const whiteout::Matrix33f __self = fromC(self);
    const whiteout::Matrix33f __other = fromC(other);
    return toC(__self * __other);
}

whiteout_v_Matrix33f whiteout_v_Matrix33f_mul_scalar(whiteout_v_Matrix33f self, float scalar) {
    const whiteout::Matrix33f __self = fromC(self);
    return toC(__self * scalar);
}

whiteout_v_Matrix33f whiteout_v_Matrix33f_identity(void) {
    return toC(whiteout::Matrix33f::identity());
}

whiteout_v_Matrix33f whiteout_v_Matrix33f_zero(void) {
    return toC(whiteout::Matrix33f::zero());
}

float whiteout_v_Matrix33f_get_at(whiteout_v_Matrix33f self, size_t row, size_t col) {
    return self.data[row][col];
}

void whiteout_v_Matrix33f_set_at(whiteout_v_Matrix33f* self, size_t row, size_t col, float value) {
    self->data[row][col] = value;
}

// ── Matrix44f ──────────────────────────────────────────
whiteout_v_Matrix44f whiteout_v_Matrix44f_add(whiteout_v_Matrix44f self, whiteout_v_Matrix44f other) {
    const whiteout::Matrix44f __self = fromC(self);
    const whiteout::Matrix44f __other = fromC(other);
    return toC(__self + __other);
}

whiteout_v_Matrix44f whiteout_v_Matrix44f_sub(whiteout_v_Matrix44f self, whiteout_v_Matrix44f other) {
    const whiteout::Matrix44f __self = fromC(self);
    const whiteout::Matrix44f __other = fromC(other);
    return toC(__self - __other);
}

whiteout_v_Matrix44f whiteout_v_Matrix44f_mul(whiteout_v_Matrix44f self, whiteout_v_Matrix44f other) {
    const whiteout::Matrix44f __self = fromC(self);
    const whiteout::Matrix44f __other = fromC(other);
    return toC(__self * __other);
}

whiteout_v_Matrix44f whiteout_v_Matrix44f_mul_scalar(whiteout_v_Matrix44f self, float scalar) {
    const whiteout::Matrix44f __self = fromC(self);
    return toC(__self * scalar);
}

whiteout_v_Matrix44f whiteout_v_Matrix44f_identity(void) {
    return toC(whiteout::Matrix44f::identity());
}

whiteout_v_Matrix44f whiteout_v_Matrix44f_zero(void) {
    return toC(whiteout::Matrix44f::zero());
}

whiteout_v_Matrix44f whiteout_v_Matrix44f_translation(whiteout_v_Vector3f t) {
    const whiteout::Vector3f __t = fromC(t);
    return toC(whiteout::Matrix44f::translation(__t));
}

whiteout_v_Matrix44f whiteout_v_Matrix44f_rotation(whiteout_v_Quaternion q) {
    const whiteout::Quaternion __q = fromC(q);
    return toC(whiteout::Matrix44f::rotation(__q));
}

whiteout_v_Matrix44f whiteout_v_Matrix44f_scaling(whiteout_v_Vector3f s) {
    const whiteout::Vector3f __s = fromC(s);
    return toC(whiteout::Matrix44f::scaling(__s));
}

whiteout_v_Matrix44f whiteout_v_Matrix44f_compose(whiteout_v_Vector3f translation, whiteout_v_Quaternion rotation, whiteout_v_Vector3f scale) {
    const whiteout::Vector3f __translation = fromC(translation);
    const whiteout::Quaternion __rotation = fromC(rotation);
    const whiteout::Vector3f __scale = fromC(scale);
    return toC(whiteout::Matrix44f::compose(__translation, __rotation, __scale));
}

whiteout_v_Matrix44f whiteout_v_Matrix44f_inverse(whiteout_v_Matrix44f m) {
    const whiteout::Matrix44f __m = fromC(m);
    return toC(whiteout::Matrix44f::inverse(__m));
}

whiteout_v_Matrix44f whiteout_v_Matrix44f_rotation_x(float angle) {
    return toC(whiteout::Matrix44f::rotation_x(angle));
}

whiteout_v_Matrix44f whiteout_v_Matrix44f_rotation_y(float angle) {
    return toC(whiteout::Matrix44f::rotation_y(angle));
}

whiteout_v_Matrix44f whiteout_v_Matrix44f_rotation_z(float angle) {
    return toC(whiteout::Matrix44f::rotation_z(angle));
}

whiteout_v_Matrix44f whiteout_v_Matrix44f_look_at_rh(whiteout_v_Vector3f eye, whiteout_v_Vector3f target, whiteout_v_Vector3f up) {
    const whiteout::Vector3f __eye = fromC(eye);
    const whiteout::Vector3f __target = fromC(target);
    const whiteout::Vector3f __up = fromC(up);
    return toC(whiteout::Matrix44f::look_at_rh(__eye, __target, __up));
}

whiteout_v_Matrix44f whiteout_v_Matrix44f_look_at_lh(whiteout_v_Vector3f eye, whiteout_v_Vector3f target, whiteout_v_Vector3f up) {
    const whiteout::Vector3f __eye = fromC(eye);
    const whiteout::Vector3f __target = fromC(target);
    const whiteout::Vector3f __up = fromC(up);
    return toC(whiteout::Matrix44f::look_at_lh(__eye, __target, __up));
}

whiteout_v_Matrix44f whiteout_v_Matrix44f_look_at_lh_sgcompat(whiteout_v_Vector3f eye, whiteout_v_Vector3f target, whiteout_v_Vector3f up) {
    const whiteout::Vector3f __eye = fromC(eye);
    const whiteout::Vector3f __target = fromC(target);
    const whiteout::Vector3f __up = fromC(up);
    return toC(whiteout::Matrix44f::look_at_lh_sgcompat(__eye, __target, __up));
}

whiteout_v_Matrix44f whiteout_v_Matrix44f_perspective_fov_rh(float fovY, float aspect, float nearZ, float farZ) {
    return toC(whiteout::Matrix44f::perspective_fov_rh(fovY, aspect, nearZ, farZ));
}

whiteout_v_Matrix44f whiteout_v_Matrix44f_perspective_fov_lh(float fovY, float aspect, float nearZ, float farZ) {
    return toC(whiteout::Matrix44f::perspective_fov_lh(fovY, aspect, nearZ, farZ));
}

whiteout_v_Matrix44f whiteout_v_Matrix44f_perspective_diag_sgcompat(float fovDiagonal, float aspect, float nearZ, float farZ) {
    return toC(whiteout::Matrix44f::perspective_diag_sgcompat(fovDiagonal, aspect, nearZ, farZ));
}

whiteout_v_Matrix44f whiteout_v_Matrix44f_orthographic_rh(float width, float height, float nearZ, float farZ) {
    return toC(whiteout::Matrix44f::orthographic_rh(width, height, nearZ, farZ));
}

whiteout_v_Matrix44f whiteout_v_Matrix44f_transpose(whiteout_v_Matrix44f self) {
    const whiteout::Matrix44f __self = fromC(self);
    return toC(__self.transpose());
}

whiteout_v_Vector3f whiteout_v_Matrix44f_extract_translation(whiteout_v_Matrix44f self) {
    const whiteout::Matrix44f __self = fromC(self);
    return toC(__self.extract_translation());
}

whiteout_v_Quaternion whiteout_v_Matrix44f_extract_rotation(whiteout_v_Matrix44f self) {
    const whiteout::Matrix44f __self = fromC(self);
    return toC(__self.extract_rotation());
}

whiteout_v_Vector3f whiteout_v_Matrix44f_extract_scale(whiteout_v_Matrix44f self) {
    const whiteout::Matrix44f __self = fromC(self);
    return toC(__self.extract_scale());
}

float whiteout_v_Matrix44f_get_at(whiteout_v_Matrix44f self, size_t row, size_t col) {
    return self.data[row][col];
}

void whiteout_v_Matrix44f_set_at(whiteout_v_Matrix44f* self, size_t row, size_t col, float value) {
    self->data[row][col] = value;
}

// ── Free functions ──────────────────────────────────
whiteout_v_Vector3f whiteout_v_cross(whiteout_v_Vector3f a, whiteout_v_Vector3f b) {
    const whiteout::Vector3f __a = fromC(a);
    const whiteout::Vector3f __b = fromC(b);
    return toC(whiteout::cross(__a, __b));
}

whiteout_v_Vector3f whiteout_v_transform_point(whiteout_v_Vector3f v, whiteout_v_Matrix44f m) {
    const whiteout::Vector3f __v = fromC(v);
    const whiteout::Matrix44f __m = fromC(m);
    return toC(whiteout::transform_point(__v, __m));
}

whiteout_v_Vector3f whiteout_v_transform_normal(whiteout_v_Vector3f v, whiteout_v_Matrix44f m) {
    const whiteout::Vector3f __v = fromC(v);
    const whiteout::Matrix44f __m = fromC(m);
    return toC(whiteout::transform_normal(__v, __m));
}

// ── Tier A: mutable pixel/element access ──────────────
uint8_t* whiteout_v_Texture_data_mut(whiteout_v_Texture* self, size_t* out_size) {
    auto __s = reinterpret_cast<whiteout::textures::Texture*>(self)->data();
    if (out_size) *out_size = __s.size();
    return reinterpret_cast<uint8_t*>(__s.data());
}

uint8_t* whiteout_v_Texture_mipData_mut(whiteout_v_Texture* self, uint32_t mip, uint32_t layer, size_t* out_size) {
    auto __s = reinterpret_cast<whiteout::textures::Texture*>(self)->mipData(mip, layer);
    if (out_size) *out_size = __s.size();
    return reinterpret_cast<uint8_t*>(__s.data());
}

}  // extern "C"