< Summary

Information
Class: Gravitas.CollisionHandling.ExactNormalResponse3D
Assembly: Gravitas
File(s): /home/runner/work/Gravitas/Gravitas/src/Gravitas/CollisionHandling/Response/Exact/ExactNormalResponse3D.cs
Line coverage
100%
Covered lines: 20
Uncovered lines: 0
Coverable lines: 20
Total lines: 81
Line coverage: 100%
Branch coverage
100%
Covered branches: 4
Total branches: 4
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%44100%
TryGetNormalVelocity(...)100%11100%
TryGetAppliedImpulse(...)100%11100%
TryGetAccumulatedImpulse(...)100%11100%

File(s)

/home/runner/work/Gravitas/Gravitas/src/Gravitas/CollisionHandling/Response/Exact/ExactNormalResponse3D.cs

#LineLine coverage
 1//=======================================================================
 2// ExactNormalResponse3D.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.CollisionHandling;
 11
 12/// <summary>
 13/// Contains atomically materialized velocity deltas from an exact normal
 14/// response.
 15/// </summary>
 16internal readonly struct ExactNormalResponse3D
 17{
 18    private readonly Fixed64 _normalVelocity;
 19    private readonly Fixed64 _appliedImpulse;
 20    private readonly Fixed64 _accumulatedImpulse;
 21    private readonly byte _projectionFlags;
 22
 23    internal ExactNormalResponse3D(
 24        bool isClosing,
 25        bool hasAppliedImpulse,
 26        Vector3d firstLinearVelocityDelta,
 27        Vector3d firstAngularVelocityDelta,
 28        Vector3d secondLinearVelocityDelta,
 29        Vector3d secondAngularVelocityDelta,
 30        bool hasNormalVelocity,
 31        Fixed64 normalVelocity,
 32        bool hasAppliedImpulseProjection,
 33        Fixed64 appliedImpulse,
 34        bool hasAccumulatedImpulse,
 35        Fixed64 accumulatedImpulse)
 36    {
 1510437        IsClosing = isClosing;
 1510438        HasAppliedImpulse = hasAppliedImpulse;
 1510439        FirstLinearVelocityDelta = firstLinearVelocityDelta;
 1510440        FirstAngularVelocityDelta = firstAngularVelocityDelta;
 1510441        SecondLinearVelocityDelta = secondLinearVelocityDelta;
 1510442        SecondAngularVelocityDelta = secondAngularVelocityDelta;
 1510443        _normalVelocity = normalVelocity;
 1510444        _appliedImpulse = appliedImpulse;
 1510445        _accumulatedImpulse = accumulatedImpulse;
 1510446        _projectionFlags = (byte)(
 1510447            (hasNormalVelocity ? 1 : 0)
 1510448            | (hasAppliedImpulseProjection ? 2 : 0)
 1510449            | (hasAccumulatedImpulse ? 4 : 0));
 1510450    }
 51
 52    internal bool IsClosing { get; }
 53
 54    internal bool HasAppliedImpulse { get; }
 55
 56    internal Vector3d FirstLinearVelocityDelta { get; }
 57
 58    internal Vector3d FirstAngularVelocityDelta { get; }
 59
 60    internal Vector3d SecondLinearVelocityDelta { get; }
 61
 62    internal Vector3d SecondAngularVelocityDelta { get; }
 63
 64    internal bool TryGetNormalVelocity(out Fixed64 value)
 65    {
 1498566        value = _normalVelocity;
 1498567        return (_projectionFlags & 1) != 0;
 68    }
 69
 70    internal bool TryGetAppliedImpulse(out Fixed64 value)
 71    {
 1490872        value = _appliedImpulse;
 1490873        return (_projectionFlags & 2) != 0;
 74    }
 75
 76    internal bool TryGetAccumulatedImpulse(out Fixed64 value)
 77    {
 1491378        value = _accumulatedImpulse;
 1491379        return (_projectionFlags & 4) != 0;
 80    }
 81}