Subversion Repositories Games.Carmageddon

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
20 pmbaty 1
#include "matrix34.h"
2
#include "harness/trace.h"
3
#include "vector.h"
4
#include <math.h>
5
 
6
br_matrix34 mattmp1;
7
br_matrix34 mattmp2;
8
 
9
#define M(x, y) mat->m[x][y]
10
#define A(x, y) A->m[x][y]
11
#define B(x, y) B->m[x][y]
12
#define C(x, y) C->m[x][y]
13
#define BR_MAC3(a, b, c, d, e, f) ((a) * (b) + (c) * (d) + (e) * (f))
14
#define BR_MAC4(a, b, c, d, e, f, g, h) ((a) * (b) + (c) * (d) + (e) * (f) + (g) * (h))
15
 
16
// IDA: void __cdecl BrMatrix34Copy(br_matrix34 *A, br_matrix34 *B)
17
void BrMatrix34Copy(br_matrix34* A, br_matrix34* B) {
18
    LOG_TRACE("(%p, %p)", A, B);
19
 
20
    A(0, 0) = B(0, 0);
21
    A(0, 1) = B(0, 1);
22
    A(0, 2) = B(0, 2);
23
 
24
    A(1, 0) = B(1, 0);
25
    A(1, 1) = B(1, 1);
26
    A(1, 2) = B(1, 2);
27
 
28
    A(2, 0) = B(2, 0);
29
    A(2, 1) = B(2, 1);
30
    A(2, 2) = B(2, 2);
31
 
32
    A(3, 0) = B(3, 0);
33
    A(3, 1) = B(3, 1);
34
    A(3, 2) = B(3, 2);
35
}
36
 
37
// IDA: void __cdecl BrMatrix34Mul(br_matrix34 *A, br_matrix34 *B, br_matrix34 *C)
38
void BrMatrix34Mul(br_matrix34* A, br_matrix34* B, br_matrix34* C) {
39
    LOG_TRACE("(%p, %p, %p)", A, B, C);
40
 
41
    A(0, 0) = BR_MAC3(B(0, 0), C(0, 0), B(0, 1), C(1, 0), B(0, 2), C(2, 0));
42
    A(0, 1) = BR_MAC3(B(0, 0), C(0, 1), B(0, 1), C(1, 1), B(0, 2), C(2, 1));
43
    A(0, 2) = BR_MAC3(B(0, 0), C(0, 2), B(0, 1), C(1, 2), B(0, 2), C(2, 2));
44
    A(1, 0) = BR_MAC3(B(1, 0), C(0, 0), B(1, 1), C(1, 0), B(1, 2), C(2, 0));
45
    A(1, 1) = BR_MAC3(B(1, 0), C(0, 1), B(1, 1), C(1, 1), B(1, 2), C(2, 1));
46
    A(1, 2) = BR_MAC3(B(1, 0), C(0, 2), B(1, 1), C(1, 2), B(1, 2), C(2, 2));
47
    A(2, 0) = BR_MAC3(B(2, 0), C(0, 0), B(2, 1), C(1, 0), B(2, 2), C(2, 0));
48
    A(2, 1) = BR_MAC3(B(2, 0), C(0, 1), B(2, 1), C(1, 1), B(2, 2), C(2, 1));
49
    A(2, 2) = BR_MAC3(B(2, 0), C(0, 2), B(2, 1), C(1, 2), B(2, 2), C(2, 2));
50
    A(3, 0) = BR_MAC3(B(3, 0), C(0, 0), B(3, 1), C(1, 0), B(3, 2), C(2, 0)) + C(3, 0);
51
    A(3, 1) = BR_MAC3(B(3, 0), C(0, 1), B(3, 1), C(1, 1), B(3, 2), C(2, 1)) + C(3, 1);
52
    A(3, 2) = BR_MAC3(B(3, 0), C(0, 2), B(3, 1), C(1, 2), B(3, 2), C(2, 2)) + C(3, 2);
53
}
54
 
55
// IDA: void __cdecl BrMatrix34Identity(br_matrix34 *mat)
56
void BrMatrix34Identity(br_matrix34* mat) {
57
    // { 1, 0, 0},
58
    // { 0, 1, 0},
59
    // { 0, 0, 1}
60
    // ( 0, 0, 0 }
61
    M(0, 0) = 1.f;
62
    M(0, 1) = 0.f;
63
    M(0, 2) = 0.f;
64
 
65
    M(1, 0) = 0.f;
66
    M(1, 1) = 1.f;
67
    M(1, 2) = 0.f;
68
 
69
    M(2, 0) = 0.f;
70
    M(2, 1) = 0.f;
71
    M(2, 2) = 1.f;
72
 
73
    M(3, 0) = 0.f;
74
    M(3, 1) = 0.f;
75
    M(3, 2) = 0.f;
76
}
77
 
