Skip to content

Commit

Permalink
colliders: Add remaining AABB transformations.
Browse files Browse the repository at this point in the history
  • Loading branch information
freezy committed Dec 30, 2024
1 parent b003eb8 commit 8cdef55
Showing 1 changed file with 44 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ public void Dispose()

public void TransformToIdentity(ref NativeParallelHashMap<int, float4x4> itemIdToTransformationMatrix)
{
#if UNITY_EDITOR
if (!KinematicColliders) {
throw new InvalidOperationException("Cannot transform non-kinetic colliders to identity.");
}
#endif
using var enumerator = _itemIdToColliderIds.GetEnumerator();
while (enumerator.MoveNext()) {
var itemId = enumerator.Current.Key;
Expand All @@ -106,6 +111,8 @@ public void TransformToIdentity(ref NativeParallelHashMap<int, float4x4> itemIdT
var lookup = Lookups[colliderId];
switch (lookup.Type) {

case ColliderType.TriggerCircle:
case ColliderType.KickerCircle:
case ColliderType.Bumper:
case ColliderType.Circle:
ref var circleCollider = ref CircleColliders.GetElementAsRef(lookup.Index);
Expand Down Expand Up @@ -176,6 +183,43 @@ public void TransformToIdentity(ref NativeParallelHashMap<int, float4x4> itemIdT
#endif
flipperCollider.TransformAabb(math.inverse(matrix));
break;

case ColliderType.LineSlingShot:
ref var slingshotCollider = ref LineSlingshotColliders.GetElementAsRef(lookup.Index);
#if UNITY_EDITOR
if (slingshotCollider.Header.IsTransformed) {
throw new InvalidOperationException("A transformed slingshot collider shouldn't have been added as a kinetic collider.");
}
#endif
slingshotCollider.TransformAabb(math.inverse(matrix));
break;

case ColliderType.Plunger:
ref var plungerCollider = ref PlungerColliders.GetElementAsRef(lookup.Index);
#if UNITY_EDITOR
if (plungerCollider.Header.IsTransformed) {
throw new InvalidOperationException("A transformed plunger collider shouldn't have been added as a kinetic collider.");
}
#endif
plungerCollider.TransformAabb(math.inverse(matrix));
break;

case ColliderType.Line:
#if UNITY_EDITOR
throw new InvalidOperationException("Line colliders shouldn't exist as kinetic colliders, but converted to line 3D colliders.");
#endif
case ColliderType.LineZ:
#if UNITY_EDITOR
throw new InvalidOperationException("Line-Z colliders shouldn't exist as kinetic colliders, but converted to line 3D colliders.");
#endif
case ColliderType.Plane:
#if UNITY_EDITOR
throw new InvalidOperationException("Planes cannot be be kinematic.");
#endif
case ColliderType.None:
break;
default:
throw new ArgumentOutOfRangeException();
}
}
}
Expand Down

0 comments on commit 8cdef55

Please sign in to comment.