| | | 1 | | //======================================================================= |
| | | 2 | | // PhysicsRuntimeMode.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; |
| | | 9 | | using System.Runtime.CompilerServices; |
| | | 10 | | |
| | | 11 | | namespace Gravitas; |
| | | 12 | | |
| | | 13 | | /// <summary> |
| | | 14 | | /// Selects which dimensional runtime path a context advances. |
| | | 15 | | /// </summary> |
| | | 16 | | [Flags] |
| | | 17 | | public enum PhysicsRuntimeMode : byte |
| | | 18 | | { |
| | | 19 | | /// <summary> |
| | | 20 | | /// No physics runtime path. This is not a valid settings value. |
| | | 21 | | /// </summary> |
| | | 22 | | None = 0, |
| | | 23 | | |
| | | 24 | | /// <summary> |
| | | 25 | | /// Advance only the pure 2D runtime path. |
| | | 26 | | /// </summary> |
| | | 27 | | TwoD = 1 << 0, |
| | | 28 | | |
| | | 29 | | /// <summary> |
| | | 30 | | /// Advance only the 3D runtime path. |
| | | 31 | | /// </summary> |
| | | 32 | | ThreeD = 1 << 1, |
| | | 33 | | |
| | | 34 | | /// <summary> |
| | | 35 | | /// Advance pure 2D and pure 3D runtime paths without cross-dimensional contacts. |
| | | 36 | | /// </summary> |
| | | 37 | | Both = TwoD | ThreeD, |
| | | 38 | | |
| | | 39 | | /// <summary> |
| | | 40 | | /// Advance pure 2D, pure 3D, and explicit mixed 2D/3D collision paths. |
| | | 41 | | /// </summary> |
| | | 42 | | Mixed = Both | (1 << 2) |
| | | 43 | | } |
| | | 44 | | |
| | | 45 | | internal static class PhysicsRuntimeModeSupport |
| | | 46 | | { |
| | | 47 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | | 48 | | internal static bool IsValid(this PhysicsRuntimeMode mode) |
| | | 49 | | { |
| | 3455 | 50 | | return mode == PhysicsRuntimeMode.TwoD |
| | 3455 | 51 | | || mode == PhysicsRuntimeMode.ThreeD |
| | 3455 | 52 | | || mode == PhysicsRuntimeMode.Both |
| | 3455 | 53 | | || mode == PhysicsRuntimeMode.Mixed; |
| | | 54 | | } |
| | | 55 | | |
| | | 56 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | | 57 | | internal static bool Runs2D(this PhysicsRuntimeMode mode) |
| | | 58 | | { |
| | 7167 | 59 | | return (mode & PhysicsRuntimeMode.TwoD) != 0; |
| | | 60 | | } |
| | | 61 | | |
| | | 62 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | | 63 | | internal static bool Runs3D(this PhysicsRuntimeMode mode) |
| | | 64 | | { |
| | 7167 | 65 | | return (mode & PhysicsRuntimeMode.ThreeD) != 0; |
| | | 66 | | } |
| | | 67 | | |
| | | 68 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | | 69 | | internal static bool RunsMixedContacts(this PhysicsRuntimeMode mode) |
| | | 70 | | { |
| | 31816 | 71 | | return mode == PhysicsRuntimeMode.Mixed; |
| | | 72 | | } |
| | | 73 | | } |