Mercurial > mm7
view 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 |
line wrap: on
line source
#define _CRTDBG_MAP_ALLOC #include <stdlib.h> #include <crtdbg.h> #define _CRT_SECURE_NO_WARNINGS #include <utility> #include "mm7_data.h" #include "OurMath.h" //----- (004621DA) -------------------------------------------------------- uint32_t int_get_vector_length(int32_t x, int32_t y, int32_t z) { if (x < y) { std::swap(x, y); } if (x < z) { std::swap(x, z); } if (y < z) { std::swap(y, z); } return x + (11 * y >> 5) + (z >> 2); } //----- (0044C362) -------------------------------------------------------- template <class T> void Vec3<T>::Normalize_float() { double x = this->x; double y = this->y; double z = this->z; double s = sqrt(x * x + y * y + z * z); this->x = bankersRounding(x / s); this->y = bankersRounding(y / s); this->z = bankersRounding(z / s); } //----- (0043AA99) -------------------------------------------------------- template <class T> void __fastcall Vec3<T>::Rotate(T sDepth, T sRotY, T sRotX, Vec3<T> v, T *outx, T *outy, T *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) -------------------------------------------------------- template <class T> void Vec3<T>::Normalize(T *x, T *y, T *z) { extern int integer_sqrt(int val); *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); } template Vec3<int32_t>;