| | | 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 FixedMathSharp; |
| | | 9 | | using System.Runtime.CompilerServices; |
| | | 10 | | |
| | | 11 | | namespace Gravitas.Queries; |
| | | 12 | | |
| | | 13 | | internal static class PhysicsHitSelectionPolicy |
| | | 14 | | { |
| | | 15 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | | 16 | | internal static bool ShouldReplace(Physics2DHit candidate, bool found, Physics2DHit current) => |
| | 17527 | 17 | | !found || Physics2DHitSorter.ComesBefore(candidate, current); |
| | | 18 | | |
| | | 19 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | | 20 | | internal static bool ShouldReplace(Physics3DHit candidate, bool found, Physics3DHit current) => |
| | 528 | 21 | | !found || Physics3DHitSorter.ComesBefore(candidate, current); |
| | | 22 | | |
| | | 23 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | | 24 | | internal static bool ShouldReplace(PhysicsMixedHit candidate, bool found, PhysicsMixedHit current) => |
| | 511 | 25 | | !found || PhysicsMixedHitSorter.ComesBefore(candidate, current); |
| | | 26 | | |
| | | 27 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | | 28 | | internal static bool ShouldReplaceDistance(Fixed64 candidateDistance, bool found, Fixed64 currentDistance) => |
| | 95 | 29 | | !found || candidateDistance < currentDistance; |
| | | 30 | | } |