78
// IDA: void __cdecl BrMatrix34RotateX(br_matrix34 *mat, br_angle rx)
79
void BrMatrix34RotateX(br_matrix34* mat, br_angle rx) {
80
    br_scalar s;
81
    br_scalar c;
82
    LOG_TRACE("(%p, %d)", mat, rx);
83
 
84
    s = BR_SIN(rx);
85
    c = BR_COS(rx);
86
 
87
    M(0, 0) = 1;
88
    M(0, 1) = 0;
89
    M(0, 2) = 0;
90
    M(1, 0) = 0;
91
    M(1, 1) = c;
92
    M(1, 2) = s;
93
    M(2, 0) = 0;
94
    M(2, 1) = -s;
95
    M(2, 2) = c;
96
    M(3, 0) = 0;
97
    M(3, 1) = 0;
98
    M(3, 2) = 0;
99
}
100
 
101
// IDA: void __cdecl BrMatrix34RotateY(br_matrix34 *mat, br_angle ry)
102
void BrMatrix34RotateY(br_matrix34* mat, br_angle ry) {
103
    br_scalar s;
104
    br_scalar c;
105
    LOG_TRACE("(%p, %d)", mat, ry);
106
 
107
    s = BR_SIN(ry);
108
    c = BR_COS(ry);
109
 
110
    M(0, 0) = c;
111
    M(0, 1) = 0;
112
    M(0, 2) = -s;
113
    M(1, 0) = 0;
114
    M(1, 1) = 1;
115
    M(1, 2) = 0;
116
    M(2, 0) = s;
117
    M(2, 1) = 0;
118
    M(2, 2) = c;
119
    M(3, 0) = 0;
120
    M(3, 1) = 0;
121
    M(3, 2) = 0;
122
}
123
 
124
// IDA: void __cdecl BrMatrix34RotateZ(br_matrix34 *mat, br_angle rz)
125
void BrMatrix34RotateZ(br_matrix34* mat, br_angle rz) {
126
    br_scalar s;
127
    br_scalar c;
128
    LOG_TRACE("(%p, %d)", mat, rz);
129
 
130
    s = BR_SIN(rz);
131
    c = BR_COS(rz);
132
 
133
    M(0, 0) = c;
134
    M(0, 1) = s;
135
    M(0, 2) = 0;
136
    M(1, 0) = -s;
137
    M(1, 1) = c;
138
    M(1, 2) = 0;
139
    M(2, 0) = 0;
140
    M(2, 1) = 0;
141
    M(2, 2) = 1;
142
    M(3, 0) = 0;
143
    M(3, 1) = 0;
144
    M(3, 2) = 0;
145
}
146
 
147
// IDA: void __cdecl BrMatrix34Rotate(br_matrix34 *mat, br_angle r, br_vector3 *a)
148
void BrMatrix34Rotate(br_matrix34* mat, br_angle r, br_vector3* a) {
149
    br_scalar t;
150
    br_scalar s;
151
    br_scalar c;
152
    br_scalar txy;
153
    br_scalar txz;
154
    br_scalar tyz;
155
    br_scalar sx;
156
    br_scalar sy;
157
    br_scalar sz;
158
    LOG_TRACE("(%p, %d, %p)", mat, r, a);
159
 
160
    s = BR_SIN(r);
161
    c = BR_COS(r);
162
    t = (br_scalar) 1.0 - c; // Pierre-Marie Baty -- added type cast
163
 
164
    txy = t * a->v[0];
165
    txz = txy * a->v[2];
166
    txy = txy * a->v[1];
167
    tyz = t * a->v[1] * a->v[2];
168
 
169
    sx = s * a->v[0];
170
    sy = s * a->v[1];
171
    sz = s * a->v[2];
172
 
173
    M(0, 0) = t * a->v[0] * a->v[0] + c;
174
    M(0, 1) = txy + sz;
175
    M(0, 2) = txz - sy;
176
    M(1, 0) = txy - sz;
177
    M(1, 1) = t * a->v[1] * a->v[1] + c;
178
    M(1, 2) = tyz + sx;
179
    M(2, 0) = txz + sy;
180
    M(2, 1) = tyz - sx;
181
    M(2, 2) = t * a->v[2] * a->v[2] + c;
182
 
183
    M(3, 0) = M(3, 1) = M(3, 2) = 0.0;
184
}
185
 
186
// IDA: void __cdecl BrMatrix34Translate(br_matrix34 *mat, br_scalar dx, br_scalar dy, br_scalar dz)
187
void BrMatrix34Translate(br_matrix34* mat, br_scalar dx, br_scalar dy, br_scalar dz) {
188
    LOG_TRACE("(%p, %f, %f, %f)", mat, dx, dy, dz);
189
 
190
    M(0, 0) = 1.f;
191
    M(0, 1) = 0.f;
192
    M(0, 2) = 0.f;
193
    M(1, 0) = 0.f;
194
    M(1, 1) = 1.f;
195
    M(1, 2) = 0.f;
196
    M(2, 0) = 0.f;
197
    M(2, 1) = 0.f;
198
    M(2, 2) = 1.f;
199
    M(3, 0) = dx;
200
    M(3, 1) = dy;
201
    M(3, 2) = dz;
202
}
203
 
