| | | 1 | | //======================================================================= |
| | | 2 | | // BodyMotionType.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 SwiftCollections; |
| | | 9 | | using System.Runtime.CompilerServices; |
| | | 10 | | |
| | | 11 | | namespace Gravitas; |
| | | 12 | | |
| | | 13 | | /// <summary> |
| | | 14 | | /// Selects whether a body is solver controlled, host controlled, or immobile. |
| | | 15 | | /// </summary> |
| | | 16 | | public enum BodyMotionType : byte |
| | | 17 | | { |
| | | 18 | | /// <summary> |
| | | 19 | | /// The solver controls the body subject to its frozen degrees of freedom. |
| | | 20 | | /// </summary> |
| | | 21 | | Dynamic = 0, |
| | | 22 | | |
| | | 23 | | /// <summary> |
| | | 24 | | /// The host controls the body while the solver treats it as infinite mass. |
| | | 25 | | /// </summary> |
| | | 26 | | Kinematic = 1, |
| | | 27 | | |
| | | 28 | | /// <summary> |
| | | 29 | | /// The body is excluded from per-frame motion and treated as infinite mass. |
| | | 30 | | /// </summary> |
| | | 31 | | Static = 2 |
| | | 32 | | } |
| | | 33 | | |
| | | 34 | | internal static class BodyMotionTypeSupport |
| | | 35 | | { |
| | | 36 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | | 37 | | internal static bool IsValid(this BodyMotionType motionType) => |
| | 10257 | 38 | | (byte)motionType <= (byte)BodyMotionType.Static; |
| | | 39 | | |
| | | 40 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | | 41 | | internal static void ThrowIfInvalid(this BodyMotionType motionType, string parameterName) |
| | | 42 | | { |
| | 10257 | 43 | | SwiftThrowHelper.ThrowIfArgumentOutOfRange( |
| | 10257 | 44 | | !motionType.IsValid(), |
| | 10257 | 45 | | (int)motionType, |
| | 10257 | 46 | | parameterName, |
| | 10257 | 47 | | "Body motion type must be Dynamic, Kinematic, or Static."); |
| | 10253 | 48 | | } |
| | | 49 | | } |