diff options
Diffstat (limited to 'src/game/GameObject.cpp')
-rw-r--r-- | src/game/GameObject.cpp | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/src/game/GameObject.cpp b/src/game/GameObject.cpp index 95a83ce6819..00e60395ce4 100644 --- a/src/game/GameObject.cpp +++ b/src/game/GameObject.cpp @@ -125,28 +125,11 @@ bool GameObject::Create(uint32 guidlow, uint32 name_id, Map *map, uint32 phaseMa SetFloatValue(GAMEOBJECT_POS_X, x); SetFloatValue(GAMEOBJECT_POS_Y, y); SetFloatValue(GAMEOBJECT_POS_Z, z); - SetFloatValue(GAMEOBJECT_FACING, ang); //this is not facing angle - - int64 rotation = 0; - - double f_rot1 = sin(ang / 2.0f); - int64 i_rot1 = int64(f_rot1 / atan(pow(2.0f, -20.0f))); - rotation |= (i_rot1 << 43 >> 43) & 0x00000000001FFFFF; - - //float f_rot2 = sin(0.0f / 2.0f); - //int64 i_rot2 = f_rot2 / atan(pow(2.0f, -20.0f)); - //rotation |= (((i_rot2 << 22) >> 32) >> 11) & 0x000003FFFFE00000; - - //float f_rot3 = sin(0.0f / 2.0f); - //int64 i_rot3 = f_rot3 / atan(pow(2.0f, -21.0f)); - //rotation |= (i_rot3 >> 42) & 0x7FFFFC0000000000; - - SetUInt64Value(GAMEOBJECT_ROTATION, rotation); SetFloatValue(GAMEOBJECT_PARENTROTATION+0, rotation0); SetFloatValue(GAMEOBJECT_PARENTROTATION+1, rotation1); - SetFloatValue(GAMEOBJECT_PARENTROTATION+2, rotation2); - SetFloatValue(GAMEOBJECT_PARENTROTATION+3, rotation3); + + UpdateRotationFields(rotation2,rotation3); // GAMEOBJECT_FACING, GAMEOBJECT_ROTATION, GAMEOBJECT_PARENTROTATION+2/3 SetFloatValue(OBJECT_FIELD_SCALE_X, goinfo->size); @@ -1421,3 +1404,24 @@ const char* GameObject::GetNameForLocaleIdx(int32 loc_idx) const return GetName(); } +void GameObject::UpdateRotationFields(float rotation2 /*=0.0f*/, float rotation3 /*=0.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; + + SetUInt64Value(GAMEOBJECT_ROTATION, rotation); + + if(rotation2==0.0f && rotation3==0.0f) + { + rotation2 = sin(GetOrientation()/2); + rotation3 = cos(GetOrientation()/2); + } + + SetFloatValue(GAMEOBJECT_PARENTROTATION+2, rotation2); + SetFloatValue(GAMEOBJECT_PARENTROTATION+3, rotation3); +} |