Skip to content

Commit

Permalink
Bugfix: RuntimeUtility.SphereCastIgnoreTag was sometimes retruning Na…
Browse files Browse the repository at this point in the history
…N result.
  • Loading branch information
glabute committed Jun 18, 2024
1 parent 34b402b commit b0709db
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions com.unity.cinemachine/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Bugfix: The GroupAverage Rotation Mode in CinemachineTargetGroup was not calculated properly.
- Bugfix: PostProcessing and VolumeSettings were not blending correctly to and from empty profiles.
- Bugfix: added missing null check in CinemachineTargetGroup.WeightedMemberBoundsForValidMember.
- Bugfix: RuntimeUtility.SphereCastIgnoreTag was sometimes retruning NaN result.


## [2.10.0] - 2024-01-01
Expand Down
10 changes: 6 additions & 4 deletions com.unity.cinemachine/Runtime/Core/RuntimeUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,6 @@ public static bool SphereCastIgnoreTag(
// Collect overlapping items
if (h.distance == 0 && h.normal == -dir)
{
if (s_PenetrationIndexBuffer.Length > numPenetrations + 1)
s_PenetrationIndexBuffer[numPenetrations++] = i;

// hitInfo for overlapping colliders will have special
// values that are not helpful to the caller. Fix that here.
var scratchCollider = GetScratchCollider();
Expand All @@ -145,7 +142,12 @@ public static bool SphereCastIgnoreTag(
h.distance = offsetDistance - radius; // will be -ve
h.normal = offsetDir;
s_HitBuffer[i] = h;
penetrationDistanceSum += h.distance;
if (h.distance < -0.0001f)
{
penetrationDistanceSum += h.distance;
if (s_PenetrationIndexBuffer.Length > numPenetrations + 1)
s_PenetrationIndexBuffer[numPenetrations++] = i;
}
}
else
{
Expand Down

0 comments on commit b0709db

Please sign in to comment.