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:
blinkysc
2026-02-09 20:07:23 -06:00
committed by GitHub
parent d914d61acb
commit 54d145499e
5 changed files with 67 additions and 4 deletions

View File

@@ -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();