< Summary

Information
Class: Gravitas.Colliders.ColliderShapeSnapshot
Assembly: Gravitas
File(s): /home/runner/work/Gravitas/Gravitas/src/Gravitas/Colliders/Definitions/ColliderShapeSnapshot.cs
Line coverage
100%
Covered lines: 33
Uncovered lines: 0
Coverable lines: 33
Total lines: 90
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
.ctor(...)100%11100%
Equals(...)100%1212100%
Equals(...)100%22100%
GetHashCode()100%11100%
Mix(...)100%11100%
op_Equality(...)100%11100%
op_Inequality(...)100%11100%

File(s)

/home/runner/work/Gravitas/Gravitas/src/Gravitas/Colliders/Definitions/ColliderShapeSnapshot.cs

#LineLine coverage
 1//=======================================================================
 2// ColliderShapeSnapshot.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;
 10using System.Runtime.CompilerServices;
 11
 12namespace Gravitas.Colliders;
 13
 14internal readonly struct ColliderShapeSnapshot : IEquatable<ColliderShapeSnapshot>
 15{
 16    public ColliderShapeSnapshot(
 17        Vector3d center,
 18        FixedQuaternion rotation,
 19        Vector3d ownerScale,
 20        Vector3d partScale,
 21        Vector3d localOffset,
 22        Vector3d size,
 23        Fixed64 radius)
 24    {
 7511525        Center = center;
 7511526        Rotation = rotation;
 7511527        OwnerScale = ownerScale;
 7511528        PartScale = partScale;
 7511529        LocalOffset = localOffset;
 7511530        Size = size;
 7511531        Radius = radius;
 7511532    }
 33
 34    public Vector3d Center { get; }
 35
 36    public FixedQuaternion Rotation { get; }
 37
 38    public Vector3d OwnerScale { get; }
 39
 40    public Vector3d PartScale { get; }
 41
 42    public Vector3d LocalOffset { get; }
 43
 44    public Vector3d Size { get; }
 45
 46    public Fixed64 Radius { get; }
 47
 48    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 49    public bool Equals(ColliderShapeSnapshot other) =>
 6206250        Center == other.Center
 6206251        && Rotation == other.Rotation
 6206252        && OwnerScale == other.OwnerScale
 6206253        && PartScale == other.PartScale
 6206254        && LocalOffset == other.LocalOffset
 6206255        && Size == other.Size
 6206256        && Radius == other.Radius;
 57
 58    public override bool Equals(object? obj) =>
 459        obj is ColliderShapeSnapshot other && Equals(other);
 60
 61    public override int GetHashCode()
 62    {
 63        unchecked
 64        {
 265            int hash = 17;
 266            hash = Mix(hash, Center);
 267            hash = (hash * 31) + Rotation.X.GetHashCode();
 268            hash = (hash * 31) + Rotation.Y.GetHashCode();
 269            hash = (hash * 31) + Rotation.Z.GetHashCode();
 270            hash = (hash * 31) + Rotation.W.GetHashCode();
 271            hash = Mix(hash, OwnerScale);
 272            hash = Mix(hash, PartScale);
 273            hash = Mix(hash, LocalOffset);
 274            hash = Mix(hash, Size);
 275            hash = (hash * 31) + Radius.GetHashCode();
 276            return hash;
 77        }
 78    }
 79
 80    private static int Mix(int hash, Vector3d value)
 81    {
 1082        hash = (hash * 31) + value.X.GetHashCode();
 1083        hash = (hash * 31) + value.Y.GetHashCode();
 1084        return (hash * 31) + value.Z.GetHashCode();
 85    }
 86
 187    public static bool operator ==(ColliderShapeSnapshot left, ColliderShapeSnapshot right) => left.Equals(right);
 88
 289    public static bool operator !=(ColliderShapeSnapshot left, ColliderShapeSnapshot right) => !left.Equals(right);
 90}