Mercurial > mm7
annotate VectorTypes.cpp @ 2432:99e7bd7ec0a2
* Fixed OpenAL crash for videos
* Fixed double release of movie for Emerald Intro
author | a.parshin |
---|---|
date | Wed, 23 Jul 2014 21:38:34 +0300 |
parents | f4af3b203f65 |
children | 104fdbea0386 |
rev | line source |
---|---|
2415 | 1 #define _CRTDBG_MAP_ALLOC |
2 #include <stdlib.h> | |
3 #include <crtdbg.h> | |
4 | |
2253
aff7a7b072b7
adding _CRT_SECURE_NO_WARNINGS to get rid of a few hundrer annoying warnings + adding count parameter to swprintf
Grumpy7
parents:
2152
diff
changeset
|
5 #define _CRT_SECURE_NO_WARNINGS |
1513 | 6 #include <utility> |
7 | |
1504 | 8 #include "mm7_data.h" |
2037
7a9477135943
Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
1528
diff
changeset
|
9 #include "OurMath.h" |
1504 | 10 |
1513 | 11 //----- (004621DA) -------------------------------------------------------- |
12 uint32_t int_get_vector_length(int32_t x, int32_t y, int32_t z) | |
13 { | |
14 if (x < y) | |
15 { | |
16 std::swap(x, y); | |
17 } | |
18 if (x < z) | |
19 { | |
20 std::swap(x, z); | |
21 } | |
22 if (y < z) | |
23 { | |
24 std::swap(y, z); | |
25 } | |
26 | |
27 return x + (11 * y >> 5) + (z >> 2); | |
28 } | |
29 | |
1504 | 30 //----- (0044C362) -------------------------------------------------------- |
1513 | 31 template <class T> |
32 void Vec3<T>::Normalize_float() | |
1504 | 33 { |
1528 | 34 double x = this->x; |
35 double y = this->y; | |
36 double z = this->z; | |
37 double s = sqrt(x * x + y * y + z * z); | |
1504 | 38 |
1528 | 39 this->x = bankersRounding(x / s); |
40 this->y = bankersRounding(y / s); | |
41 this->z = bankersRounding(z / s); | |
1504 | 42 } |
43 | |
44 //----- (0043AA99) -------------------------------------------------------- | |
1513 | 45 template <class T> |
46 void __fastcall Vec3<T>::Rotate(T sDepth, T sRotY, T sRotX, Vec3<T> v, T *outx, T *outy, T *outz) | |
1504 | 47 { |
48 float cosf_x = cosf(3.14159265f * sRotX / 1024.0f), | |
49 sinf_x = sinf(3.14159265f * sRotX / 1024.0f), | |
50 cosf_y = cosf(3.14159265f * sRotY / 1024.0f), | |
51 sinf_y = sinf(3.14159265f * sRotY / 1024.0f); | |
52 | |
53 *outx = v.x + ((unsigned __int64)(sinf_y * (signed __int64)((unsigned __int64)(cosf_x * (signed __int64)sDepth)>> 16))); | |
54 *outy = v.y + ((unsigned __int64)(cosf_y * (signed __int64)((unsigned __int64)(cosf_x * (signed __int64)sDepth)>> 16))); | |
55 *outz = v.z + ((unsigned __int64)(sinf_x * (signed __int64)sDepth) >> 16); | |
56 } | |
57 | |
58 //----- (0043AB61) -------------------------------------------------------- | |
1513 | 59 template <class T> |
60 void Vec3<T>::Normalize(T *x, T *y, T *z) | |
1504 | 61 { |
2152 | 62 extern int integer_sqrt(int val); |
1504 | 63 *x *= 65536 / (integer_sqrt(*y * *y + *z * *z + *x * *x) | 1); |
64 *y *= 65536 / (integer_sqrt(*y * *y + *z * *z + *x * *x) | 1); | |
65 *z *= 65536 / (integer_sqrt(*y * *y + *z * *z + *x * *x) | 1); | |
66 } | |
1513 | 67 |
68 template Vec3<int32_t>; |