diff --git a/src/Unity.Mathematics/matrix.cs b/src/Unity.Mathematics/matrix.cs index e423348f..7acace95 100644 --- a/src/Unity.Mathematics/matrix.cs +++ b/src/Unity.Mathematics/matrix.cs @@ -409,7 +409,7 @@ public static float3x3 LookRotationSafe(float3 forward, float3 up) float mn = min(min(forwardLengthSq, upLengthSq), tLengthSq); float mx = max(max(forwardLengthSq, upLengthSq), tLengthSq); - bool accept = mn > 1e-35f && mx < 1e35f; + bool accept = mn > 1e-35f && mx < 1e35f && isfinite(forwardLengthSq) && isfinite(upLengthSq) && isfinite(tLengthSq); return float3x3( select(float3(1,0,0), t, accept), select(float3(0,1,0), cross(forward, t), accept), diff --git a/src/Unity.Mathematics/quaternion.cs b/src/Unity.Mathematics/quaternion.cs index 346762bb..2d0cbbd5 100644 --- a/src/Unity.Mathematics/quaternion.cs +++ b/src/Unity.Mathematics/quaternion.cs @@ -387,7 +387,7 @@ public static quaternion LookRotationSafe(float3 forward, float3 up) float mn = min(min(forwardLengthSq, upLengthSq), tLengthSq); float mx = max(max(forwardLengthSq, upLengthSq), tLengthSq); - bool accept = mn > 1e-35f && mx < 1e35f; + bool accept = mn > 1e-35f && mx < 1e35f && isfinite(forwardLengthSq) && isfinite(upLengthSq) && isfinite(tLengthSq); return quaternion(select(float4(0.0f, 0.0f, 0.0f, 1.0f), quaternion(float3x3(t, cross(forward, t),forward)).value, accept)); }