< Summary

Information
Class: Gravitas.Constraints.JointMotor3D
Assembly: Gravitas
File(s): /home/runner/work/Gravitas/Gravitas/src/Gravitas/Constraints/3D/JointMotor3D.cs
Line coverage
100%
Covered lines: 22
Uncovered lines: 0
Coverable lines: 22
Total lines: 80
Line coverage: 100%
Branch coverage
100%
Covered branches: 2
Total branches: 2
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
get_Disabled()100%11100%
get_IsEnabled()100%22100%
Validate()100%11100%

File(s)

/home/runner/work/Gravitas/Gravitas/src/Gravitas/Constraints/3D/JointMotor3D.cs

#LineLine coverage
 1//=======================================================================
 2// JointMotor3D.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.Constraints;
 11
 12/// <summary>
 13/// Deterministic angular target-drive payload for a 3D joint.
 14/// </summary>
 15public readonly struct JointMotor3D
 16{
 17    /// <summary>
 18    /// Creates an angular motor payload.
 19    /// </summary>
 20    public JointMotor3D(
 21        FixedQuaternion targetLocalRotation,
 22        Fixed64 angularDriveStrength,
 23        Fixed64 angularDriveDamping,
 24        Fixed64 maximumMotorImpulse)
 25    {
 1826        TargetLocalRotation = targetLocalRotation.Normalized;
 1827        AngularDriveStrength = angularDriveStrength;
 1828        AngularDriveDamping = angularDriveDamping;
 1829        MaximumMotorImpulse = maximumMotorImpulse;
 1830        Validate();
 1831    }
 32
 33    /// <summary>
 34    /// Gets a disabled motor payload.
 35    /// </summary>
 30236    public static JointMotor3D Disabled => default;
 37
 38    /// <summary>
 39    /// Gets the desired B-relative-to-A joint-space rotation.
 40    /// </summary>
 41    public FixedQuaternion TargetLocalRotation { get; }
 42
 43    /// <summary>
 44    /// Gets the deterministic spring-like angular drive strength.
 45    /// </summary>
 46    public Fixed64 AngularDriveStrength { get; }
 47
 48    /// <summary>
 49    /// Gets angular damping applied against relative angular velocity.
 50    /// </summary>
 51    public Fixed64 AngularDriveDamping { get; }
 52
 53    /// <summary>
 54    /// Gets the maximum absolute impulse this motor may apply per row and iteration.
 55    /// </summary>
 56    public Fixed64 MaximumMotorImpulse { get; }
 57
 58    /// <summary>
 59    /// Gets whether this motor can emit solver rows.
 60    /// </summary>
 61    public bool IsEnabled =>
 4970362        AngularDriveStrength > Fixed64.Zero
 4970363        && MaximumMotorImpulse > Fixed64.Zero;
 64
 65    internal void Validate()
 66    {
 39467        SwiftThrowHelper.ThrowIfArgument(
 39468            AngularDriveStrength < Fixed64.Zero,
 39469            nameof(AngularDriveStrength),
 39470            "Angular drive strength cannot be negative.");
 39471        SwiftThrowHelper.ThrowIfArgument(
 39472            AngularDriveDamping < Fixed64.Zero,
 39473            nameof(AngularDriveDamping),
 39474            "Angular drive damping cannot be negative.");
 39475        SwiftThrowHelper.ThrowIfArgument(
 39476            MaximumMotorImpulse < Fixed64.Zero,
 39477            nameof(MaximumMotorImpulse),
 39478            "Maximum motor impulse cannot be negative.");
 39479    }
 80}