204
// IDA: void __cdecl BrMatrix34Scale(br_matrix34 *mat, br_scalar sx, br_scalar sy, br_scalar sz)
205
void BrMatrix34Scale(br_matrix34* mat, br_scalar sx, br_scalar sy, br_scalar sz) {
206
    LOG_TRACE("(%p, %f, %f, %f)", mat, sx, sy, sz);
207
 
208
    M(0, 0) = sx;
209
    M(0, 1) = 0.f;
210
    M(0, 2) = 0.f;
211
    M(1, 0) = 0.f;
212
    M(1, 1) = sy;
213
    M(1, 2) = 0.f;
214
    M(2, 0) = 0.f;
215
    M(2, 1) = 0.f;
216
    M(2, 2) = sz;
217
    M(3, 0) = 0.f;
218
    M(3, 1) = 0.f;
219
    M(3, 2) = 0.f;
220
}
221
 
222
// IDA: void __cdecl BrMatrix34ShearX(br_matrix34 *mat, br_scalar sy, br_scalar sz)
223
void BrMatrix34ShearX(br_matrix34* mat, br_scalar sy, br_scalar sz) {
224
    LOG_TRACE("(%p, %f, %f)", mat, sy, sz);
225
 
226
    M(0, 0) = 1.f;
227
    M(0, 1) = sy;
228
    M(0, 2) = sz;
229
    M(1, 0) = 0.f;
230
    M(1, 1) = 1.f;
231
    M(1, 2) = 0.f;
232
    M(2, 0) = 0.f;
233
    M(2, 1) = 0.f;
234
    M(2, 2) = 1.f;
235
    M(3, 0) = 0.f;
236
    M(3, 1) = 0.f;
237
    M(3, 2) = 0.f;
238
}
239
 
240
// IDA: void __cdecl BrMatrix34ShearY(br_matrix34 *mat, br_scalar sx, br_scalar sz)
241
void BrMatrix34ShearY(br_matrix34* mat, br_scalar sx, br_scalar sz) {
242
    LOG_TRACE("(%p, %f, %f)", mat, sx, sz);
243
 
244
    M(0, 0) = 1.f;
245
    M(0, 1) = 0.f;
246
    M(0, 2) = 0.f;
247
    M(1, 0) = sx;
248
    M(1, 1) = 1.f;
249
    M(1, 2) = sz;
250
    M(2, 0) = 0.f;
251
    M(2, 1) = 0.f;
252
    M(2, 2) = 1.f;
253
    M(3, 0) = 0.f;
254
    M(3, 1) = 0.f;
255
    M(3, 2) = 0.f;
256
}
257
 
258
// IDA: void __cdecl BrMatrix34ShearZ(br_matrix34 *mat, br_scalar sx, br_scalar sy)
259
void BrMatrix34ShearZ(br_matrix34* mat, br_scalar sx, br_scalar sy) {
260
    LOG_TRACE("(%p, %f, %f)", mat, sx, sy);
261
 
262
    M(0, 0) = 1.f;
263
    M(0, 1) = 0.f;
264
    M(0, 2) = 0.f;
265
    M(1, 0) = 0.f;
266
    M(1, 1) = 1.f;
267
    M(1, 2) = 0.f;
268
    M(2, 0) = sx;
269
    M(2, 1) = sy;
270
    M(2, 2) = 1.f;
271
    M(3, 0) = 0.f;
272
    M(3, 1) = 0.f;
273
    M(3, 2) = 0.f;
274
}
275
 
