From ae104fea277c1f41b52a95b0f6c4f40a73b32ce7 Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Thu, 19 Mar 2009 20:14:03 +0300 Subject: [PATCH] [7496] Fxied problems with visual GO orientation for some angles. Optimize related code. --- src/game/GameObject.cpp | 13 +++++++------ src/shared/revision_nr.h | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/game/GameObject.cpp b/src/game/GameObject.cpp index ae9689216..9ebed58ac 100644 --- a/src/game/GameObject.cpp +++ b/src/game/GameObject.cpp @@ -1303,20 +1303,21 @@ const char* GameObject::GetNameForLocaleIdx(int32 loc_idx) const void GameObject::UpdateRotationFields(float rotation2 /*=0.0f*/, float rotation3 /*=0.0f*/) { + static double const atan_pow = atan(pow(2.0f, -20.0f)); + SetFloatValue(GAMEOBJECT_FACING, GetOrientation()); - int64 rotation = 0; - double f_rot1 = sin(GetOrientation() / 2.0f); - int64 i_rot1 = int64(f_rot1 / atan(pow(2.0f, -20.0f))); - rotation |= (i_rot1 << 43 >> 43) & 0x00000000001FFFFF; + double f_rot2 = cos(GetOrientation() / 2.0f); + int64 i_rot1 = int64(f_rot1 / atan_pow *(f_rot2 >= 0 ? 1.0f : -1.0f)); + int64 rotation = (i_rot1 << 43 >> 43) & 0x00000000001FFFFF; SetUInt64Value(GAMEOBJECT_ROTATION, rotation); if(rotation2==0.0f && rotation3==0.0f) { - rotation2 = sin(GetOrientation()/2); - rotation3 = cos(GetOrientation()/2); + rotation2 = f_rot1; + rotation3 = f_rot2; } SetFloatValue(GAMEOBJECT_PARENTROTATION+2, rotation2); diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 768dd4cf3..7e387ea3e 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "7495" + #define REVISION_NR "7496" #endif // __REVISION_NR_H__