1513
|
1 #include <utility>
|
|
2
|
1504
|
3 #include "mm7_data.h"
|
1528
|
4 #include "Math.h"
|
1504
|
5
|
1513
|
6 //----- (004621DA) --------------------------------------------------------
|
|
7 uint32_t int_get_vector_length(int32_t x, int32_t y, int32_t z)
|
|
8 {
|
|
9 if (x < y)
|
|
10 {
|
|
11 std::swap(x, y);
|
|
12 }
|
|
13 if (x < z)
|
|
14 {
|
|
15 std::swap(x, z);
|
|
16 }
|
|
17 if (y < z)
|
|
18 {
|
|
19 std::swap(y, z);
|
|
20 }
|
|
21
|
|
22 return x + (11 * y >> 5) + (z >> 2);
|
|
23 }
|
|
24
|
1504
|
25 //----- (0044C362) --------------------------------------------------------
|
1513
|
26 template <class T>
|
|
27 void Vec3<T>::Normalize_float()
|
1504
|
28 {
|
1528
|
29 double x = this->x;
|
|
30 double y = this->y;
|
|
31 double z = this->z;
|
|
32 double s = sqrt(x * x + y * y + z * z);
|
1504
|
33
|
1528
|
34 this->x = bankersRounding(x / s);
|
|
35 this->y = bankersRounding(y / s);
|
|
36 this->z = bankersRounding(z / s);
|
1504
|
37 }
|
|
38
|
|
39 //----- (0043AA99) --------------------------------------------------------
|
1513
|
40 template <class T>
|
|
41 void __fastcall Vec3<T>::Rotate(T sDepth, T sRotY, T sRotX, Vec3<T> v, T *outx, T *outy, T *outz)
|
1504
|
42 {
|
|
43 float cosf_x = cosf(3.14159265f * sRotX / 1024.0f),
|
|
44 sinf_x = sinf(3.14159265f * sRotX / 1024.0f),
|
|
45 cosf_y = cosf(3.14159265f * sRotY / 1024.0f),
|
|
46 sinf_y = sinf(3.14159265f * sRotY / 1024.0f);
|
|
47
|
|
48 *outx = v.x + ((unsigned __int64)(sinf_y * (signed __int64)((unsigned __int64)(cosf_x * (signed __int64)sDepth)>> 16)));
|
|
49 *outy = v.y + ((unsigned __int64)(cosf_y * (signed __int64)((unsigned __int64)(cosf_x * (signed __int64)sDepth)>> 16)));
|
|
50 *outz = v.z + ((unsigned __int64)(sinf_x * (signed __int64)sDepth) >> 16);
|
|
51 }
|
|
52
|
|
53 //----- (0043AB61) --------------------------------------------------------
|
1513
|
54 template <class T>
|
|
55 void Vec3<T>::Normalize(T *x, T *y, T *z)
|
1504
|
56 {
|
|
57 *x *= 65536 / (integer_sqrt(*y * *y + *z * *z + *x * *x) | 1);
|
|
58 *y *= 65536 / (integer_sqrt(*y * *y + *z * *z + *x * *x) | 1);
|
|
59 *z *= 65536 / (integer_sqrt(*y * *y + *z * *z + *x * *x) | 1);
|
|
60 }
|
1513
|
61
|
|
62 template Vec3<int32_t>;
|