| | | 1 | | //======================================================================= |
| | | 2 | | // PhysicsHitSelectionPolicy.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 System.Runtime.CompilerServices; |
| | | 9 | | using FixedMathSharp; |
| | | 10 | | |
| | | 11 | | namespace Gravitas.Queries; |
| | | 12 | | |
| | | 13 | | /// <summary> |
| | | 14 | | /// Selects the best accepted hit using the ordering rules for each query dimension. |
| | | 15 | | /// </summary> |
| | | 16 | | internal static class PhysicsHitSelectionPolicy |
| | | 17 | | { |
| | | 18 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | | 19 | | internal static bool ShouldReplace(Physics2DHit candidate, bool found, Physics2DHit current) => |
| | 21726 | 20 | | !found || Physics2DHitSorter.ComesBefore(candidate, current); |
| | | 21 | | |
| | | 22 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | | 23 | | internal static bool ShouldReplace(Physics3DHit candidate, bool found, Physics3DHit current) => |
| | 3953 | 24 | | !found || Physics3DHitSorter.ComesBefore(candidate, current); |
| | | 25 | | |
| | | 26 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | | 27 | | internal static bool ShouldReplace(PhysicsMixedHit candidate, bool found, PhysicsMixedHit current) => |
| | 744 | 28 | | !found || PhysicsMixedHitSorter.ComesBefore(candidate, current); |
| | | 29 | | |
| | | 30 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | | 31 | | internal static bool ShouldReplaceDistance(Fixed64 candidateDistance, bool found, Fixed64 currentDistance) => |
| | 100 | 32 | | !found || candidateDistance < currentDistance; |
| | | 33 | | } |