Rev 18 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1 | pmbaty | 1 | #include "trig.h" |
20 | pmbaty | 2 | #include "brender/brender.h" |
1 | pmbaty | 3 | #include "harness/trace.h" |
4 | #include <math.h> |
||
5 | #include <stdlib.h> |
||
6 | |||
7 | float gFloat_sine_table[91] = { |
||
8 | 0.0f, |
||
9 | 0.017452f, |
||
10 | 0.034899f, |
||
11 | 0.052336f, |
||
12 | 0.069756f, |
||
13 | 0.087156f, |
||
14 | 0.104528f, |
||
15 | 0.121869f, |
||
16 | 0.139173f, |
||
17 | 0.156434f, |
||
18 | 0.173648f, |
||
19 | 0.190809f, |
||
20 | 0.207912f, |
||
21 | 0.224951f, |
||
22 | 0.241922f, |
||
23 | 0.258819f, |
||
24 | 0.275637f, |
||
25 | 0.292372f, |
||
26 | 0.309017f, |
||
27 | 0.325568f, |
||
28 | 0.342020f, |
||
29 | 0.358368f, |
||
30 | 0.374607f, |
||
31 | 0.390731f, |
||
32 | 0.406737f, |
||
33 | 0.422618f, |
||
34 | 0.438371f, |
||
35 | 0.453990f, |
||
36 | 0.469472f, |
||
37 | 0.484810f, |
||
38 | 0.5f, |
||
39 | 0.51503801f, |
||
40 | 0.52991903f, |
||
41 | 0.54463899f, |
||
42 | 0.55919302f, |
||
43 | 0.57357597f, |
||
44 | 0.58778501f, |
||
45 | 0.60181499f, |
||
46 | 0.61566103f, |
||
47 | 0.62932003f, |
||
48 | 0.64278799f, |
||
49 | 0.65605903f, |
||
50 | 0.66913098f, |
||
51 | 0.68199801f, |
||
52 | 0.69465798f, |
||
53 | 0.70710701f, |
||
54 | 0.71934003f, |
||
55 | 0.731354f, |
||
56 | 0.74314499f, |
||
57 | 0.75471002f, |
||
58 | 0.76604402f, |
||
59 | 0.77714598f, |
||
60 | 0.78801101f, |
||
61 | 0.79863602f, |
||
62 | 0.809017f, |
||
63 | 0.819152f, |
||
64 | 0.82903802f, |
||
65 | 0.83867103f, |
||
66 | 0.84804797f, |
||
67 | 0.85716701f, |
||
68 | 0.86602497f, |
||
69 | 0.87462002f, |
||
70 | 0.88294798f, |
||
71 | 0.89100701f, |
||
72 | 0.898794f, |
||
73 | 0.906308f, |
||
74 | 0.91354501f, |
||
75 | 0.92050499f, |
||
76 | 0.92718399f, |
||
77 | 0.93357998f, |
||
78 | 0.93969297f, |
||
79 | 0.94551897f, |
||
80 | 0.95105702f, |
||
81 | 0.95630503f, |
||
82 | 0.96126199f, |
||
83 | 0.96592599f, |
||
84 | 0.97029603f, |
||
85 | 0.97437f, |
||
86 | 0.97814798f, |
||
87 | 0.98162699f, |
||
88 | 0.98480803f, |
||
89 | 0.987688f, |
||
90 | 0.99026799f, |
||
91 | 0.99254602f, |
||
92 | 0.99452198f, |
||
93 | 0.99619502f, |
||
94 | 0.99756402f, |
||
95 | 0.99862999f, |
||
96 | 0.99939102f, |
||
97 | 0.99984801f, |
||
98 | 1.0f, |
||
99 | }; |
||
100 | br_fixed_ls gFixed_sine_table[91]; |
||
101 | br_matrix23 mat23tmp1; |
||
102 | br_matrix23 mat23tmp2; |
||
103 | br_matrix34 mattmp1__trig; // suffix added to avoid duplicate symbol |
||
104 | br_matrix34 mattmp2__trig; // suffix added to avoid duplicate symbol |
||
105 | |||
106 | // IDA: float __usercall FastFloatSin@<ST0>(int pAngle_in_degrees@<EAX>) |
||
107 | float FastFloatSin(int pAngle_in_degrees) { |
||
108 | LOG_TRACE("(%d)", pAngle_in_degrees); |
||
109 | |||
110 | if (pAngle_in_degrees >= 0) { |
||
111 | pAngle_in_degrees = pAngle_in_degrees % 360; |
||
112 | } else { |
||
113 | pAngle_in_degrees = 360 - -pAngle_in_degrees % 360; |
||
114 | } |
||
115 | if (pAngle_in_degrees > 270) { |
||
116 | return -gFloat_sine_table[360 - pAngle_in_degrees]; |
||
117 | } |
||
118 | if (pAngle_in_degrees > 180) { |
||
119 | return -gFloat_sine_table[pAngle_in_degrees - 180]; |
||
120 | } |
||
121 | if (pAngle_in_degrees <= 90) { |
||
122 | return gFloat_sine_table[pAngle_in_degrees]; |
||
123 | } |
||
124 | return gFloat_sine_table[180 - pAngle_in_degrees]; |
||
125 | } |
||
126 | |||
127 | // IDA: float __usercall FastFloatCos@<ST0>(int pAngle_in_degrees@<EAX>) |
||
128 | float FastFloatCos(int pAngle_in_degrees) { |
||
129 | LOG_TRACE("(%d)", pAngle_in_degrees); |
||
130 | |||
131 | if (pAngle_in_degrees >= 0) { |
||
132 | pAngle_in_degrees = pAngle_in_degrees % 360; |
||
133 | } else { |
||
134 | pAngle_in_degrees = 360 - -pAngle_in_degrees % 360; |
||
135 | } |
||
136 | |||
137 | if (pAngle_in_degrees > 270) { |
||
138 | return gFloat_sine_table[pAngle_in_degrees - 270]; |
||
139 | } |
||
140 | if (pAngle_in_degrees > 180) { |
||
141 | return -gFloat_sine_table[270 - pAngle_in_degrees]; |
||
142 | } |
||
143 | if (pAngle_in_degrees <= 90) { |
||
144 | return gFloat_sine_table[90 - pAngle_in_degrees]; |
||
145 | } |
||
146 | return -gFloat_sine_table[pAngle_in_degrees - 90]; |
||
147 | } |
||
148 | |||
149 | // IDA: float __usercall FastFloatTan@<ST0>(int pAngle_in_degrees@<EAX>) |
||
150 | float FastFloatTan(int pAngle_in_degrees) { |
||
151 | LOG_TRACE("(%d)", pAngle_in_degrees); |
||
152 | |||
153 | return FastFloatSin(pAngle_in_degrees) / FastFloatCos(pAngle_in_degrees); |
||
154 | } |
||
155 | |||
156 | // IDA: br_scalar __usercall FastScalarSin@<ST0>(int pAngle_in_degrees@<EAX>) |
||
157 | br_scalar FastScalarSin(int pAngle_in_degrees) { |
||
158 | LOG_TRACE("(%d)", pAngle_in_degrees); |
||
159 | |||
160 | return FastFloatSin(pAngle_in_degrees); |
||
161 | } |
||
162 | |||
163 | // IDA: br_scalar __usercall FastScalarCos@<ST0>(int pAngle_in_degrees@<EAX>) |
||
164 | br_scalar FastScalarCos(int pAngle_in_degrees) { |
||
165 | LOG_TRACE("(%d)", pAngle_in_degrees); |
||
166 | |||
167 | return FastFloatCos(pAngle_in_degrees); |
||
168 | } |
||
169 | |||
170 | // IDA: br_scalar __usercall FastScalarTan@<ST0>(int pAngle_in_degrees@<EAX>) |
||
171 | br_scalar FastScalarTan(int pAngle_in_degrees) { |
||
172 | LOG_TRACE("(%d)", pAngle_in_degrees); |
||
173 | |||
174 | return FastScalarSin(pAngle_in_degrees) / FastScalarCos(pAngle_in_degrees); |
||
175 | } |
||
176 | |||
177 | // IDA: br_scalar __usercall FastScalarSinAngle@<ST0>(br_angle pBR_angle@<EAX>) |
||
178 | br_scalar FastScalarSinAngle(br_angle pBR_angle) { |
||
179 | LOG_TRACE("(%d)", pBR_angle); |
||
180 | |||
20 | pmbaty | 181 | return FastScalarSin(BrAngleToDegrees(pBR_angle)); |
1 | pmbaty | 182 | } |
183 | |||
184 | // IDA: br_scalar __usercall FastScalarCosAngle@<ST0>(br_angle pBR_angle@<EAX>) |
||
185 | br_scalar FastScalarCosAngle(br_angle pBR_angle) { |
||
186 | LOG_TRACE("(%d)", pBR_angle); |
||
187 | |||
20 | pmbaty | 188 | return FastScalarCos(BrAngleToDegrees(pBR_angle)); |
1 | pmbaty | 189 | } |
190 | |||
191 | // IDA: br_scalar __usercall FastScalarTanAngle@<ST0>(br_angle pBR_angle@<EAX>) |
||
192 | br_scalar FastScalarTanAngle(br_angle pBR_angle) { |
||
193 | int angle_in_degrees; |
||
194 | LOG_TRACE("(%d)", pBR_angle); |
||
195 | |||
20 | pmbaty | 196 | angle_in_degrees = BrAngleToDegrees(pBR_angle); |
1 | pmbaty | 197 | return FastScalarSin(angle_in_degrees) / FastScalarCos(angle_in_degrees); |
198 | } |
||
199 | |||
200 | // IDA: float __cdecl FastFloatArcSin(float pValue) |
||
201 | float FastFloatArcSin(float pValue) { |
||
202 | float low_limit; |
||
203 | float high_limit; |
||
204 | float mid_point; |
||
205 | LOG_TRACE("(%f)", pValue); |
||
20 | pmbaty | 206 | |
1 | pmbaty | 207 | if (pValue < 0.f) { |
208 | return -FastFloatArcSin(-pValue); |
||
209 | } |
||
210 | high_limit = 90.f * pValue; |
||
211 | low_limit = high_limit - 19.f; |
||
212 | if (low_limit < 0.f) { |
||
213 | low_limit = 0.f; |
||
214 | } |
||
215 | while (high_limit - low_limit >= 1.f) { |
||
216 | mid_point = (low_limit + high_limit) / 2.f; |
||
217 | |||
218 | if (gFloat_sine_table[(int)mid_point] > pValue) { |
||
219 | high_limit = mid_point; |
||
220 | } else { |
||
221 | low_limit = mid_point; |
||
222 | } |
||
223 | } |
||
224 | return low_limit; |
||
225 | } |
||
226 | |||
227 | // IDA: float __cdecl FastFloatArcCos(float pValue) |
||
228 | float FastFloatArcCos(float pValue) { |
||
229 | LOG_TRACE("(%f)", pValue); |
||
230 | |||
231 | return 90.f - FastFloatArcSin(pValue); |
||
232 | } |
||
233 | |||
234 | // IDA: br_scalar __cdecl FastScalarArcSin(br_scalar pValue) |
||
235 | br_scalar FastScalarArcSin(br_scalar pValue) { |
||
236 | LOG_TRACE("(%f)", pValue); |
||
237 | |||
238 | return FastFloatArcSin(pValue); |
||
239 | } |
||
240 | |||
241 | // IDA: br_scalar __cdecl FastScalarArcCos(br_scalar pValue) |
||
242 | br_scalar FastScalarArcCos(br_scalar pValue) { |
||
243 | LOG_TRACE("(%f)", pValue); |
||
244 | |||
245 | return 90.f - FastScalarArcSin(pValue); |
||
246 | } |
||
247 | |||
248 | // IDA: float __cdecl FastFloatArcTan2(float pY, float pX) |
||
249 | float FastFloatArcTan2(float pY, float pX) { |
||
250 | float abs_x; |
||
251 | float abs_y; |
||
252 | LOG_TRACE("(%f, %f)", pY, pX); |
||
253 | |||
254 | abs_x = fabsf(pX); |
||
255 | abs_y = fabsf(pY); |
||
256 | if (pX == 0.0f) { |
||
257 | if (pY < 0.0f) { |
||
258 | return 270.0; |
||
259 | } else if (pY == 0.0f) { |
||
260 | return 0.0f; |
||
261 | } else { |
||
262 | return 90.0f; |
||
263 | } |
||
264 | } else if (pX > 0.0f) { |
||
265 | if (pY >= 0.0) { |
||
266 | if (abs_y <= abs_x) { |
||
267 | return abs_y / abs_x * 45.0f; |
||
268 | } else { |
||
269 | return (2.0f - abs_x / abs_y) * 45.0f; |
||
270 | } |
||
271 | } else { |
||
272 | if (abs_y <= abs_x) { |
||
273 | return (8.0f - abs_y / abs_x) * 45.0f; |
||
274 | } else { |
||
275 | return (abs_x / abs_y + 6.0f) * 45.0f; |
||
276 | } |
||
277 | } |
||
278 | } else { |
||
279 | if (pY >= 0.0f) { |
||
280 | if (abs_y <= abs_x) { |
||
281 | return (4.0f - abs_y / abs_x) * 45.0f; |
||
282 | } else { |
||
283 | return (abs_x / abs_y + 2.0f) * 45.0f; |
||
284 | } |
||
285 | } else { |
||
286 | if (abs_y <= abs_x) { |
||
287 | return (abs_y / abs_x + 4.0f) * 45.0f; |
||
288 | } else { |
||
289 | return (6.0f - abs_x / abs_y) * 45.0f; |
||
290 | } |
||
291 | } |
||
292 | } |
||
293 | } |
||
294 | |||
295 | // IDA: br_scalar __cdecl FastScalarArcTan2(br_scalar pY, br_scalar pX) |
||
296 | br_scalar FastScalarArcTan2(br_scalar pY, br_scalar pX) { |
||
297 | //br_scalar abs_x; // Pierre-Marie Baty -- unused variable |
||
298 | //br_scalar abs_y; // Pierre-Marie Baty -- unused variable |
||
299 | LOG_TRACE("(%f, %f)", pY, pX); |
||
300 | |||
301 | return FastFloatArcTan2(pY, pX); |
||
302 | } |
||
303 | |||
304 | // IDA: br_angle __cdecl FastFloatArcTan2Angle(float pY, float pX) |
||
305 | br_angle FastFloatArcTan2Angle(float pY, float pX) { |
||
306 | float abs_x; |
||
307 | float abs_y; |
||
308 | LOG_TRACE("(%f, %f)", pY, pX); |
||
309 | |||
310 | abs_x = fabsf(pX); |
||
311 | abs_y = fabsf(pY); |
||
312 | if (pX == 0.0) { |
||
313 | if (pY >= 0.0) { |
||
314 | if (pY <= 0.0) { |
||
315 | return 0; |
||
316 | } else { |
||
317 | return 16380; |
||
318 | } |
||
319 | } else { |
||
320 | return -16396; |
||
321 | } |
||
322 | } else if (pX >= 0.0) { |
||
323 | if (pY >= 0.0) { |
||
324 | if (abs_y <= (double)abs_x) { |
||
325 | return (abs_y / abs_x * 8192.0); |
||
326 | } else { |
||
327 | return ((2.0 - abs_x / abs_y) * 8192.0f); |
||
328 | } |
||
329 | } else if (abs_y <= abs_x) { |
||
330 | return ((8.0 - abs_y / abs_x) * 8192.0f); |
||
331 | } else { |
||
332 | return ((abs_x / abs_y + 6.0) * 8192.0f); |
||
333 | } |
||
334 | } else if (pY >= 0.0) { |
||
335 | if (abs_y <= abs_x) { |
||
336 | return ((4.0 - abs_y / abs_x) * 8192.0f); |
||
337 | } else { |
||
338 | return ((abs_x / abs_y + 2.0) * 8192.0f); |
||
339 | } |
||
340 | } else if (abs_y <= abs_x) { |
||
341 | return ((abs_y / abs_x + 4.0) * 8192.0f); |
||
342 | } else { |
||
343 | return ((6.0 - abs_x / abs_y) * 8192.0f); |
||
344 | } |
||
345 | } |
||
346 | |||
347 | // IDA: br_angle __cdecl FastScalarArcTan2Angle(br_scalar pY, br_scalar pX) |
||
348 | br_angle FastScalarArcTan2Angle(br_scalar pY, br_scalar pX) { |
||
349 | //br_scalar abs_x; // Pierre-Marie Baty -- unused variable |
||
350 | //br_scalar abs_y; // Pierre-Marie Baty -- unused variable |
||
351 | LOG_TRACE("(%f, %f)", pY, pX); |
||
352 | |||
353 | return FastFloatArcTan2Angle(pY, pX); |
||
354 | } |
||
355 | |||
356 | // IDA: void __usercall DRMatrix34RotateX(br_matrix34 *mat@<EAX>, br_angle rx@<EDX>) |
||
357 | void DRMatrix34RotateX(br_matrix34* mat, br_angle rx) { |
||
358 | br_scalar s; |
||
359 | br_scalar c; |
||
360 | LOG_TRACE("(%p, %d)", mat, rx); |
||
361 | |||
362 | s = FastScalarSinAngle(rx); |
||
363 | c = FastScalarCosAngle(rx); |
||
364 | mat->m[0][0] = 1.0; |
||
365 | mat->m[0][1] = 0.0; |
||
366 | mat->m[0][2] = 0.0; |
||
367 | mat->m[1][0] = 0.0; |
||
368 | mat->m[1][1] = c; |
||
369 | mat->m[1][2] = s; |
||
370 | mat->m[2][0] = 0.0; |
||
371 | mat->m[2][1] = -s; |
||
372 | mat->m[2][2] = c; |
||
373 | mat->m[3][0] = 0.0; |
||
374 | mat->m[3][1] = 0.0; |
||
375 | mat->m[3][2] = 0.0; |
||
376 | } |
||
377 | |||
378 | // IDA: void __usercall DRMatrix34RotateY(br_matrix34 *mat@<EAX>, br_angle ry@<EDX>) |
||
379 | void DRMatrix34RotateY(br_matrix34* mat, br_angle ry) { |
||
380 | br_scalar s; |
||
381 | br_scalar c; |
||
382 | LOG_TRACE8("(%p, %d)", mat, ry); |
||
383 | |||
384 | s = FastScalarSinAngle(ry); |
||
385 | c = FastScalarCosAngle(ry); |
||
386 | mat->m[0][0] = c; |
||
387 | mat->m[0][1] = 0.0; |
||
388 | mat->m[0][2] = -s; |
||
389 | mat->m[1][0] = 0.0; |
||
390 | mat->m[1][1] = 1.0; |
||
391 | mat->m[1][2] = 0.0; |
||
392 | mat->m[2][0] = s; |
||
393 | mat->m[2][1] = 0.0; |
||
394 | mat->m[2][2] = c; |
||
395 | mat->m[3][0] = 0.0; |
||
396 | mat->m[3][1] = 0.0; |
||
397 | mat->m[3][2] = 0.0; |
||
398 | } |
||
399 | |||
400 | // IDA: void __usercall DRMatrix34RotateZ(br_matrix34 *mat@<EAX>, br_angle rz@<EDX>) |
||
401 | void DRMatrix34RotateZ(br_matrix34* mat, br_angle rz) { |
||
402 | br_scalar s; |
||
403 | br_scalar c; |
||
404 | LOG_TRACE8("(%p, %d)", mat, rz); |
||
405 | |||
406 | s = FastScalarSinAngle(rz); |
||
407 | c = FastScalarCosAngle(rz); |
||
408 | mat->m[0][0] = c; |
||
409 | mat->m[0][1] = s; |
||
410 | mat->m[0][2] = 0.0; |
||
411 | mat->m[1][0] = -s; |
||
412 | mat->m[1][1] = c; |
||
413 | mat->m[1][2] = 0.0; |
||
414 | mat->m[2][0] = 0.0; |
||
415 | mat->m[2][1] = 0.0; |
||
416 | mat->m[2][2] = 1.0; |
||
417 | mat->m[3][0] = 0.0; |
||
418 | mat->m[3][1] = 0.0; |
||
419 | mat->m[3][2] = 0.0; |
||
420 | } |
||
421 | |||
422 | // IDA: void __usercall DRMatrix34Rotate(br_matrix34 *mat@<EAX>, br_angle r@<EDX>, br_vector3 *a@<EBX>) |
||
423 | void DRMatrix34Rotate(br_matrix34* mat, br_angle r, br_vector3* a) { |
||
424 | br_scalar t; |
||
425 | br_scalar s; |
||
426 | br_scalar c; |
||
427 | br_scalar txy; |
||
428 | br_scalar txz; |
||
429 | br_scalar tyz; |
||
430 | br_scalar sx; |
||
431 | br_scalar sy; |
||
432 | br_scalar sz; |
||
433 | LOG_TRACE("(%p, %d, %p)", mat, r, a); |
||
434 | |||
435 | s = FastScalarSinAngle(r); |
||
436 | c = FastScalarCosAngle(r); |
||
437 | t = 1.f - c; |
||
438 | txy = t * a->v[0] * a->v[1]; |
||
439 | txz = t * a->v[0] * a->v[2]; |
||
440 | tyz = t * a->v[1] * a->v[2]; |
||
441 | sx = s * a->v[0]; |
||
442 | sy = s * a->v[1]; |
||
443 | sz = s * a->v[2]; |
||
444 | |||
445 | mat->m[0][0] = a->v[0] * a->v[0] * t + c; |
||
446 | mat->m[0][1] = sx + txy; |
||
447 | mat->m[0][2] = txz - sy; |
||
448 | mat->m[1][0] = txy - sz; |
||
449 | mat->m[1][1] = a->v[1] * a->v[1] * t + c; |
||
450 | mat->m[1][2] = sx + tyz; |
||
451 | mat->m[2][0] = sy + txz; |
||
452 | mat->m[2][1] = tyz - sx; |
||
453 | mat->m[2][2] = a->v[2] * a->v[2] * t + c; |
||
454 | mat->m[3][2] = 0.f; |
||
455 | mat->m[3][1] = 0.f; |
||
456 | mat->m[3][0] = 0.f; |
||
457 | } |
||
458 | |||
459 | // IDA: void __usercall DRMatrix34PreRotateX(br_matrix34 *mat@<EAX>, br_angle rx@<EDX>) |
||
460 | void DRMatrix34PreRotateX(br_matrix34* mat, br_angle rx) { |
||
461 | LOG_TRACE("(%p, %d)", mat, rx); |
||
462 | |||
463 | DRMatrix34RotateX(&mattmp2__trig, rx); |
||
464 | BrMatrix34Mul(&mattmp1__trig, &mattmp2__trig, mat); |
||
465 | BrMatrix34Copy(mat, &mattmp1__trig); |
||
466 | } |
||
467 | |||
468 | // IDA: void __usercall DRMatrix34PostRotateX(br_matrix34 *mat@<EAX>, br_angle rx@<EDX>) |
||
469 | void DRMatrix34PostRotateX(br_matrix34* mat, br_angle rx) { |
||
470 | LOG_TRACE("(%p, %d)", mat, rx); |
||
471 | |||
472 | DRMatrix34RotateX(&mattmp2__trig, rx); |
||
473 | BrMatrix34Mul(&mattmp1__trig, mat, &mattmp2__trig); |
||
474 | BrMatrix34Copy(mat, &mattmp1__trig); |
||
475 | } |
||
476 | |||
477 | // IDA: void __usercall DRMatrix34PreRotateY(br_matrix34 *mat@<EAX>, br_angle ry@<EDX>) |
||
478 | void DRMatrix34PreRotateY(br_matrix34* mat, br_angle ry) { |
||
479 | LOG_TRACE("(%p, %d)", mat, ry); |
||
480 | |||
481 | DRMatrix34RotateY(&mattmp2__trig, ry); |
||
482 | BrMatrix34Mul(&mattmp1__trig, &mattmp2__trig, mat); |
||
483 | BrMatrix34Copy(mat, &mattmp1__trig); |
||
484 | } |
||
485 | |||
486 | // IDA: void __usercall DRMatrix34PostRotateY(br_matrix34 *mat@<EAX>, br_angle ry@<EDX>) |
||
487 | void DRMatrix34PostRotateY(br_matrix34* mat, br_angle ry) { |
||
488 | LOG_TRACE("(%p, %d)", mat, ry); |
||
489 | |||
490 | DRMatrix34RotateY(&mattmp2__trig, ry); |
||
491 | BrMatrix34Mul(&mattmp1__trig, mat, &mattmp2__trig); |
||
492 | BrMatrix34Copy(mat, &mattmp1__trig); |
||
493 | } |
||
494 | |||
495 | // IDA: void __usercall DRMatrix34PreRotateZ(br_matrix34 *mat@<EAX>, br_angle rz@<EDX>) |
||
496 | void DRMatrix34PreRotateZ(br_matrix34* mat, br_angle rz) { |
||
497 | LOG_TRACE("(%p, %d)", mat, rz); |
||
498 | |||
499 | DRMatrix34RotateZ(&mattmp2__trig, rz); |
||
500 | BrMatrix34Mul(&mattmp1__trig, &mattmp2__trig, mat); |
||
501 | BrMatrix34Copy(mat, &mattmp1__trig); |
||
502 | } |
||
503 | |||
504 | // IDA: void __usercall DRMatrix34PostRotateZ(br_matrix34 *mat@<EAX>, br_angle rz@<EDX>) |
||
505 | void DRMatrix34PostRotateZ(br_matrix34* mat, br_angle rz) { |
||
506 | LOG_TRACE("(%p, %d)", mat, rz); |
||
507 | |||
508 | DRMatrix34RotateZ(&mattmp2__trig, rz); |
||
509 | BrMatrix34Mul(&mattmp1__trig, mat, &mattmp2__trig); |
||
510 | BrMatrix34Copy(mat, &mattmp1__trig); |
||
511 | } |
||
512 | |||
513 | // IDA: void __usercall DRMatrix34PreRotate(br_matrix34 *mat@<EAX>, br_angle r@<EDX>, br_vector3 *axis@<EBX>) |
||
514 | void DRMatrix34PreRotate(br_matrix34* mat, br_angle r, br_vector3* axis) { |
||
515 | LOG_TRACE("(%p, %d, %p)", mat, r, axis); |
||
516 | |||
517 | DRMatrix34Rotate(&mattmp2__trig, r, axis); |
||
518 | BrMatrix34Mul(&mattmp1__trig, &mattmp2__trig, mat); |
||
519 | BrMatrix34Copy(mat, &mattmp1__trig); |
||
520 | } |
||
521 | |||
522 | // IDA: void __usercall DRMatrix34PostRotate(br_matrix34 *mat@<EAX>, br_angle r@<EDX>, br_vector3 *axis@<EBX>) |
||
523 | void DRMatrix34PostRotate(br_matrix34* mat, br_angle r, br_vector3* axis) { |
||
524 | LOG_TRACE("(%p, %d, %p)", mat, r, axis); |
||
525 | |||
526 | DRMatrix34Rotate(&mattmp2__trig, r, axis); |
||
527 | BrMatrix34Mul(&mattmp1__trig, mat, &mattmp2__trig); |
||
528 | BrMatrix34Copy(mat, &mattmp1__trig); |
||
529 | } |
||
530 | |||
531 | // IDA: void __usercall DRMatrix23Rotate(br_matrix23 *mat@<EAX>, br_angle rz@<EDX>) |
||
532 | void DRMatrix23Rotate(br_matrix23* mat, br_angle rz) { |
||
533 | br_scalar s; |
||
534 | br_scalar c; |
||
535 | LOG_TRACE("(%p, %d)", mat, rz); |
||
536 | |||
537 | s = FastScalarSinAngle(rz); |
||
538 | c = FastScalarCosAngle(rz); |
||
539 | |||
540 | mat->m[0][0] = c; |
||
541 | mat->m[0][1] = s; |
||
542 | mat->m[1][0] = -s; |
||
543 | mat->m[1][1] = c; |
||
544 | mat->m[2][0] = 0.f; |
||
545 | mat->m[2][1] = 0.f; |
||
546 | } |
||
547 | |||
548 | // IDA: void __usercall DRMatrix23PreRotate(br_matrix23 *mat@<EAX>, br_angle rz@<EDX>) |
||
549 | void DRMatrix23PreRotate(br_matrix23* mat, br_angle rz) { |
||
550 | LOG_TRACE("(%p, %d)", mat, rz); |
||
551 | |||
552 | DRMatrix23Rotate(&mat23tmp2, rz); |
||
553 | BrMatrix23Mul(&mat23tmp1, &mat23tmp2, mat); |
||
554 | BrMatrix23Copy(mat, &mat23tmp1); |
||
555 | } |
||
556 | |||
557 | // IDA: void __usercall DRMatrix23PostRotate(br_matrix23 *mat@<EAX>, br_angle rz@<EDX>) |
||
558 | void DRMatrix23PostRotate(br_matrix23* mat, br_angle rz) { |
||
559 | LOG_TRACE("(%p, %d)", mat, rz); |
||
560 | |||
561 | DRMatrix23Rotate(&mat23tmp2, rz); |
||
562 | BrMatrix23Mul(&mat23tmp1, mat, &mat23tmp2); |
||
563 | BrMatrix23Copy(mat, &mat23tmp1); |
||
564 | } |