[11667] Implement transport path rotation

Transport rotation transforms transport path - this makes possible to have few transports with same entry but with modified paths.
This also solvers problems with some transports (like deeprun tram).
TODO: some transports has non standart rotations, that must be stored in db

Signed-off-by: SilverIce <slifeleaf@gmail.com>
This commit is contained in:
SilverIce 2011-06-24 14:28:08 +03:00
parent 85a13fcc33
commit f99fcb1b92
4 changed files with 34 additions and 20 deletions

View file

@ -129,7 +129,10 @@ bool GameObject::Create(uint32 guidlow, uint32 name_id, Map *map, uint32 phaseMa
SetObjectScale(goinfo->size); SetObjectScale(goinfo->size);
SetRotationQuat(rotation0,rotation1,rotation2,rotation3); SetWorldRotation(rotation0,rotation1,rotation2,rotation3);
// For most of gameobjects is (0, 0, 0, 1) quaternion, only transports has not standart rotation
// TODO: store these values in DB
SetTransportPathRotation(0, 0, 0, 1.f);
SetUInt32Value(GAMEOBJECT_FACTION, goinfo->faction); SetUInt32Value(GAMEOBJECT_FACTION, goinfo->faction);
SetUInt32Value(GAMEOBJECT_FLAGS, goinfo->flags); SetUInt32Value(GAMEOBJECT_FLAGS, goinfo->flags);
@ -514,10 +517,10 @@ void GameObject::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
data.posY = GetPositionY(); data.posY = GetPositionY();
data.posZ = GetPositionZ(); data.posZ = GetPositionZ();
data.orientation = GetOrientation(); data.orientation = GetOrientation();
data.rotation0 = GetFloatValue(GAMEOBJECT_PARENTROTATION+0); data.rotation0 = m_quatX;
data.rotation1 = GetFloatValue(GAMEOBJECT_PARENTROTATION+1); data.rotation1 = m_quatY;
data.rotation2 = GetFloatValue(GAMEOBJECT_PARENTROTATION+2); data.rotation2 = m_quatZ;
data.rotation3 = GetFloatValue(GAMEOBJECT_PARENTROTATION+3); data.rotation3 = m_quatW;
data.spawntimesecs = m_spawnedByDefault ? (int32)m_respawnDelayTime : -(int32)m_respawnDelayTime; data.spawntimesecs = m_spawnedByDefault ? (int32)m_respawnDelayTime : -(int32)m_respawnDelayTime;
data.animprogress = GetGoAnimProgress(); data.animprogress = GetGoAnimProgress();
data.go_state = GetGoState(); data.go_state = GetGoState();
@ -535,10 +538,10 @@ void GameObject::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
<< GetPositionY() << ", " << GetPositionY() << ", "
<< GetPositionZ() << ", " << GetPositionZ() << ", "
<< GetOrientation() << ", " << GetOrientation() << ", "
<< GetFloatValue(GAMEOBJECT_PARENTROTATION) << ", " << m_quatX << ", "
<< GetFloatValue(GAMEOBJECT_PARENTROTATION+1) << ", " << m_quatY << ", "
<< GetFloatValue(GAMEOBJECT_PARENTROTATION+2) << ", " << m_quatZ << ", "
<< GetFloatValue(GAMEOBJECT_PARENTROTATION+3) << ", " << m_quatW << ", "
<< m_respawnDelayTime << ", " << m_respawnDelayTime << ", "
<< uint32(GetGoAnimProgress()) << ", " << uint32(GetGoAnimProgress()) << ", "
<< uint32(GetGoState()) << ")"; << uint32(GetGoState()) << ")";
@ -1669,7 +1672,7 @@ struct QuaternionCompressed
int64 m_raw; int64 m_raw;
}; };
void GameObject::SetRotationQuat(float qx, float qy, float qz, float qw) void GameObject::SetWorldRotation(float qx, float qy, float qz, float qw)
{ {
Quat quat(qx, qy, qz, qw); Quat quat(qx, qy, qz, qw);
// Temporary solution for gameobjects that has no rotation data in DB: // Temporary solution for gameobjects that has no rotation data in DB:
@ -1678,16 +1681,25 @@ void GameObject::SetRotationQuat(float qx, float qy, float qz, float qw)
quat.unitize(); quat.unitize();
m_rotation = QuaternionCompressed(quat).m_raw; m_rotation = QuaternionCompressed(quat).m_raw;
SetFloatValue(GAMEOBJECT_PARENTROTATION+0, quat.x); m_rotation = QuaternionCompressed(quat).m_raw;
SetFloatValue(GAMEOBJECT_PARENTROTATION+1, quat.y); m_quatX = quat.x;
SetFloatValue(GAMEOBJECT_PARENTROTATION+2, quat.z); m_quatY = quat.y;
SetFloatValue(GAMEOBJECT_PARENTROTATION+3, quat.w); m_quatZ = quat.z;
m_quatW = quat.w;
} }
void GameObject::SetRotationAngles(float z_rot, float y_rot, float x_rot) void GameObject::SetTransportPathRotation(float qx, float qy, float qz, float qw)
{
SetFloatValue(GAMEOBJECT_PARENTROTATION+0, qx);
SetFloatValue(GAMEOBJECT_PARENTROTATION+1, qy);
SetFloatValue(GAMEOBJECT_PARENTROTATION+2, qz);
SetFloatValue(GAMEOBJECT_PARENTROTATION+3, qw);
}
void GameObject::SetWorldRotationAngles(float z_rot, float y_rot, float x_rot)
{ {
Quat quat( G3D::Matrix3::fromEulerAnglesZYX(z_rot, y_rot, x_rot) ); Quat quat( G3D::Matrix3::fromEulerAnglesZYX(z_rot, y_rot, x_rot) );
SetRotationQuat(quat.x, quat.y, quat.z, quat.w); SetWorldRotation(quat.x, quat.y, quat.z, quat.w);
} }
bool GameObject::IsHostileTo(Unit const* unit) const bool GameObject::IsHostileTo(Unit const* unit) const