276
// IDA: br_scalar __cdecl BrMatrix34Inverse(br_matrix34 *B, br_matrix34 *A)
277
br_scalar BrMatrix34Inverse(br_matrix34* B, br_matrix34* A) {
278
    float idet;
279
    float det;
280
    float pos;
281
    float neg;
282
    float temp;
283
    float AF[4][3];
284
    float BF[4][3];
285
    int i;
286
    LOG_TRACE("(%p, %p)", B, A);
287
 
288
#define AF(x, y) (AF[x][y])
289
#define BF(x, y) (BF[x][y])
290
 
291
#define ACCUMULATE   \
292
    if (temp >= 0.f) \
293
        pos += temp; \
294
    else             \
295
        neg += temp;
296
#define PRECISION_LIMIT BR_SCALAR(1.0e-15)
297
#define ABS(a) (((a) < 0) ? -(a) : (a))
298
 
299
    for (i = 0; i < 4; i++) {
300
        AF(i, 0) = A(i, 0);
301
        AF(i, 1) = A(i, 1);
302
        AF(i, 2) = A(i, 2);
303
    }
304
 
305
    pos = neg = 0.0F;
306
    temp = AF(0, 0) * AF(1, 1) * AF(2, 2);
307
    ACCUMULATE
308
    temp = AF(0, 1) * AF(1, 2) * AF(2, 0);
309
    ACCUMULATE
310
    temp = AF(0, 2) * AF(1, 0) * AF(2, 1);
311
    ACCUMULATE
312
    temp = -AF(0, 2) * AF(1, 1) * AF(2, 0);
313
    ACCUMULATE
314
    temp = -AF(0, 1) * AF(1, 0) * AF(2, 2);
315
    ACCUMULATE
316
    temp = -AF(0, 0) * AF(1, 2) * AF(2, 1);
317
    ACCUMULATE
318
    det = pos + neg;
319
 
320
    if (ABS(det) <= PRECISION_LIMIT)
321
        return 0.f;
322
 
323
    if ((ABS(det / (pos - neg)) < PRECISION_LIMIT)) {
324
        return 0.f;
325
    }
326
 
327
    idet = 1.f / det;
328
 
329
    BF(0, 0) = (AF(1, 1) * AF(2, 2) - AF(1, 2) * AF(2, 1)) * idet;
330
    BF(1, 0) = -(AF(1, 0) * AF(2, 2) - AF(1, 2) * AF(2, 0)) * idet;
331
    BF(2, 0) = (AF(1, 0) * AF(2, 1) - AF(1, 1) * AF(2, 0)) * idet;
332
    BF(0, 1) = -(AF(0, 1) * AF(2, 2) - AF(0, 2) * AF(2, 1)) * idet;
333
    BF(1, 1) = (AF(0, 0) * AF(2, 2) - AF(0, 2) * AF(2, 0)) * idet;
334
    BF(2, 1) = -(AF(0, 0) * AF(2, 1) - AF(0, 1) * AF(2, 0)) * idet;
335
    BF(0, 2) = (AF(0, 1) * AF(1, 2) - AF(0, 2) * AF(1, 1)) * idet;
336
    BF(1, 2) = -(AF(0, 0) * AF(1, 2) - AF(0, 2) * AF(1, 0)) * idet;
337
    BF(2, 2) = (AF(0, 0) * AF(1, 1) - AF(0, 1) * AF(1, 0)) * idet;
338
 
339
    BF(3, 0) = -(AF(3, 0) * BF(0, 0) + AF(3, 1) * BF(1, 0) + AF(3, 2) * BF(2, 0));
340
    BF(3, 1) = -(AF(3, 0) * BF(0, 1) + AF(3, 1) * BF(1, 1) + AF(3, 2) * BF(2, 1));
341
    BF(3, 2) = -(AF(3, 0) * BF(0, 2) + AF(3, 1) * BF(1, 2) + AF(3, 2) * BF(2, 2));
342
 
343
    for (i = 0; i < 4; i++) {
344
        B(i, 0) = BF(i, 0);
345
        B(i, 1) = BF(i, 1);
346
        B(i, 2) = BF(i, 2);
347
    }
348
 
349
    return det;
350
}
351
 
352
// IDA: void __cdecl BrMatrix34LPInverse(br_matrix34 *A, br_matrix34 *B)
353
void BrMatrix34LPInverse(br_matrix34* A, br_matrix34* B) {
354
    LOG_TRACE("(%p, %p)", A, B);
355
 
356
    A(0, 0) = B(0, 0);
357
    A(0, 1) = B(1, 0);
358
    A(0, 2) = B(2, 0);
359
 
360
    A(1, 0) = B(0, 1);
361
    A(1, 1) = B(1, 1);
362
    A(1, 2) = B(2, 1);
363
 
364
    A(2, 0) = B(0, 2);
365
    A(2, 1) = B(1, 2);
366
    A(2, 2) = B(2, 2);
367
 
368
    A(3, 0) = -BR_MAC3(B(3, 0), A(0, 0), B(3, 1), A(1, 0), B(3, 2), A(2, 0));
369
    A(3, 1) = -BR_MAC3(B(3, 0), A(0, 1), B(3, 1), A(1, 1), B(3, 2), A(2, 1));
370
    A(3, 2) = -BR_MAC3(B(3, 0), A(0, 2), B(3, 1), A(1, 2), B(3, 2), A(2, 2));
371
}
372
 
373
// IDA: void __cdecl BrMatrix34LPNormalise(br_matrix34 *A, br_matrix34 *B)
374
void BrMatrix34LPNormalise(br_matrix34* A, br_matrix34* B) {
375
    LOG_TRACE("(%p, %p)", A, B);
376
 
377
    BrVector3Normalise((br_vector3*)A->m[2], (br_vector3*)B->m[2]);
378
    BrVector3Cross((br_vector3*)A->m[0], (br_vector3*)B->m[1], (br_vector3*)A->m[2]);
379
    BrVector3Normalise((br_vector3*)A->m[0], (br_vector3*)A->m[0]);
380
    BrVector3Cross((br_vector3*)A->m[1], (br_vector3*)A->m[2], (br_vector3*)A->m[0]);
381
 
382
    A(3, 0) = B(3, 0);
383
    A(3, 1) = B(3, 1);
384
    A(3, 2) = B(3, 2);
385
}
386
 
