| | | 1 | | //======================================================================= |
| | | 2 | | // ContactSelectionPolicy.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 | | |
| | | 10 | | namespace Gravitas.CollisionHandling; |
| | | 11 | | |
| | | 12 | | internal static class ContactSelectionPolicy |
| | | 13 | | { |
| | | 14 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | | 15 | | internal static bool ShouldReplaceWithDeeper(Contact2D candidate, bool found, Contact2D current) => |
| | 14 | 16 | | !found |
| | 14 | 17 | | || candidate.Depth > current.Depth |
| | 14 | 18 | | || (candidate.Depth == current.Depth |
| | 14 | 19 | | && candidate.DepthIsClamped |
| | 14 | 20 | | && !current.DepthIsClamped); |
| | | 21 | | |
| | | 22 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | | 23 | | internal static bool ShouldReplaceWithShallower(MixedContact candidate, bool found, MixedContact current) => |
| | 47 | 24 | | !found |
| | 47 | 25 | | || candidate.Depth < current.Depth |
| | 47 | 26 | | || (candidate.Depth == current.Depth |
| | 47 | 27 | | && current.DepthIsClamped |
| | 47 | 28 | | && !candidate.DepthIsClamped); |
| | | 29 | | } |