< Summary

Line coverage
100%
Covered lines: 80
Uncovered lines: 0
Coverable lines: 80
Total lines: 273
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
File 1: .cctor()100%11100%
File 1: .ctor(...)100%11100%
File 1: Default(...)100%11100%
File 2: ContributeReplayHash(...)100%11100%

File(s)

/home/runner/work/Gravitas/Gravitas/src/Gravitas/Settings/PhysicsEnvironment.cs

#LineLine coverage
 1//=======================================================================
 2// PhysicsEnvironment.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
 8using FixedMathSharp;
 9
 10namespace Gravitas;
 11
 12/// <summary>
 13/// Stores world-local physical environment values used by deterministic simulation.
 14/// </summary>
 15public sealed partial class PhysicsEnvironment
 16{
 17    /// <summary>
 18    /// Standard gravitational acceleration in world units per second squared.
 19    /// </summary>
 120    public static readonly Fixed64 DefaultGravity = (Fixed64)9.8f;
 21
 22    /// <summary>
 23    /// Standard air density used by drag calculations.
 24    /// </summary>
 125    public static readonly Fixed64 DefaultAirDensity = (Fixed64)1.225f;
 26
 27    /// <summary>
 28    /// Minimum speed treated as meaningful motion by the standard environment.
 29    /// </summary>
 130    public static readonly Fixed64 DefaultMinSpeed = (Fixed64)0.00001f;
 31
 32    /// <summary>
 33    /// Maximum linear or angular speed used by the standard environment.
 34    /// </summary>
 135    public static readonly Fixed64 DefaultMaxSpeed = (Fixed64)7f;
 36
 37    /// <summary>
 38    /// Maximum downward fall speed used by the standard environment.
 39    /// </summary>
 140    public static readonly Fixed64 DefaultMaxFallSpeed = DefaultGravity;
 41
 42    /// <summary>
 43    /// Speed threshold used when transitioning friction behavior in the standard environment.
 44    /// </summary>
 145    public static readonly Fixed64 DefaultFrictionTransitionSpeed = (Fixed64)0.2f;
 46
 47    /// <summary>
 48    /// Motion deceleration multiplier used by the standard environment.
 49    /// </summary>
 150    public static readonly Fixed64 DefaultDecelerationMultiplier = (Fixed64)10f;
 51
 52    /// <summary>
 53    /// Angular velocity damping factor used by the standard environment.
 54    /// </summary>
 155    public static readonly Fixed64 DefaultDampingFactor = (Fixed64)0.95f;
 56
 57    /// <summary>
 58    /// Frame-rate divisor used to derive the default maximum distance-based
 59    /// collision-culling score.
 60    /// </summary>
 161    public static readonly int DefaultCullDistanceFrameDivisor = 3;
 62
 63    /// <summary>
 64    /// Distance threshold whose square becomes the default fast-collision
 65    /// preservation threshold.
 66    /// </summary>
 167    public static readonly int DefaultCullFastDistance = 4;
 68
 69    /// <summary>
 70    /// Squared distance below which the standard environment preserves fast
 71    /// collision checks.
 72    /// </summary>
 173    public static readonly Fixed64 DefaultCullFastDistanceMax =
 174        Fixed64.One * DefaultCullFastDistance * (Fixed64.One * DefaultCullFastDistance);
 75
 76    /// <summary>
 77    /// Velocity step used by standard collision culling.
 78    /// </summary>
 179    public static readonly int DefaultCullVelocityStep = 2;
 80
 81    /// <summary>
 82    /// Maximum velocity-based collision-culling score used by the standard environment.
 83    /// </summary>
 184    public static readonly int DefaultCullVelocityMax = 4;
 85
 86    /// <summary>
 87    /// Frame-rate multiplier used to derive the default collision-culling time step.
 88    /// </summary>
 189    public static readonly int DefaultCullTimeStepFrameMultiplier = 3;
 90
 91    /// <summary>
 92    /// Frame-rate divisor used to derive the default maximum time-based
 93    /// collision-culling score.
 94    /// </summary>
 195    public static readonly int DefaultCullTimeMaxFrameDivisor = 5;
 96
 97    /// <summary>
 98    /// One pound is equal to this many Newtons.
 99    /// </summary>
 1100    public static readonly Fixed64 PoundToNewton = (Fixed64)4.44822162f;
 101
 102    /// <summary>
 103    /// One kilogram is equal to this many pounds.
 104    /// </summary>
 1105    public static readonly Fixed64 KilogramToPound = (Fixed64)2.20462262f;
 106
 107    /// <summary>
 108    /// Gets or sets gravitational acceleration in world units per second squared.
 109    /// </summary>
 110    public Fixed64 Gravity { get; set; }
 111
 112    /// <summary>
 113    /// Gets or sets air density used by drag calculations.
 114    /// </summary>
 115    public Fixed64 AirDensity { get; set; }
 116
 117    /// <summary>
 118    /// Gets or sets the minimum speed treated as meaningful motion.
 119    /// </summary>
 120    public Fixed64 MinSpeed { get; set; }
 121
 122    /// <summary>
 123    /// Gets or sets the maximum linear or angular speed.
 124    /// </summary>
 125    public Fixed64 MaxSpeed { get; set; }
 126
 127    /// <summary>
 128    /// Gets or sets the maximum downward fall speed.
 129    /// </summary>
 130    public Fixed64 MaxFallSpeed { get; set; }
 131
 132    /// <summary>
 133    /// Gets or sets the speed threshold used when transitioning friction behavior.
 134    /// </summary>
 135    public Fixed64 FrictionTransitionSpeed { get; set; }
 136
 137    /// <summary>
 138    /// Gets or sets the multiplier applied when decelerating motion.
 139    /// </summary>
 140    public Fixed64 DecelerationMultiplier { get; set; }
 141
 142    /// <summary>
 143    /// Gets or sets the damping factor applied to angular velocity.
 144    /// </summary>
 145    public Fixed64 DampingFactor { get; set; }
 146
 147    /// <summary>
 148    /// Gets or sets the maximum distance-based collision-culling score.
 149    /// </summary>
 150    public int CullDistanceMax { get; set; }
 151
 152    /// <summary>
 153    /// Gets or sets the squared distance below which fast collision checks are preserved.
 154    /// </summary>
 155    public Fixed64 CullFastDistanceMax { get; set; }
 156
 157    /// <summary>
 158    /// Gets or sets the velocity step used by collision culling.
 159    /// </summary>
 160    public int CullVelocityStep { get; set; }
 161
 162    /// <summary>
 163    /// Gets or sets the maximum velocity-based collision-culling score.
 164    /// </summary>
 165    public int CullVelocityMax { get; set; }
 166
 167    /// <summary>
 168    /// Gets or sets the frame-count step used by collision culling.
 169    /// </summary>
 170    public int CullTimeStep { get; set; }
 171
 172    /// <summary>
 173    /// Gets or sets the maximum time-based collision-culling score.
 174    /// </summary>
 175    public int CullTimeMax { get; set; }
 176
 177    /// <summary>
 178    /// Initializes a new environment with explicit physical and culling values.
 179    /// </summary>
 5084180    public PhysicsEnvironment(
 5084181        Fixed64 gravity,
 5084182        Fixed64 airDensity,
 5084183        Fixed64 minSpeed,
 5084184        Fixed64 maxSpeed,
 5084185        Fixed64 maxFallSpeed,
 5084186        Fixed64 frictionTransitionSpeed,
 5084187        Fixed64 decelerationMultiplier,
 5084188        Fixed64 dampingFactor,
 5084189        int cullDistanceMax,
 5084190        Fixed64 cullFastDistanceMax,
 5084191        int cullVelocityStep,
 5084192        int cullVelocityMax,
 5084193        int cullTimeStep,
 5084194        int cullTimeMax)
 195    {
 5084196        Gravity = gravity;
 5084197        AirDensity = airDensity;
 5084198        MinSpeed = minSpeed;
 5084199        MaxSpeed = maxSpeed;
 5084200        MaxFallSpeed = maxFallSpeed;
 5084201        FrictionTransitionSpeed = frictionTransitionSpeed;
 5084202        DecelerationMultiplier = decelerationMultiplier;
 5084203        DampingFactor = dampingFactor;
 5084204        CullDistanceMax = cullDistanceMax;
 5084205        CullFastDistanceMax = cullFastDistanceMax;
 5084206        CullVelocityStep = cullVelocityStep;
 5084207        CullVelocityMax = cullVelocityMax;
 5084208        CullTimeStep = cullTimeStep;
 5084209        CullTimeMax = cullTimeMax;
 5084210    }
 211
 212    /// <summary>
 213    /// Creates environment values for the standard Gravitas runtime defaults.
 214    /// </summary>
 215    /// <param name="frameRate">Frame rate used to initialize frame-derived culling thresholds.</param>
 216    /// <returns>A new environment instance.</returns>
 217    public static PhysicsEnvironment Default(int frameRate = PhysicsSettings.DefaultFrameRate)
 218    {
 5085219        PhysicsSettings.ThrowIfInvalidFrameRate(frameRate);
 220
 5084221        return new PhysicsEnvironment(
 5084222            gravity: DefaultGravity,
 5084223            airDensity: DefaultAirDensity,
 5084224            minSpeed: DefaultMinSpeed,
 5084225            maxSpeed: DefaultMaxSpeed,
 5084226            maxFallSpeed: DefaultMaxFallSpeed,
 5084227            frictionTransitionSpeed: DefaultFrictionTransitionSpeed,
 5084228            decelerationMultiplier: DefaultDecelerationMultiplier,
 5084229            dampingFactor: DefaultDampingFactor,
 5084230            cullDistanceMax: frameRate / DefaultCullDistanceFrameDivisor,
 5084231            cullFastDistanceMax: DefaultCullFastDistanceMax,
 5084232            cullVelocityStep: DefaultCullVelocityStep,
 5084233            cullVelocityMax: DefaultCullVelocityMax,
 5084234            cullTimeStep: frameRate * DefaultCullTimeStepFrameMultiplier,
 5084235            cullTimeMax: frameRate / DefaultCullTimeMaxFrameDivisor);
 236    }
 237}

