Skip to content

Commit

Permalink
Merge pull request #1068 from anatawa12/fix-invalid-aabb
Browse files Browse the repository at this point in the history
fix: Invalid AABB error
  • Loading branch information
anatawa12 authored May 12, 2024
2 parents d926af6 + ee2d6ad commit 5bd73da
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG-PRERELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ The format is based on [Keep a Changelog].
### Removed

### Fixed
- Invalid AABB error message from UnityEngine if there are no source for Merge Skinned Mesh `#1068`

### Security

Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ The format is based on [Keep a Changelog].

### Fixed
- Some rare material swap animation can cause exception `#1067`
- Invalid AABB error message from UnityEngine if there are no source for Merge Skinned Mesh `#1068`

### Security

Expand Down
7 changes: 6 additions & 1 deletion Editor/Processors/SkinnedMeshes/MergeSkinnedMeshProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,12 @@ MeshInfo2[] meshInfos
}
}

if (newBoundMin != Vector3.positiveInfinity && newBoundMax != Vector3.negativeInfinity)
if (Utils.IsFinite(newBoundMin.x)
&& Utils.IsFinite(newBoundMin.y)
&& Utils.IsFinite(newBoundMin.z)
&& Utils.IsFinite(newBoundMax.x)
&& Utils.IsFinite(newBoundMax.y)
&& Utils.IsFinite(newBoundMax.z))
{
target.Bounds.SetMinMax(newBoundMin, newBoundMax);
}
Expand Down
2 changes: 2 additions & 0 deletions Internal/Utils/Utils.Float.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,7 @@ public static float PreviousFloat(float x)
public static int SingleToInt32Bits(float value) => BitConverter.ToInt32(BitConverter.GetBytes(value), 0);
public static float Int32BitsToSingle(int value) => BitConverter.ToSingle(BitConverter.GetBytes(value), 0);
#endif

public static bool IsFinite(float x) => !float.IsNaN(x) && !float.IsInfinity(x);
}
}

0 comments on commit 5bd73da

Please sign in to comment.