< 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: 42
Uncovered lines: 0
Coverable lines: 42
Total lines: 108
Line coverage: 100%
Branch coverage
100%
Covered branches: 18
Total branches: 18
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%1616100%
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 System;
 9using System.Runtime.CompilerServices;
 10using FixedMathSharp;
 11
 12namespace Gravitas.Colliders;
 13
 14/// <summary>
 15/// Captures the 3D pose and shape inputs used to track changes to committed geometry.
 16/// </summary>
 17internal readonly struct ColliderShapeSnapshot : IEquatable<ColliderShapeSnapshot>
 18{
 19    public ColliderShapeSnapshot(
 20        Vector3d center,
 21        FixedQuaternion rotation,
 22        Vector3d ownerScale,
 23        Vector3d partScale,
 24        Vector3d localOffset,
 25        Vector3d size,
 26        Fixed64 radius,
 27        Vector3d? poseOrigin = null,
 28        FixedQuaternion? placementRotation = null)
 29    {
 46772630        Center = center;
 46772631        Rotation = rotation;
 46772632        OwnerScale = ownerScale;
 46772633        PartScale = partScale;
 46772634        LocalOffset = localOffset;
 46772635        Size = size;
 46772636        Radius = radius;
 46772637        PoseOrigin = poseOrigin ?? center;
 46772638        PlacementRotation = placementRotation ?? rotation;
 46772639    }
 40
 41    public Vector3d Center { get; }
 42
 43    public FixedQuaternion Rotation { get; }
 44
 45    public Vector3d OwnerScale { get; }
 46
 47    public Vector3d PartScale { get; }
 48
 49    public Vector3d LocalOffset { get; }
 50
 51    public Vector3d Size { get; }
 52
 53    public Fixed64 Radius { get; }
 54
 55    // Geometry retains placement before center rounding; public Center remains a scalar summary.
 56    internal Vector3d PoseOrigin { get; }
 57    internal FixedQuaternion PlacementRotation { get; }
 58
 59    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 60    public bool Equals(ColliderShapeSnapshot other) =>
 34827761        Center == other.Center
 34827762        && Rotation == other.Rotation
 34827763        && OwnerScale == other.OwnerScale
 34827764        && PartScale == other.PartScale
 34827765        && LocalOffset == other.LocalOffset
 34827766        && Size == other.Size
 34827767        && Radius == other.Radius
 34827768        && PoseOrigin == other.PoseOrigin
 34827769        && PlacementRotation == other.PlacementRotation;
 70
 71    public override bool Equals(object? obj) =>
 472        obj is ColliderShapeSnapshot other && Equals(other);
 73
 74    public override int GetHashCode()
 75    {
 76        unchecked
 77        {
 278            int hash = 17;
 279            hash = Mix(hash, Center);
 280            hash = (hash * 31) + Rotation.X.GetHashCode();
 281            hash = (hash * 31) + Rotation.Y.GetHashCode();
 282            hash = (hash * 31) + Rotation.Z.GetHashCode();
 283            hash = (hash * 31) + Rotation.W.GetHashCode();
 284            hash = Mix(hash, OwnerScale);
 285            hash = Mix(hash, PartScale);
 286            hash = Mix(hash, LocalOffset);
 287            hash = Mix(hash, Size);
 288            hash = (hash * 31) + Radius.GetHashCode();
 289            hash = Mix(hash, PoseOrigin);
 290            hash = (hash * 31) + PlacementRotation.X.GetHashCode();
 291            hash = (hash * 31) + PlacementRotation.Y.GetHashCode();
 292            hash = (hash * 31) + PlacementRotation.Z.GetHashCode();
 293            hash = (hash * 31) + PlacementRotation.W.GetHashCode();
 294            return hash;
 95        }
 96    }
 97
 98    private static int Mix(int hash, Vector3d value)
 99    {
 12100        hash = (hash * 31) + value.X.GetHashCode();
 12101        hash = (hash * 31) + value.Y.GetHashCode();
 12102        return (hash * 31) + value.Z.GetHashCode();
 103    }
 104
 1105    public static bool operator ==(ColliderShapeSnapshot left, ColliderShapeSnapshot right) => left.Equals(right);
 106
 2107    public static bool operator !=(ColliderShapeSnapshot left, ColliderShapeSnapshot right) => !left.Equals(right);
 108}