/home/runner/work/Gravitas/Gravitas/src/Gravitas/Settings/PhysicsEnvironment.ReplayHash.cs

#LineLine coverage
 1//=======================================================================
 2// PhysicsEnvironment.ReplayHash.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
 8using Chronicler;
 9using FixedMathSharp.Chronicler;
 10
 11namespace Gravitas;
 12
 13/// <content>
 14/// Contributes physical environment values to deterministic replay hashes.
 15/// </content>
 16public sealed partial class PhysicsEnvironment
 17{
 18    internal void ContributeReplayHash(ref ChronicleHashWriter writer)
 19    {
 99320        writer.WriteSection("environment", 1);
 99321        writer.WriteFixed64(Gravity);
 99322        writer.WriteFixed64(AirDensity);
 99323        writer.WriteFixed64(MinSpeed);
 99324        writer.WriteFixed64(MaxSpeed);
 99325        writer.WriteFixed64(MaxFallSpeed);
 99326        writer.WriteFixed64(FrictionTransitionSpeed);
 99327        writer.WriteFixed64(DecelerationMultiplier);
 99328        writer.WriteFixed64(DampingFactor);
 99329        writer.WriteInt32(CullDistanceMax);
 99330        writer.WriteFixed64(CullFastDistanceMax);
 99331        writer.WriteInt32(CullVelocityStep);
 99332        writer.WriteInt32(CullVelocityMax);
 99333        writer.WriteInt32(CullTimeStep);
 99334        writer.WriteInt32(CullTimeMax);
 99335    }
 36}