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