mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 13:37:05 +00:00
[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:
parent
85a13fcc33
commit
f99fcb1b92
4 changed files with 34 additions and 20 deletions
|
|
@ -129,7 +129,10 @@ bool GameObject::Create(uint32 guidlow, uint32 name_id, Map *map, uint32 phaseMa
|
|||
|
||||
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_FLAGS, goinfo->flags);
|
||||
|
|
@ -514,10 +517,10 @@ void GameObject::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
|
|||
data.posY = GetPositionY();
|
||||
data.posZ = GetPositionZ();
|
||||
data.orientation = GetOrientation();
|
||||
data.rotation0 = GetFloatValue(GAMEOBJECT_PARENTROTATION+0);
|
||||
data.rotation1 = GetFloatValue(GAMEOBJECT_PARENTROTATION+1);
|
||||
data.rotation2 = GetFloatValue(GAMEOBJECT_PARENTROTATION+2);
|
||||
data.rotation3 = GetFloatValue(GAMEOBJECT_PARENTROTATION+3);
|
||||
data.rotation0 = m_quatX;
|
||||
data.rotation1 = m_quatY;
|
||||
data.rotation2 = m_quatZ;
|
||||
data.rotation3 = m_quatW;
|
||||
data.spawntimesecs = m_spawnedByDefault ? (int32)m_respawnDelayTime : -(int32)m_respawnDelayTime;
|
||||
data.animprogress = GetGoAnimProgress();
|
||||
data.go_state = GetGoState();
|
||||
|
|
@ -535,10 +538,10 @@ void GameObject::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
|
|||
<< GetPositionY() << ", "
|
||||
<< GetPositionZ() << ", "
|
||||
<< GetOrientation() << ", "
|
||||
<< GetFloatValue(GAMEOBJECT_PARENTROTATION) << ", "
|
||||
<< GetFloatValue(GAMEOBJECT_PARENTROTATION+1) << ", "
|
||||
<< GetFloatValue(GAMEOBJECT_PARENTROTATION+2) << ", "
|
||||
<< GetFloatValue(GAMEOBJECT_PARENTROTATION+3) << ", "
|
||||
<< m_quatX << ", "
|
||||
<< m_quatY << ", "
|
||||
<< m_quatZ << ", "
|
||||
<< m_quatW << ", "
|
||||
<< m_respawnDelayTime << ", "
|
||||
<< uint32(GetGoAnimProgress()) << ", "
|
||||
<< uint32(GetGoState()) << ")";
|
||||
|
|
@ -1669,7 +1672,7 @@ struct QuaternionCompressed
|
|||
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);
|
||||
// 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();
|
||||
m_rotation = QuaternionCompressed(quat).m_raw;
|
||||
SetFloatValue(GAMEOBJECT_PARENTROTATION+0, quat.x);
|
||||
SetFloatValue(GAMEOBJECT_PARENTROTATION+1, quat.y);
|
||||
SetFloatValue(GAMEOBJECT_PARENTROTATION+2, quat.z);
|
||||
SetFloatValue(GAMEOBJECT_PARENTROTATION+3, quat.w);
|
||||
m_rotation = QuaternionCompressed(quat).m_raw;
|
||||
m_quatX = quat.x;
|
||||
m_quatY = quat.y;
|
||||
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) );
|
||||
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
|
||||
|
|
|
|||
|
|
@ -607,7 +607,9 @@ class MANGOS_DLL_SPEC GameObject : public WorldObject
|
|||
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
|
||||
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; }
|
||||
|
||||
// overwrite WorldObject function for proper name localization
|
||||
|
|
@ -745,9 +747,9 @@ class MANGOS_DLL_SPEC GameObject : public WorldObject
|
|||
GameObjectInfo const* m_goInfo;
|
||||
GameObjectDisplayInfoEntry const* m_displayInfo;
|
||||
int64 m_rotation;
|
||||
float m_quatX, m_quatY, m_quatZ, m_quatW;
|
||||
private:
|
||||
void SwitchDoorOrButton(bool activate, bool alternative = false);
|
||||
void SetRotationQuat(float qx, float qy, float qz, float qw);
|
||||
|
||||
GridReference<GameObject> m_gridRef;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -962,7 +962,7 @@ bool ChatHandler::HandleGameObjectTurnCommand(char* args)
|
|||
if (!ExtractFloat(&args, z_rot) || !ExtractOptFloat(&args, y_rot, 0) || !ExtractOptFloat(&args, x_rot, 0))
|
||||
return false;
|
||||
|
||||
obj->SetRotationAngles(z_rot, y_rot, x_rot);
|
||||
obj->SetWorldRotationAngles(z_rot, y_rot, x_rot);
|
||||
obj->SaveToDB();
|
||||
PSendSysMessage(LANG_COMMAND_TURNOBJMESSAGE, obj->GetGUIDLow(), obj->GetGOInfo()->name, obj->GetGUIDLow());
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "11666"
|
||||
#define REVISION_NR "11667"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue