Mercurial > mm7
view VectorTypes.cpp @ 1637:2c71fa8913d2
class OutdoorCamera -> ODMRenderParams
author | Nomad |
---|---|
date | Tue, 17 Sep 2013 14:10:41 +0200 |
parents | 270627b54ed4 |
children | 7a9477135943 |
line wrap: on
line source
#include <utility> #include "mm7_data.h" #include "Math.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) { *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>;