Mercurial > mm7
annotate VectorTypes.cpp @ 2159:67a83bc1a7de
uDefaultPartyHeight = 192
author | Ritor1 |
---|---|
date | Mon, 13 Jan 2014 14:31:25 +0600 |
parents | d44b7775fc06 |
children | aff7a7b072b7 |
rev | line source |
---|---|
1513 | 1 #include <utility> |
2 | |
1504 | 3 #include "mm7_data.h" |
2037
7a9477135943
Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
1528
diff
changeset
|
4 #include "OurMath.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 { |
2152 | 57 extern int integer_sqrt(int val); |
1504 | 58 *x *= 65536 / (integer_sqrt(*y * *y + *z * *z + *x * *x) | 1); |
59 *y *= 65536 / (integer_sqrt(*y * *y + *z * *z + *x * *x) | 1); | |
60 *z *= 65536 / (integer_sqrt(*y * *y + *z * *z + *x * *x) | 1); | |
61 } | |
1513 | 62 |
63 template Vec3<int32_t>; |