< 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    {
 164537        IsClosing = isClosing;
 164538        HasAppliedImpulse = hasAppliedImpulse;
 164539        FirstLinearVelocityDelta = firstLinearVelocityDelta;
 164540        FirstAngularVelocityDelta = firstAngularVelocityDelta;
 164541        SecondLinearVelocityDelta = secondLinearVelocityDelta;
 164542        SecondAngularVelocityDelta = secondAngularVelocityDelta;
 164543        _normalVelocity = normalVelocity;
 164544        _appliedImpulse = appliedImpulse;
 164545        _accumulatedImpulse = accumulatedImpulse;
 164546        _projectionFlags = (byte)(
 164547            (hasNormalVelocity ? 1 : 0)
 164548            | (hasAppliedImpulseProjection ? 2 : 0)
 164549            | (hasAccumulatedImpulse ? 4 : 0));
 164550    }
 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    {
 161966        value = _normalVelocity;
 161967        return (_projectionFlags & 1) != 0;
 68    }
 69
 70    internal bool TryGetAppliedImpulse(out Fixed64 value)
 71    {
 145972        value = _appliedImpulse;
 145973        return (_projectionFlags & 2) != 0;
 74    }
 75
 76    internal bool TryGetAccumulatedImpulse(out Fixed64 value)
 77    {
 145878        value = _accumulatedImpulse;
 145879        return (_projectionFlags & 4) != 0;
 80    }
 81}