mirror of
https://github.com/liyunfan1223/azerothcore-wotlk.git
synced 2026-08-07 15:28:02 +00:00
fix(Core/GameObject): Handle zero quaternion rotation for dynamically spawned gameobjects (#24662)
Co-authored-by: blinkysc <blinkysc@users.noreply.github.com> Co-authored-by: zergtmn <zergtmn@users.noreply.github.com>
This commit is contained in:
@@ -2209,6 +2209,10 @@ void GameObject::UpdatePackedRotation()
|
||||
void GameObject::SetWorldRotation(G3D::Quat const& rot)
|
||||
{
|
||||
G3D::Quat rotation = rot;
|
||||
// If the quaternion is zero (e.g. dynamically spawned GOs with no rotation),
|
||||
// fall back to computing rotation from orientation to avoid NaN from unitize()
|
||||
if (G3D::fuzzyEq(rotation.magnitude(), 0.0f))
|
||||
rotation = G3D::Quat::fromAxisAngleRotation(G3D::Vector3::unitZ(), GetOrientation());
|
||||
rotation.unitize();
|
||||
WorldRotation = rotation;
|
||||
UpdatePackedRotation();
|
||||
|
||||
Reference in New Issue
Block a user