387
// IDA: void __cdecl BrMatrix34RollingBall(br_matrix34 *mat, int dx, int dy, int radius)
388
void BrMatrix34RollingBall(br_matrix34* mat, int dx, int dy, int radius) {
389
    br_scalar nx;
390
    br_scalar ny;
391
    br_scalar ca;
392
    br_scalar sa;
393
    br_scalar dr;
394
    br_scalar h;
395
    LOG_TRACE("(%p, %d, %d, %d)", mat, dx, dy, radius);
396
 
397
    // The rolling ball, Graphics Gems III (1993), pages 51-60, Academic Press
398
 
399
    dr = sqrtf((float)(dx * dx + dy * dy)); // Pierre-Marie Baty -- added type cast
400
    if (dr == BR_SCALAR(.0f)) {
401
        BrMatrix34Identity(mat);
402
        return;
403
    }
404
    h = sqrtf(dr * dr + radius * radius);
405
    ca = radius / h;
406
    sa = dr / h;
407
    nx = -dy / dr;
408
    ny = dx / dr;
409
    // nz = 0;
410
 
411
    h = (1 - ca);
412
 
413
    M(0, 0) = nx * nx * h + ca;
414
    M(0, 1) = nx * ny * h;
415
    M(0, 2) = ny * sa;
416
    M(1, 1) = ca + ny * ny * h;
417
    M(1, 2) = -nx * sa;
418
    M(2, 2) = ca;
419
 
420
    M(1, 0) = M(0, 1);
421
    M(2, 0) = -M(0, 2);
422
    M(2, 1) = -M(1, 2);
423
 
424
    M(3, 0) = BR_SCALAR(0.f);
425
    M(3, 1) = BR_SCALAR(0.f);
426
    M(3, 2) = BR_SCALAR(0.f);
427
}
428
 
429
// IDA: br_matrix34* __cdecl BrBoundsToMatrix34(br_matrix34 *mat, br_bounds *bounds)
430
br_matrix34* BrBoundsToMatrix34(br_matrix34* mat, br_bounds* bounds) {
431
    int i;
432
    br_vector3 tr;
433
    br_vector3 sc;
434
    LOG_TRACE("(%p, %p)", mat, bounds);
435
 
436
    for (i = 0; i < 3; ++i) {
437
        tr.v[i] = 0.5f * bounds->min.v[i] + 0.5f * bounds->max.v[i];
438
        if (bounds->min.v[i] == bounds->max.v[i]) {
439
            sc.v[i] = 1.f;
440
        } else {
441
            sc.v[i] = 0.5f * bounds->max.v[i] - 0.5f * bounds->min.v[i];
442
        }
443
    }
444
 
445
    M(0, 0) = sc.v[0];
446
    M(0, 1) = 0.f;
447
    M(0, 2) = 0.f;
448
    M(1, 0) = 0.f;
449
    M(1, 1) = sc.v[1];
450
    M(1, 2) = 0.f;
451
    M(2, 0) = 0.f;
452
    M(2, 1) = 0.f;
453
    M(2, 2) = sc.v[2];
454
    M(3, 0) = tr.v[0];
455
    M(3, 1) = tr.v[1];
456
    M(3, 2) = tr.v[2];
457
    return mat;
458
}
459
 
460
// IDA: void __cdecl BrMatrix34Copy4(br_matrix34 *A, br_matrix4 *B)
461
void BrMatrix34Copy4(br_matrix34* A, br_matrix4* B) {
462
    LOG_TRACE("(%p, %p)", A, B);
463
 
464
    A(0, 0) = B(0, 0);
465
    A(0, 1) = B(0, 1);
466
    A(0, 2) = B(0, 2);
467
 
468
    A(1, 0) = B(1, 0);
469
    A(1, 1) = B(1, 1);
470
    A(1, 2) = B(1, 2);
471
 
472
    A(2, 0) = B(2, 0);
473
    A(2, 1) = B(2, 1);
474
    A(2, 2) = B(2, 2);
475
 
476
    A(3, 0) = B(3, 0);
477
    A(3, 1) = B(3, 1);
478
    A(3, 2) = B(3, 2);
479
}
480
 
481
// IDA: void __usercall BrMatrix34TApplyFV(br_vector3 *A@<EAX>, br_fvector3 *B@<EDX>, br_matrix34 *C@<EBX>)
482
void BrMatrix34TApplyFV(br_vector3* A, br_fvector3* B, br_matrix34* C) {
483
    LOG_TRACE("(%p, %p, %p)", A, B, C);
484
 
485
    A->v[0] = BR_MAC3(B->v[0], C(0, 0), B->v[1], C(0, 1), B->v[2], C(0, 2));
486
    A->v[1] = BR_MAC3(B->v[0], C(1, 0), B->v[1], C(1, 1), B->v[2], C(1, 2));
487
    A->v[2] = BR_MAC3(B->v[0], C(2, 0), B->v[1], C(2, 1), B->v[2], C(2, 2));
488
}
489
 
490
// IDA: void __cdecl BrMatrix34Apply(br_vector3 *A, br_vector4 *B, br_matrix34 *C)
491
void BrMatrix34Apply(br_vector3* A, br_vector4* B, br_matrix34* C) {
492
    LOG_TRACE("(%p, %p, %p)", A, B, C);
493
 
494
    A->v[0] = BR_MAC4(B->v[0], C(0, 0), B->v[1], C(1, 0), B->v[2], C(2, 0), B->v[3], C(3, 0));
495
    A->v[1] = BR_MAC4(B->v[0], C(0, 1), B->v[1], C(1, 1), B->v[2], C(2, 1), B->v[3], C(3, 1));
496
    A->v[2] = BR_MAC4(B->v[0], C(0, 2), B->v[1], C(1, 2), B->v[2], C(2, 2), B->v[3], C(3, 2));
497
}
498
 
