< 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 System.Runtime.CompilerServices;
 9using FixedMathSharp;
 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    {
 1641731        if (Count == 0)
 1179332            _contact0 = contact;
 33        else
 462434            _contact1 = contact;
 35
 1641736        Count++;
 1641737    }
 38
 39    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 6894040    public SolverContact2D GetContact(int index) => index == 0 ? _contact0 : _contact1;
 41
 42    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 2692643    public Fixed64 GetNormalImpulse(int index) => index == 0 ? _normalImpulse0 : _normalImpulse1;
 44
 45    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 46    public ContactNormalImpulseResult2D GetNormalResult(int index) =>
 2692947        index == 0 ? _normalResult0 : _normalResult1;
 48
 49    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 1346250    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    {
 1640358        if (index == 0)
 59        {
 1178260            _normalImpulse0 = impulse;
 1178261            _normalResult0 = normalResult;
 1178262            return;
 63        }
 64
 462165        _normalImpulse1 = impulse;
 462166        _normalResult1 = normalResult;
 462167    }
 68
 69    public void SetTangentImpulse(int index, Fixed64 impulse)
 70    {
 1346271        if (index == 0)
 72        {
 952173            _tangentImpulse0 = impulse;
 952174            return;
 75        }
 76
 394177        _tangentImpulse1 = impulse;
 394178    }
 79}