annotate VectorTypes.cpp @ 1951:524fe0810f32

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