From 0d0aa6a75be9ee65a7d385c5c6c17cf0bde35d05 Mon Sep 17 00:00:00 2001 From: Shauren Date: Sun, 5 Feb 2023 22:14:11 +0100 Subject: [PATCH] Core/GameObjects: Fixed crash with transport gameobjects that have only 1 entry in TransportAnimation/TransportRotation db2 Closes #28673 --- .../game/Entities/GameObject/GameObject.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp index efeb8b11af..4c13b58f27 100644 --- a/src/server/game/Entities/GameObject/GameObject.cpp +++ b/src/server/game/Entities/GameObject/GameObject.cpp @@ -217,10 +217,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()); @@ -233,9 +238,14 @@ public: G3D::Quat prev(oldRotation->X, oldRotation->Y, oldRotation->Z, oldRotation->W); G3D::Quat next(newRotation->X, newRotation->Y, newRotation->Z, newRotation->W); - 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();