annotate VectorTypes.cpp @ 1504:ff1867836af5

Cleanup of VectorTypes.
author yoctozepto
date Mon, 02 Sep 2013 12:46:32 +0200
parents
children 4055b09160ae
rev   line source
1504
ff1867836af5 Cleanup of VectorTypes.
yoctozepto
parents:
diff changeset
1 #include "mm7_data.h"
ff1867836af5 Cleanup of VectorTypes.
yoctozepto
parents:
diff changeset
2
ff1867836af5 Cleanup of VectorTypes.
yoctozepto
parents:
diff changeset
3 //----- (0044C362) --------------------------------------------------------
ff1867836af5 Cleanup of VectorTypes.
yoctozepto
parents:
diff changeset
4 void Vec3_int_::Normalize_float()
ff1867836af5 Cleanup of VectorTypes.
yoctozepto
parents:
diff changeset
5 {
ff1867836af5 Cleanup of VectorTypes.
yoctozepto
parents:
diff changeset
6 //Vec3_int_ *v1; // esi@1
ff1867836af5 Cleanup of VectorTypes.
yoctozepto
parents:
diff changeset
7 double v2; // st6@1
ff1867836af5 Cleanup of VectorTypes.
yoctozepto
parents:
diff changeset
8 float v3; // ST20_4@1
ff1867836af5 Cleanup of VectorTypes.
yoctozepto
parents:
diff changeset
9 double v4; // st5@1
ff1867836af5 Cleanup of VectorTypes.
yoctozepto
parents:
diff changeset
10 float v5; // ST18_4@1
ff1867836af5 Cleanup of VectorTypes.
yoctozepto
parents:
diff changeset
11 double v6; // st4@1
ff1867836af5 Cleanup of VectorTypes.
yoctozepto
parents:
diff changeset
12 float v7; // ST14_4@1
ff1867836af5 Cleanup of VectorTypes.
yoctozepto
parents:
diff changeset
13 float v8; // ST24_4@1
ff1867836af5 Cleanup of VectorTypes.
yoctozepto
parents:
diff changeset
14 float v9; // ST20_4@1
ff1867836af5 Cleanup of VectorTypes.
yoctozepto
parents:
diff changeset
15 double v10; // ST0C_8@1
ff1867836af5 Cleanup of VectorTypes.
yoctozepto
parents:
diff changeset
16 float v11; // ST18_4@1
ff1867836af5 Cleanup of VectorTypes.
yoctozepto
parents:
diff changeset
17 double v12; // ST0C_8@1
ff1867836af5 Cleanup of VectorTypes.
yoctozepto
parents:
diff changeset
18 float v13; // ST14_4@1
ff1867836af5 Cleanup of VectorTypes.
yoctozepto
parents:
diff changeset
19 double v14; // ST0C_8@1
ff1867836af5 Cleanup of VectorTypes.
yoctozepto
parents:
diff changeset
20
ff1867836af5 Cleanup of VectorTypes.
yoctozepto
parents:
diff changeset
21 assert(false);
ff1867836af5 Cleanup of VectorTypes.
yoctozepto
parents:
diff changeset
22 //v1 = this;
ff1867836af5 Cleanup of VectorTypes.
yoctozepto
parents:
diff changeset
23 v2 = (double)this->x * 0.000015258789;
ff1867836af5 Cleanup of VectorTypes.
yoctozepto
parents:
diff changeset
24 v3 = v2;
ff1867836af5 Cleanup of VectorTypes.
yoctozepto
parents:
diff changeset
25 v4 = (double)this->y * 0.000015258789;
ff1867836af5 Cleanup of VectorTypes.
yoctozepto
parents:
diff changeset
26 v5 = v4;
ff1867836af5 Cleanup of VectorTypes.
yoctozepto
parents:
diff changeset
27 v6 = (double)this->z * 0.000015258789;
ff1867836af5 Cleanup of VectorTypes.
yoctozepto
parents:
diff changeset
28 v7 = v6;
ff1867836af5 Cleanup of VectorTypes.
yoctozepto
parents:
diff changeset
29 v8 = 1.0 / sqrt(v6 * v6 + v4 * v4 + v2 * v2);
ff1867836af5 Cleanup of VectorTypes.
yoctozepto
parents:
diff changeset
30 v9 = v8 * v3 * 65536.0;
ff1867836af5 Cleanup of VectorTypes.
yoctozepto
parents:
diff changeset
31 v10 = v9 + 6.7553994e15;
ff1867836af5 Cleanup of VectorTypes.
yoctozepto
parents:
diff changeset
32 this->x = LODWORD(v10);
ff1867836af5 Cleanup of VectorTypes.
yoctozepto
parents:
diff changeset
33 v11 = v8 * v5 * 65536.0;
ff1867836af5 Cleanup of VectorTypes.
yoctozepto
parents:
diff changeset
34 v12 = v11 + 6.7553994e15;
ff1867836af5 Cleanup of VectorTypes.
yoctozepto
parents:
diff changeset
35 this->y = LODWORD(v12);
ff1867836af5 Cleanup of VectorTypes.
yoctozepto
parents:
diff changeset
36 v13 = v8 * v7 * 65536.0;
ff1867836af5 Cleanup of VectorTypes.
yoctozepto
parents:
diff changeset
37 v14 = v13 + 6.7553994e15;
ff1867836af5 Cleanup of VectorTypes.
yoctozepto
parents:
diff changeset
38 this->z = LODWORD(v14);
ff1867836af5 Cleanup of VectorTypes.
yoctozepto
parents:
diff changeset
39 }
ff1867836af5 Cleanup of VectorTypes.
yoctozepto
parents:
diff changeset
40
ff1867836af5 Cleanup of VectorTypes.
yoctozepto
parents:
diff changeset
41 //----- (0043AA99) --------------------------------------------------------
ff1867836af5 Cleanup of VectorTypes.
yoctozepto
parents:
diff changeset
42 void __fastcall Vec3_int_::Rotate(int sDepth, int sRotY, int sRotX, Vec3_int_ v, int *outx, int *outy, int *outz)
ff1867836af5 Cleanup of VectorTypes.
yoctozepto
parents:
diff changeset
43 {
ff1867836af5 Cleanup of VectorTypes.
yoctozepto
parents:
diff changeset
44 float cosf_x = cosf(3.14159265f * sRotX / 1024.0f),
ff1867836af5 Cleanup of VectorTypes.
yoctozepto
parents:
diff changeset
45 sinf_x = sinf(3.14159265f * sRotX / 1024.0f),
ff1867836af5 Cleanup of VectorTypes.
yoctozepto
parents:
diff changeset
46 cosf_y = cosf(3.14159265f * sRotY / 1024.0f),
ff1867836af5 Cleanup of VectorTypes.
yoctozepto
parents:
diff changeset
47 sinf_y = sinf(3.14159265f * sRotY / 1024.0f);
ff1867836af5 Cleanup of VectorTypes.
yoctozepto
parents:
diff changeset
48
ff1867836af5 Cleanup of VectorTypes.
yoctozepto
parents:
diff changeset
49 *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
50 *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
51 *outz = v.z + ((unsigned __int64)(sinf_x * (signed __int64)sDepth) >> 16);
ff1867836af5 Cleanup of VectorTypes.
yoctozepto
parents:
diff changeset
52 }
ff1867836af5 Cleanup of VectorTypes.
yoctozepto
parents:
diff changeset
53
ff1867836af5 Cleanup of VectorTypes.
yoctozepto
parents:
diff changeset
54 //----- (0043AB61) --------------------------------------------------------
ff1867836af5 Cleanup of VectorTypes.
yoctozepto
parents:
diff changeset
55 void Vec3_int_::Normalize(int *x, int *y, int *z)
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 }