Mercurial > mm7
changeset 1504:ff1867836af5
Cleanup of VectorTypes.
author | yoctozepto |
---|---|
date | Mon, 02 Sep 2013 12:46:32 +0200 |
parents | 4ce525fe9ea9 |
children | 4f0fea48e9ee |
files | Spells.h VectorTypes.cpp VectorTypes.h mm7_3.cpp mm7_5.cpp stru367.h |
diffstat | 6 files changed, 63 insertions(+), 61 deletions(-) [+] |
line wrap: on
line diff
--- a/Spells.h Mon Sep 02 08:38:41 2013 +0200 +++ b/Spells.h Mon Sep 02 12:46:32 2013 +0200 @@ -1,5 +1,7 @@ #pragma once +#include <array> + #include "VectorTypes.h" /* 360 */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/VectorTypes.cpp Mon Sep 02 12:46:32 2013 +0200 @@ -0,0 +1,60 @@ +#include "mm7_data.h" + +//----- (0044C362) -------------------------------------------------------- +void Vec3_int_::Normalize_float() +{ + //Vec3_int_ *v1; // esi@1 + double v2; // st6@1 + float v3; // ST20_4@1 + double v4; // st5@1 + float v5; // ST18_4@1 + double v6; // st4@1 + float v7; // ST14_4@1 + float v8; // ST24_4@1 + float v9; // ST20_4@1 + double v10; // ST0C_8@1 + float v11; // ST18_4@1 + double v12; // ST0C_8@1 + float v13; // ST14_4@1 + double v14; // ST0C_8@1 + + assert(false); + //v1 = this; + v2 = (double)this->x * 0.000015258789; + v3 = v2; + v4 = (double)this->y * 0.000015258789; + v5 = v4; + v6 = (double)this->z * 0.000015258789; + v7 = v6; + v8 = 1.0 / sqrt(v6 * v6 + v4 * v4 + v2 * v2); + v9 = v8 * v3 * 65536.0; + v10 = v9 + 6.7553994e15; + this->x = LODWORD(v10); + v11 = v8 * v5 * 65536.0; + v12 = v11 + 6.7553994e15; + this->y = LODWORD(v12); + v13 = v8 * v7 * 65536.0; + v14 = v13 + 6.7553994e15; + this->z = LODWORD(v14); +} + +//----- (0043AA99) -------------------------------------------------------- +void __fastcall Vec3_int_::Rotate(int sDepth, int sRotY, int sRotX, Vec3_int_ v, int *outx, int *outy, int *outz) +{ + float cosf_x = cosf(3.14159265f * sRotX / 1024.0f), + sinf_x = sinf(3.14159265f * sRotX / 1024.0f), + cosf_y = cosf(3.14159265f * sRotY / 1024.0f), + sinf_y = sinf(3.14159265f * sRotY / 1024.0f); + + *outx = v.x + ((unsigned __int64)(sinf_y * (signed __int64)((unsigned __int64)(cosf_x * (signed __int64)sDepth)>> 16))); + *outy = v.y + ((unsigned __int64)(cosf_y * (signed __int64)((unsigned __int64)(cosf_x * (signed __int64)sDepth)>> 16))); + *outz = v.z + ((unsigned __int64)(sinf_x * (signed __int64)sDepth) >> 16); +} + +//----- (0043AB61) -------------------------------------------------------- +void Vec3_int_::Normalize(int *x, int *y, int *z) +{ + *x *= 65536 / (integer_sqrt(*y * *y + *z * *z + *x * *x) | 1); + *y *= 65536 / (integer_sqrt(*y * *y + *z * *z + *x * *x) | 1); + *z *= 65536 / (integer_sqrt(*y * *y + *z * *z + *x * *x) | 1); +}
--- a/VectorTypes.h Mon Sep 02 08:38:41 2013 +0200 +++ b/VectorTypes.h Mon Sep 02 12:46:32 2013 +0200 @@ -1,5 +1,4 @@ #pragma once -#include <array> typedef unsigned __int32 uint;
--- a/mm7_3.cpp Mon Sep 02 08:38:41 2013 +0200 +++ b/mm7_3.cpp Mon Sep 02 12:46:32 2013 +0200 @@ -7760,44 +7760,6 @@ return true; } -//----- (0044C362) -------------------------------------------------------- -void Vec3_int_::Normalize_float() -{ - //Vec3_int_ *v1; // esi@1 - double v2; // st6@1 - float v3; // ST20_4@1 - double v4; // st5@1 - float v5; // ST18_4@1 - double v6; // st4@1 - float v7; // ST14_4@1 - float v8; // ST24_4@1 - float v9; // ST20_4@1 - double v10; // ST0C_8@1 - float v11; // ST18_4@1 - double v12; // ST0C_8@1 - float v13; // ST14_4@1 - double v14; // ST0C_8@1 - - assert(false); - //v1 = this; - v2 = (double)this->x * 0.000015258789; - v3 = v2; - v4 = (double)this->y * 0.000015258789; - v5 = v4; - v6 = (double)this->z * 0.000015258789; - v7 = v6; - v8 = 1.0 / sqrt(v6 * v6 + v4 * v4 + v2 * v2); - v9 = v8 * v3 * 65536.0; - v10 = v9 + 6.7553994e15; - this->x = LODWORD(v10); - v11 = v8 * v5 * 65536.0; - v12 = v11 + 6.7553994e15; - this->y = LODWORD(v12); - v13 = v8 * v7 * 65536.0; - v14 = v13 + 6.7553994e15; - this->z = LODWORD(v14); -} - //----- (00401000) -------------------------------------------------------- void mm7__vector_constructor(void *a1, int objSize, int numObjs, int ( *constructor)(int)) {
--- a/mm7_5.cpp Mon Sep 02 08:38:41 2013 +0200 +++ b/mm7_5.cpp Mon Sep 02 12:46:32 2013 +0200 @@ -3870,27 +3870,6 @@ } } -//----- (0043AA99) -------------------------------------------------------- -void __fastcall Vec3_int_::Rotate(int sDepth, int sRotY, int sRotX, Vec3_int_ v, int *outx, int *outy, int *outz) -{ - float cosf_x = cosf(3.14159265f * sRotX / 1024.0f), - sinf_x = sinf(3.14159265f * sRotX / 1024.0f), - cosf_y = cosf(3.14159265f * sRotY / 1024.0f), - sinf_y = sinf(3.14159265f * sRotY / 1024.0f); - - *outx = v.x + ((unsigned __int64)(sinf_y * (signed __int64)((unsigned __int64)(cosf_x * (signed __int64)sDepth)>> 16))); - *outy = v.y + ((unsigned __int64)(cosf_y * (signed __int64)((unsigned __int64)(cosf_x * (signed __int64)sDepth)>> 16))); - *outz = v.z + ((unsigned __int64)(sinf_x * (signed __int64)sDepth) >> 16); -} - -//----- (0043AB61) -------------------------------------------------------- -void Vec3_int_::Normalize(int *x, int *y, int *z) -{ - *x *= 65536 / (integer_sqrt(*y * *y + *z * *z + *x * *x) | 1); - *y *= 65536 / (integer_sqrt(*y * *y + *z * *z + *x * *x) | 1); - *z *= 65536 / (integer_sqrt(*y * *y + *z * *z + *x * *x) | 1); -} - //----- (0043AE12) -------------------------------------------------------- double __fastcall sub_43AE12(signed int a1) {