499
// IDA: void __cdecl BrMatrix34ApplyP(br_vector3 *A, br_vector3 *B, br_matrix34 *C)
500
void BrMatrix34ApplyP(br_vector3* A, br_vector3* B, br_matrix34* C) {
501
    LOG_TRACE("(%p, %p, %p)", A, B, C);
502
 
503
    A->v[0] = BR_MAC3(B->v[0], C(0, 0), B->v[1], C(1, 0), B->v[2], C(2, 0)) + C(3, 0);
504
    A->v[1] = BR_MAC3(B->v[0], C(0, 1), B->v[1], C(1, 1), B->v[2], C(2, 1)) + C(3, 1);
505
    A->v[2] = BR_MAC3(B->v[0], C(0, 2), B->v[1], C(1, 2), B->v[2], C(2, 2)) + C(3, 2);
506
}
507
 
508
// IDA: void __cdecl BrMatrix34ApplyV(br_vector3 *A, br_vector3 *B, br_matrix34 *C)
509
void BrMatrix34ApplyV(br_vector3* A, br_vector3* B, br_matrix34* C) {
510
    LOG_TRACE("(%p, %p, %p)", A, B, C);
511
 
512
    A->v[0] = BR_MAC3(B->v[0], C(0, 0), B->v[1], C(1, 0), B->v[2], C(2, 0));
513
    A->v[1] = BR_MAC3(B->v[0], C(0, 1), B->v[1], C(1, 1), B->v[2], C(2, 1));
514
    A->v[2] = BR_MAC3(B->v[0], C(0, 2), B->v[1], C(1, 2), B->v[2], C(2, 2));
515
}
516
 
517
// IDA: void __cdecl BrMatrix34TApply(br_vector4 *A, br_vector4 *B, br_matrix34 *C)
518
void BrMatrix34TApply(br_vector4* A, br_vector4* B, br_matrix34* C) {
519
    LOG_TRACE("(%p, %p, %p)", A, B, C)
520
 
521
    A->v[0] = BR_MAC3(B->v[0], C(0, 0), B->v[1], C(0, 1), B->v[2], C(0, 2));
522
    A->v[1] = BR_MAC3(B->v[0], C(1, 0), B->v[1], C(1, 1), B->v[2], C(1, 2));
523
    A->v[2] = BR_MAC3(B->v[0], C(2, 0), B->v[1], C(2, 1), B->v[2], C(2, 2));
524
    A->v[3] = BR_MAC3(B->v[0], C(3, 0), B->v[1], C(3, 1), B->v[2], C(3, 2)) + B->v[3];
525
}
526
 
527
// IDA: void __cdecl BrMatrix34TApplyP(br_vector3 *A, br_vector3 *B, br_matrix34 *C)
528
void BrMatrix34TApplyP(br_vector3* A, br_vector3* B, br_matrix34* C) {
529
    LOG_TRACE("(%p, %p, %p)", A, B, C);
530
 
531
    // translation elements are presumed zero or irrelevant
532
    A->v[0] = BR_MAC3(B->v[0], C(0, 0), B->v[1], C(0, 1), B->v[2], C(0, 2));
533
    A->v[1] = BR_MAC3(B->v[0], C(1, 0), B->v[1], C(1, 1), B->v[2], C(1, 2));
534
    A->v[2] = BR_MAC3(B->v[0], C(2, 0), B->v[1], C(2, 1), B->v[2], C(2, 2));
535
}
536
 
537
// IDA: void __cdecl BrMatrix34TApplyV(br_vector3 *A, br_vector3 *B, br_matrix34 *C)
538
void BrMatrix34TApplyV(br_vector3* A, br_vector3* B, br_matrix34* C) {
539
    LOG_TRACE("(%p, %p, %p)", A, B, C);
540
 
541
    // translation elements are presumed zero or irrelevant
542
    A->v[0] = BR_MAC3(B->v[0], C(0, 0), B->v[1], C(0, 1), B->v[2], C(0, 2));
543
    A->v[1] = BR_MAC3(B->v[0], C(1, 0), B->v[1], C(1, 1), B->v[2], C(1, 2));
544
    A->v[2] = BR_MAC3(B->v[0], C(2, 0), B->v[1], C(2, 1), B->v[2], C(2, 2));
545
}
546
 
547
// IDA: void __cdecl BrMatrix34Pre(br_matrix34 *mat, br_matrix34 *A)
548
void BrMatrix34Pre(br_matrix34* mat, br_matrix34* A) {
549
    LOG_TRACE("(%p, %p)", mat, A);
550
 
551
    BrMatrix34Mul(&mattmp1, A, mat);
552
    BrMatrix34Copy(mat, &mattmp1);
553
}
554
 
555
// IDA: void __cdecl BrMatrix34Post(br_matrix34 *mat, br_matrix34 *A)
556
void BrMatrix34Post(br_matrix34* mat, br_matrix34* A) {
557
    LOG_TRACE("(%p, %p)", mat, A);
558
 
559
    BrMatrix34Mul(&mattmp1, mat, A);
560
    BrMatrix34Copy(mat, &mattmp1);
561
}
562
 
