< Summary

Information
Class: Gravitas.CollisionHandling.SolverContactBuffer2D
Assembly: Gravitas
File(s): /home/runner/work/Gravitas/Gravitas/src/Gravitas/CollisionHandling/Response/2D/SolverContactBuffer2D.cs
Line coverage
100%
Covered lines: 21
Uncovered lines: 0
Coverable lines: 21
Total lines: 79
Line coverage: 100%
Branch coverage
100%
Covered branches: 14
Total branches: 14
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
Add(...)100%22100%
GetContact(...)100%22100%
GetNormalImpulse(...)100%22100%
GetNormalResult(...)100%22100%
GetTangentImpulse(...)100%22100%
SetNormalImpulse(...)100%22100%
SetTangentImpulse(...)100%22100%

File(s)

/home/runner/work/Gravitas/Gravitas/src/Gravitas/CollisionHandling/Response/2D/SolverContactBuffer2D.cs

#LineLine coverage
 1//=======================================================================
 2// SolverContactBuffer2D.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;
 9using System.Runtime.CompilerServices;
 10
 11namespace Gravitas.CollisionHandling;
 12
 13/// <summary>
 14/// Fixed-capacity pure 2D solver contact buffer.
 15/// </summary>
 16internal struct SolverContactBuffer2D
 17{
 18    private SolverContact2D _contact0;
 19    private SolverContact2D _contact1;
 20    private Fixed64 _normalImpulse0;
 21    private Fixed64 _normalImpulse1;
 22    private ContactNormalImpulseResult2D _normalResult0;
 23    private ContactNormalImpulseResult2D _normalResult1;
 24    private Fixed64 _tangentImpulse0;
 25    private Fixed64 _tangentImpulse1;
 26
 27    public int Count { get; private set; }
 28
 29    public void Add(SolverContact2D contact)
 30    {
 101131        if (Count == 0)
 99132            _contact0 = contact;
 33        else
 2034            _contact1 = contact;
 35
 101136        Count++;
 101137    }
 38
 39    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 510740    public SolverContact2D GetContact(int index) => index == 0 ? _contact0 : _contact1;
 41
 42    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 200843    public Fixed64 GetNormalImpulse(int index) => index == 0 ? _normalImpulse0 : _normalImpulse1;
 44
 45    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 46    public ContactNormalImpulseResult2D GetNormalResult(int index) =>
 201147        index == 0 ? _normalResult0 : _normalResult1;
 48
 49    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 100350    public Fixed64 GetTangentImpulse(int index) => index == 0 ? _tangentImpulse0 : _tangentImpulse1;
 51
 52    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 53    public void SetNormalImpulse(
 54        int index,
 55        Fixed64 impulse,
 56        ContactNormalImpulseResult2D normalResult)
 57    {
 100658        if (index == 0)
 59        {
 98760            _normalImpulse0 = impulse;
 98761            _normalResult0 = normalResult;
 98762            return;
 63        }
 64
 1965        _normalImpulse1 = impulse;
 1966        _normalResult1 = normalResult;
 1967    }
 68
 69    public void SetTangentImpulse(int index, Fixed64 impulse)
 70    {
 100371        if (index == 0)
 72        {
 98473            _tangentImpulse0 = impulse;
 98474            return;
 75        }
 76
 1977        _tangentImpulse1 = impulse;
 1978    }
 79}