| | | 1 | | //======================================================================= |
| | | 2 | | // MixedQueryReducerClassifier.cs |
| | | 3 | | //======================================================================= |
| | | 4 | | // MIT License, Copyright (c) 2026-present David Oravsky (mrdav30) |
| | | 5 | | // See LICENSE file in the project root for full license information. |
| | | 6 | | //======================================================================= |
| | | 7 | | |
| | | 8 | | using Gravitas.Colliders; |
| | | 9 | | using System; |
| | | 10 | | |
| | | 11 | | namespace Gravitas.Queries; |
| | | 12 | | |
| | | 13 | | /// <summary> |
| | | 14 | | /// Classifies mixed swept-query reducers before the exact candidate path runs. |
| | | 15 | | /// </summary> |
| | | 16 | | internal static class MixedQueryReducerClassifier |
| | | 17 | | { |
| | | 18 | | internal static PhysicsQueryReducerKind ClassifySweepSphereAgainst2D(LSCollider2D collider) |
| | | 19 | | { |
| | 8 | 20 | | if (collider is LSCircleCollider2D |
| | 8 | 21 | | || collider is LSCapsuleCollider2D |
| | 8 | 22 | | || collider is LSAABBoxCollider2D |
| | 8 | 23 | | || collider is LSPolygonCollider2D) |
| | | 24 | | { |
| | 6 | 25 | | return PhysicsQueryReducerKind.Exact; |
| | | 26 | | } |
| | | 27 | | |
| | 2 | 28 | | if (collider is LSCompoundCollider2D) |
| | 1 | 29 | | return PhysicsQueryReducerKind.Exact; |
| | | 30 | | |
| | 1 | 31 | | throw new InvalidOperationException( |
| | 1 | 32 | | "The embedded 2D collider type is not supported by mixed queries."); |
| | | 33 | | } |
| | | 34 | | |
| | | 35 | | internal static PhysicsQueryReducerKind ClassifySweepCircleAgainst3D(LSCollider collider) |
| | | 36 | | { |
| | 11 | 37 | | if (collider is LSSphereCollider |
| | 11 | 38 | | || collider is LSCuboidCollider |
| | 11 | 39 | | || collider is LSCapsuleCollider |
| | 11 | 40 | | || collider is LSCylinderCollider |
| | 11 | 41 | | || collider is LSConeCollider |
| | 11 | 42 | | || collider is LSMeshCollider) |
| | | 43 | | { |
| | 8 | 44 | | return PhysicsQueryReducerKind.Exact; |
| | | 45 | | } |
| | | 46 | | |
| | 3 | 47 | | if (collider is LSCompoundCollider) |
| | 1 | 48 | | return PhysicsQueryReducerKind.Exact; |
| | | 49 | | |
| | 2 | 50 | | return PhysicsQueryReducerKind.ConservativeFallback; |
| | | 51 | | } |
| | | 52 | | } |