| | | 1 | | //======================================================================= |
| | | 2 | | // DynamicCcdExtentMetadata.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.CollisionHandling; |
| | | 12 | | |
| | | 13 | | /// <summary> |
| | | 14 | | /// Checks whether a bounds update preserves the X extent tracked by the CCD indexes. |
| | | 15 | | /// </summary> |
| | | 16 | | internal static class DynamicCcdExtentMetadata |
| | | 17 | | { |
| | | 18 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | | 19 | | public static bool IsEquivalent( |
| | | 20 | | Fixed64 previousMinX, |
| | | 21 | | Fixed64 previousMaxX, |
| | | 22 | | Fixed64 currentMinX, |
| | | 23 | | Fixed64 currentMaxX) |
| | | 24 | | { |
| | 129068 | 25 | | bool previousRepresentable = Fixed64.TrySubtract(previousMaxX, previousMinX, out Fixed64 previousExtentX); |
| | 129068 | 26 | | bool currentRepresentable = Fixed64.TrySubtract(currentMaxX, currentMinX, out Fixed64 currentExtentX); |
| | 129068 | 27 | | return previousRepresentable == currentRepresentable |
| | 129068 | 28 | | && (!previousRepresentable || previousExtentX == currentExtentX); |
| | | 29 | | } |
| | | 30 | | } |