aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2022-05-22 14:53:05 +0200
committerShauren <shauren.trinity@gmail.com>2022-05-22 14:53:05 +0200
commitc13d26e1fa40ac8d40e1b4f7c72e4c1ef3f6c5e8 (patch)
treef2860f37c8fce085b7ca2574294ca9d96ac79bd9 /src
parent703452d28d05e8690ad802b9c7c22e0df6c50d71 (diff)
Core/GameObjects: Use all axis rotations for gameobject model collision, not just orientation
Diffstat (limited to 'src')
-rw-r--r--src/common/Collision/Models/GameObjectModel.cpp5
-rw-r--r--src/common/Collision/Models/GameObjectModel.h7
-rw-r--r--src/server/game/Entities/GameObject/GameObject.cpp2
3 files changed, 10 insertions, 4 deletions
diff --git a/src/common/Collision/Models/GameObjectModel.cpp b/src/common/Collision/Models/GameObjectModel.cpp
index bcbfed28f32..5ef59a727ea 100644
--- a/src/common/Collision/Models/GameObjectModel.cpp
+++ b/src/common/Collision/Models/GameObjectModel.cpp
@@ -23,6 +23,7 @@
#include "Log.h"
#include "MapTree.h"
#include "Timer.h"
+#include <G3D/Quat.h>
using G3D::Vector3;
using G3D::Ray;
@@ -124,7 +125,7 @@ bool GameObjectModel::initialize(std::unique_ptr<GameObjectModelOwnerBase> model
iScale = modelOwner->GetScale();
iInvScale = 1.f / iScale;
- G3D::Matrix3 iRotation = G3D::Matrix3::fromEulerAnglesZYX(modelOwner->GetOrientation(), 0, 0);
+ G3D::Matrix3 iRotation = modelOwner->GetRotation().toRotationMatrix();
iInvRot = iRotation.inverse();
// transform bounding box:
mdl_box = AABox(mdl_box.low() * iScale, mdl_box.high() * iScale);
@@ -275,7 +276,7 @@ bool GameObjectModel::UpdatePosition()
iPos = owner->GetPosition();
- G3D::Matrix3 iRotation = G3D::Matrix3::fromEulerAnglesZYX(owner->GetOrientation(), 0, 0);
+ G3D::Matrix3 iRotation = owner->GetRotation().toRotationMatrix();
iInvRot = iRotation.inverse();
// transform bounding box:
mdl_box = AABox(mdl_box.low() * iScale, mdl_box.high() * iScale);
diff --git a/src/common/Collision/Models/GameObjectModel.h b/src/common/Collision/Models/GameObjectModel.h
index c10a8bfdea2..a8a5c6fc5e0 100644
--- a/src/common/Collision/Models/GameObjectModel.h
+++ b/src/common/Collision/Models/GameObjectModel.h
@@ -26,6 +26,11 @@
#include "Define.h"
#include <memory>
+namespace G3D
+{
+class Quat;
+}
+
namespace VMAP
{
class WorldModel;
@@ -48,7 +53,7 @@ public:
virtual uint8 GetNameSetId() const = 0;
virtual bool IsInPhase(PhaseShift const& /*phaseShift*/) const = 0;
virtual G3D::Vector3 GetPosition() const = 0;
- virtual float GetOrientation() const = 0;
+ virtual G3D::Quat GetRotation() const = 0;
virtual float GetScale() const = 0;
virtual void DebugVisualizeCorner(G3D::Vector3 const& /*corner*/) const = 0;
};
diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp
index 76a09af2d0b..01212a02097 100644
--- a/src/server/game/Entities/GameObject/GameObject.cpp
+++ b/src/server/game/Entities/GameObject/GameObject.cpp
@@ -3299,7 +3299,7 @@ public:
uint8 GetNameSetId() const override { return _owner->GetNameSetId(); }
bool IsInPhase(PhaseShift const& phaseShift) const override { return _owner->GetPhaseShift().CanSee(phaseShift); }
G3D::Vector3 GetPosition() const override { return G3D::Vector3(_owner->GetPositionX(), _owner->GetPositionY(), _owner->GetPositionZ()); }
- float GetOrientation() const override { return _owner->GetOrientation(); }
+ G3D::Quat GetRotation() const override { return G3D::Quat(_owner->GetLocalRotation().x, _owner->GetLocalRotation().y, _owner->GetLocalRotation().z, _owner->GetLocalRotation().w); }
float GetScale() const override { return _owner->GetObjectScale(); }
void DebugVisualizeCorner(G3D::Vector3 const& corner) const override { _owner->SummonCreature(1, corner.x, corner.y, corner.z, 0, TEMPSUMMON_MANUAL_DESPAWN); }