View file

@ -607,7 +607,9 @@ class MANGOS_DLL_SPEC GameObject : public WorldObject
bool HasStaticDBSpawnData() const; // listed in `gameobject` table and have fixed in DB guid bool HasStaticDBSpawnData() const; // listed in `gameobject` table and have fixed in DB guid
// z_rot, y_rot, x_rot - rotation angles around z, y and x axes // z_rot, y_rot, x_rot - rotation angles around z, y and x axes
void SetRotationAngles(float z_rot, float y_rot, float x_rot); void SetWorldRotationAngles(float z_rot, float y_rot, float x_rot);
void SetWorldRotation(float qx, float qy, float qz, float qw);
void SetTransportPathRotation(float qx, float qy, float qz, float qw); // transforms(rotates) transport's path
int64 GetRotation() const { return m_rotation; } int64 GetRotation() const { return m_rotation; }
// overwrite WorldObject function for proper name localization // overwrite WorldObject function for proper name localization
@ -745,9 +747,9 @@ class MANGOS_DLL_SPEC GameObject : public WorldObject
GameObjectInfo const* m_goInfo; GameObjectInfo const* m_goInfo;
GameObjectDisplayInfoEntry const* m_displayInfo; GameObjectDisplayInfoEntry const* m_displayInfo;
int64 m_rotation; int64 m_rotation;
float m_quatX, m_quatY, m_quatZ, m_quatW;
private: private:
void SwitchDoorOrButton(bool activate, bool alternative = false); void SwitchDoorOrButton(bool activate, bool alternative = false);
void SetRotationQuat(float qx, float qy, float qz, float qw);
GridReference<GameObject> m_gridRef; GridReference<GameObject> m_gridRef;
}; };

View file

@ -962,7 +962,7 @@ bool ChatHandler::HandleGameObjectTurnCommand(char* args)
if (!ExtractFloat(&args, z_rot) || !ExtractOptFloat(&args, y_rot, 0) || !ExtractOptFloat(&args, x_rot, 0)) if (!ExtractFloat(&args, z_rot) || !ExtractOptFloat(&args, y_rot, 0) || !ExtractOptFloat(&args, x_rot, 0))
return false; return false;
obj->SetRotationAngles(z_rot, y_rot, x_rot); obj->SetWorldRotationAngles(z_rot, y_rot, x_rot);
obj->SaveToDB(); obj->SaveToDB();
PSendSysMessage(LANG_COMMAND_TURNOBJMESSAGE, obj->GetGUIDLow(), obj->GetGOInfo()->name, obj->GetGUIDLow()); PSendSysMessage(LANG_COMMAND_TURNOBJMESSAGE, obj->GetGUIDLow(), obj->GetGOInfo()->name, obj->GetGUIDLow());
return true; return true;

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "11666" #define REVISION_NR "11667"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__