aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2023-02-05 22:14:11 +0100
committerShauren <shauren.trinity@gmail.com>2023-02-05 22:14:11 +0100
commitea3f7f665b658744970a4cdc24b30e09342039cd (patch)
tree78b2a4295f8914d462bff17743e44392b7879f08
parentb6965b2c30eb3317228b328a0c1da71235d7c257 (diff)
Core/GameObjects: Fixed crash with transport gameobjects that have only 1 entry in TransportAnimation/TransportRotation db2
Closes #28673
-rw-r--r--src/server/game/Entities/GameObject/GameObject.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp
index d26144cd019..43707fa07ce 100644
--- a/src/server/game/Entities/GameObject/GameObject.cpp
+++ b/src/server/game/Entities/GameObject/GameObject.cpp
@@ -304,10 +304,15 @@ public:
G3D::Vector3 prev(oldAnimation->Pos.X, oldAnimation->Pos.Y, oldAnimation->Pos.Z);
G3D::Vector3 next(newAnimation->Pos.X, newAnimation->Pos.Y, newAnimation->Pos.Z);
- float animProgress = float(newProgress - oldAnimation->TimeIndex) / float(newAnimation->TimeIndex - oldAnimation->TimeIndex);
+ G3D::Vector3 dst = next;
+ if (prev != next)
+ {
+ float animProgress = float(newProgress - oldAnimation->TimeIndex) / float(newAnimation->TimeIndex - oldAnimation->TimeIndex);
- G3D::Vector3 dst = prev.lerp(next, animProgress) * pathRotation;
+ dst = prev.lerp(next, animProgress);
+ }
+ dst = dst * pathRotation;
dst += PositionToVector3(&_owner.GetStationaryPosition());
_owner.GetMap()->GameObjectRelocation(&_owner, dst.x, dst.y, dst.z, _owner.GetOrientation());
@@ -320,9 +325,14 @@ public:
G3D::Quat prev(oldRotation->Rot[0], oldRotation->Rot[1], oldRotation->Rot[2], oldRotation->Rot[3]);
G3D::Quat next(newRotation->Rot[0], newRotation->Rot[1], newRotation->Rot[2], newRotation->Rot[3]);
- float animProgress = float(newProgress - oldRotation->TimeIndex) / float(newRotation->TimeIndex - oldRotation->TimeIndex);
+ G3D::Quat rotation = next;
- G3D::Quat rotation = prev.slerp(next, animProgress);
+ if (prev != next)
+ {
+ float animProgress = float(newProgress - oldRotation->TimeIndex) / float(newRotation->TimeIndex - oldRotation->TimeIndex);
+
+ rotation = prev.slerp(next, animProgress);
+ }
_owner.SetLocalRotation(rotation.x, rotation.y, rotation.z, rotation.w);
_owner.UpdateModelPosition();