563
// IDA: void __cdecl BrMatrix34PreRotateX(br_matrix34 *mat, br_angle rx)
564
void BrMatrix34PreRotateX(br_matrix34* mat, br_angle rx) {
565
    LOG_TRACE("(%p, %d)", mat, rx);
566
 
567
    BrMatrix34RotateX(&mattmp2, rx);
568
    BrMatrix34Mul(&mattmp1, &mattmp2, mat);
569
    BrMatrix34Copy(mat, &mattmp1);
570
}
571
 
572
// IDA: void __cdecl BrMatrix34PostRotateX(br_matrix34 *mat, br_angle rx)
573
void BrMatrix34PostRotateX(br_matrix34* mat, br_angle rx) {
574
    LOG_TRACE("(%p, %d)", mat, rx);
575
 
576
    BrMatrix34RotateX(&mattmp2, rx);
577
    BrMatrix34Mul(&mattmp1, mat, &mattmp2);
578
    BrMatrix34Copy(mat, &mattmp1);
579
}
580
 
581
// IDA: void __cdecl BrMatrix34PreRotateY(br_matrix34 *mat, br_angle ry)
582
void BrMatrix34PreRotateY(br_matrix34* mat, br_angle ry) {
583
    LOG_TRACE("(%p, %d)", mat, ry);
584
 
585
    BrMatrix34RotateY(&mattmp2, ry);
586
    BrMatrix34Mul(&mattmp1, &mattmp2, mat);
587
    BrMatrix34Copy(mat, &mattmp1);
588
}
589
 
590
// IDA: void __cdecl BrMatrix34PostRotateY(br_matrix34 *mat, br_angle ry)
591
void BrMatrix34PostRotateY(br_matrix34* mat, br_angle ry) {
592
    LOG_TRACE("(%p, %d)", mat, ry);
593
 
594
    BrMatrix34RotateY(&mattmp2, ry);
595
    BrMatrix34Mul(&mattmp1, mat, &mattmp2);
596
    BrMatrix34Copy(mat, &mattmp1);
597
}
598
 
599
// IDA: void __cdecl BrMatrix34PreRotateZ(br_matrix34 *mat, br_angle rz)
600
void BrMatrix34PreRotateZ(br_matrix34* mat, br_angle rz) {
601
    LOG_TRACE("(%p, %d)", mat, rz);
602
 
603
    BrMatrix34RotateZ(&mattmp2, rz);
604
    BrMatrix34Mul(&mattmp1, &mattmp2, mat);
605
    BrMatrix34Copy(mat, &mattmp1);
606
}
607
 
608
// IDA: void __cdecl BrMatrix34PostRotateZ(br_matrix34 *mat, br_angle rz)
609
void BrMatrix34PostRotateZ(br_matrix34* mat, br_angle rz) {
610
    LOG_TRACE("(%p, %d)", mat, rz);
611
 
612
    BrMatrix34RotateZ(&mattmp2, rz);
613
    BrMatrix34Mul(&mattmp1, mat, &mattmp2);
614
    BrMatrix34Copy(mat, &mattmp1);
615
}
616
 
617
// IDA: void __cdecl BrMatrix34PreRotate(br_matrix34 *mat, br_angle r, br_vector3 *axis)
618
void BrMatrix34PreRotate(br_matrix34* mat, br_angle r, br_vector3* axis) {
619
    LOG_TRACE("(%p, %d, %p)", mat, r, axis);
620
 
621
    BrMatrix34Rotate(&mattmp2, r, axis);
622
    BrMatrix34Mul(&mattmp1, &mattmp2, mat);
623
    BrMatrix34Copy(mat, &mattmp1);
624
}
625
 
626
// IDA: void __cdecl BrMatrix34PostRotate(br_matrix34 *mat, br_angle r, br_vector3 *axis)
627
void BrMatrix34PostRotate(br_matrix34* mat, br_angle r, br_vector3* axis) {
628
    LOG_TRACE("(%p, %d, %p)", mat, r, axis);
629
 
630
    BrMatrix34Rotate(&mattmp2, r, axis);
631
    BrMatrix34Mul(&mattmp1, mat, &mattmp2);
632
    BrMatrix34Copy(mat, &mattmp1);
633
}
634
 
635
// IDA: void __cdecl BrMatrix34PreTranslate(br_matrix34 *mat, br_scalar x, br_scalar y, br_scalar z)
636
void BrMatrix34PreTranslate(br_matrix34* mat, br_scalar x, br_scalar y, br_scalar z) {
637
    LOG_TRACE("(%p, %f, %f, %f)", mat, x, y, z);
638
 
639
    BrMatrix34Translate(&mattmp2, x, y, z);
640
    BrMatrix34Mul(&mattmp1, &mattmp2, mat);
641
    BrMatrix34Copy(mat, &mattmp1);
642
}
643
 
