Skip to content

Commit 2665cd4

Browse files
ShaurenXenphis
authored andcommitted
Core/GameObjects: Use all axis rotations for gameobject model collision, not just orientation
(cherry-picked from commit c13d26e1fa40ac8d40e1b4f7c72e4c1ef3f6c5e8)
1 parent 0cf62b8 commit 2665cd4

3 files changed

Lines changed: 10 additions & 4 deletions

File tree

src/common/Collision/Models/GameObjectModel.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "Log.h"
2020
#include "MapTree.h"
2121
#include "Timer.h"
22+
#include <G3D/Quat.h>
2223
#include "VMapDefinitions.h"
2324
#include "VMapFactory.h"
2425
#include "VMapManager2.h"
@@ -126,7 +127,7 @@ bool GameObjectModel::initialize(std::unique_ptr<GameObjectModelOwnerBase> model
126127
iScale = modelOwner->GetScale();
127128
iInvScale = 1.f / iScale;
128129

129-
G3D::Matrix3 iRotation = G3D::Matrix3::fromEulerAnglesZYX(modelOwner->GetOrientation(), 0, 0);
130+
G3D::Matrix3 iRotation = modelOwner->GetRotation().toRotationMatrix();
130131
iInvRot = iRotation.inverse();
131132
// transform bounding box:
132133
mdl_box = AABox(mdl_box.low() * iScale, mdl_box.high() * iScale);
@@ -246,7 +247,7 @@ bool GameObjectModel::UpdatePosition()
246247

247248
iPos = owner->GetPosition();
248249

249-
G3D::Matrix3 iRotation = G3D::Matrix3::fromEulerAnglesZYX(owner->GetOrientation(), 0, 0);
250+
G3D::Matrix3 iRotation = owner->GetRotation().toRotationMatrix();
250251
iInvRot = iRotation.inverse();
251252
// transform bounding box:
252253
mdl_box = AABox(mdl_box.low() * iScale, mdl_box.high() * iScale);

src/common/Collision/Models/GameObjectModel.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@
2626
#include "Define.h"
2727
#include <memory>
2828

29+
namespace G3D
30+
{
31+
class Quat;
32+
}
33+
2934
namespace VMAP
3035
{
3136
class WorldModel;
@@ -46,7 +51,7 @@ class TC_COMMON_API GameObjectModelOwnerBase
4651
virtual uint32 GetDisplayId() const = 0;
4752
virtual uint32 GetPhaseMask() const = 0;
4853
virtual G3D::Vector3 GetPosition() const = 0;
49-
virtual float GetOrientation() const = 0;
54+
virtual G3D::Quat GetRotation() const = 0;
5055
virtual float GetScale() const = 0;
5156
virtual void DebugVisualizeCorner(G3D::Vector3 const& /*corner*/) const = 0;
5257
};

src/server/game/Entities/GameObject/GameObject.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2859,7 +2859,7 @@ class GameObjectModelOwnerImpl : public GameObjectModelOwnerBase
28592859
uint32 GetDisplayId() const override { return _owner->GetDisplayId(); }
28602860
uint32 GetPhaseMask() const override { return _owner->GetPhaseMask(); }
28612861
G3D::Vector3 GetPosition() const override { return G3D::Vector3(_owner->GetPositionX(), _owner->GetPositionY(), _owner->GetPositionZ()); }
2862-
float GetOrientation() const override { return _owner->GetOrientation(); }
2862+
G3D::Quat GetRotation() const override { return G3D::Quat(_owner->GetLocalRotation().x, _owner->GetLocalRotation().y, _owner->GetLocalRotation().z, _owner->GetLocalRotation().w); }
28632863
float GetScale() const override { return _owner->GetObjectScale(); }
28642864
void DebugVisualizeCorner(G3D::Vector3 const& corner) const override { const_cast<GameObject*>(_owner)->SummonCreature(1, corner.x, corner.y, corner.z, 0, TEMPSUMMON_MANUAL_DESPAWN); }
28652865

0 commit comments

Comments
 (0)