644
// IDA: void __cdecl BrMatrix34PostTranslate(br_matrix34 *mat, br_scalar x, br_scalar y, br_scalar z)
645
void BrMatrix34PostTranslate(br_matrix34* mat, br_scalar x, br_scalar y, br_scalar z) {
646
    LOG_TRACE("(%p, %f, %f, %f)", mat, x, y, z);
647
 
648
    M(3, 0) += x;
649
    M(3, 1) += y;
650
    M(3, 2) += z;
651
}
652
 
653
// IDA: void __cdecl BrMatrix34PreScale(br_matrix34 *mat, br_scalar sx, br_scalar sy, br_scalar sz)
654
void BrMatrix34PreScale(br_matrix34* mat, br_scalar sx, br_scalar sy, br_scalar sz) {
655
    LOG_TRACE("(%p, %f, %f, %f)", mat, sx, sy, sz);
656
 
657
    BrMatrix34Scale(&mattmp2, sx, sy, sz);
658
    BrMatrix34Mul(&mattmp1, &mattmp2, mat);
659
    BrMatrix34Copy(mat, &mattmp1);
660
}
661
 
662
// IDA: void __cdecl BrMatrix34PostScale(br_matrix34 *mat, br_scalar sx, br_scalar sy, br_scalar sz)
663
void BrMatrix34PostScale(br_matrix34* mat, br_scalar sx, br_scalar sy, br_scalar sz) {
664
    LOG_TRACE("(%p, %f, %f, %f)", mat, sx, sy, sz);
665
 
666
    BrMatrix34Scale(&mattmp1, sx, sy, sz);
667
    BrMatrix34Mul(&mattmp2, mat, &mattmp1);
668
    BrMatrix34Copy(mat, &mattmp2);
669
}
670
 
671
// IDA: void __cdecl BrMatrix34PreShearX(br_matrix34 *mat, br_scalar sy, br_scalar sz)
672
void BrMatrix34PreShearX(br_matrix34* mat, br_scalar sy, br_scalar sz) {
673
    LOG_TRACE("(%p, %f, %f)", mat, sy, sz);
674
 
675
    BrMatrix34ShearX(&mattmp2, sy, sz);
676
    BrMatrix34Mul(&mattmp1, &mattmp2, mat);
677
    BrMatrix34Copy(mat, &mattmp1);
678
}
679
 
680
// IDA: void __cdecl BrMatrix34PostShearX(br_matrix34 *mat, br_scalar sy, br_scalar sz)
681
void BrMatrix34PostShearX(br_matrix34* mat, br_scalar sy, br_scalar sz) {
682
    LOG_TRACE("(%p, %f, %f)", mat, sy, sz);
683
 
684
    BrMatrix34ShearX(&mattmp2, sy, sz);
685
    BrMatrix34Mul(&mattmp1, mat, &mattmp2);
686
    BrMatrix34Copy(mat, &mattmp1);
687
}
688
 
689
// IDA: void __cdecl BrMatrix34PreShearY(br_matrix34 *mat, br_scalar sx, br_scalar sz)
690
void BrMatrix34PreShearY(br_matrix34* mat, br_scalar sx, br_scalar sz) {
691
    LOG_TRACE("(%p, %f, %f)", mat, sx, sz);
692
 
693
    BrMatrix34ShearY(&mattmp2, sx, sz);
694
    BrMatrix34Mul(&mattmp1, &mattmp2, mat);
695
    BrMatrix34Copy(mat, &mattmp1);
696
}
697
 
698
// IDA: void __cdecl BrMatrix34PostShearY(br_matrix34 *mat, br_scalar sx, br_scalar sz)
699
void BrMatrix34PostShearY(br_matrix34* mat, br_scalar sx, br_scalar sz) {
700
    LOG_TRACE("(%p, %f, %f)", mat, sx, sz);
701
 
702
    BrMatrix34ShearY(&mattmp2, sx, sz);
703
    BrMatrix34Mul(&mattmp1, mat, &mattmp2);
704
    BrMatrix34Copy(mat, &mattmp1);
705
}
706
 
707
// IDA: void __cdecl BrMatrix34PreShearZ(br_matrix34 *mat, br_scalar sx, br_scalar sy)
708
void BrMatrix34PreShearZ(br_matrix34* mat, br_scalar sx, br_scalar sy) {
709
    LOG_TRACE("(%p, %f, %f)", mat, sx, sy);
710
 
711
    BrMatrix34ShearZ(&mattmp2, sx, sy);
712
    BrMatrix34Mul(&mattmp1, &mattmp2, mat);
713
    BrMatrix34Copy(mat, &mattmp1);
714
}
715
 
716
// IDA: void __cdecl BrMatrix34PostShearZ(br_matrix34 *mat, br_scalar sx, br_scalar sy)
717
void BrMatrix34PostShearZ(br_matrix34* mat, br_scalar sx, br_scalar sy) {
718
    LOG_TRACE("(%p, %f, %f)", mat, sx, sy);
719
 
720
    BrMatrix34ShearZ(&mattmp2, sx, sy);
721
    BrMatrix34Mul(&mattmp1, mat, &mattmp2);
722
    BrMatrix34Copy(mat, &mattmp1);
723
}