< Summary

Information
Class: GridForge.Grids.Topology.VoxelContactManifold
Assembly: GridForge
File(s): /home/runner/work/GridForge/GridForge/src/GridForge/Grids/Topology/VoxelContactManifold.cs
Line coverage
100%
Covered lines: 22
Uncovered lines: 0
Coverable lines: 22
Total lines: 127
Line coverage: 100%
Branch coverage
100%
Covered branches: 8
Total branches: 8
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_IsPositiveAreaFace()100%44100%
get_VerticalFaceWidth()100%22100%
get_VerticalFaceHeight()100%22100%
.ctor(...)100%11100%

File(s)

/home/runner/work/GridForge/GridForge/src/GridForge/Grids/Topology/VoxelContactManifold.cs

#LineLine coverage
 1//=======================================================================
 2// VoxelContactManifold.cs
 3//=======================================================================
 4// MIT License, Copyright (c) 2024-present David Oravsky (mrdav30)
 5// See LICENSE file in the project root for full license information.
 6//=======================================================================
 7
 8using FixedMathSharp;
 9using GridForge.Spatial;
 10
 11namespace GridForge.Grids.Topology;
 12
 13/// <summary>
 14/// Classifies the exact shared geometry of two closed cell prisms.
 15/// </summary>
 16public enum VoxelContactKind : byte
 17{
 18    /// <summary>The prisms do not intersect.</summary>
 19    Separated,
 20    /// <summary>The prisms share one point.</summary>
 21    Point,
 22    /// <summary>The prisms share a positive-length line.</summary>
 23    Edge,
 24    /// <summary>The prisms share a positive-area face.</summary>
 25    Face,
 26    /// <summary>The prism interiors overlap in three dimensions.</summary>
 27    VolumeOverlap
 28}
 29
 30/// <summary>
 31/// Identifies the world-plane orientation of a face contact.
 32/// </summary>
 33public enum VoxelContactFaceKind : byte
 34{
 35    /// <summary>The manifold is not a face.</summary>
 36    None,
 37    /// <summary>A horizontal footprint segment extruded through a vertical interval.</summary>
 38    Vertical,
 39    /// <summary>A convex XZ polygon on a shared Y plane.</summary>
 40    Horizontal
 41}
 42
 43/// <summary>
 44/// Describes exact point, edge, face, or volume contact between two cell prisms.
 45/// </summary>
 46public readonly struct VoxelContactManifold
 47{
 48    /// <summary>The source cell identity.</summary>
 49    public WorldVoxelIndex Source { get; }
 50
 51    /// <summary>The target cell identity.</summary>
 52    public WorldVoxelIndex Target { get; }
 53
 54    /// <summary>The target-center displacement from the source center.</summary>
 55    public Vector3d SourceToTarget { get; }
 56
 57    /// <summary>The exact contact classification.</summary>
 58    public VoxelContactKind Kind { get; }
 59
 60    /// <summary>The face orientation when <see cref="Kind"/> is <see cref="VoxelContactKind.Face"/>.</summary>
 61    public VoxelContactFaceKind FaceKind { get; }
 62
 63    /// <summary>The lower bound of the shared vertical interval or horizontal face plane.</summary>
 64    public Fixed64 VerticalMin { get; }
 65
 66    /// <summary>The upper bound of the shared vertical interval or horizontal face plane.</summary>
 67    public Fixed64 VerticalMax { get; }
 68
 69    /// <summary>The first endpoint of a vertical face's exact XZ contact segment.</summary>
 70    public Vector2d HorizontalSegmentStart { get; }
 71
 72    /// <summary>The second endpoint of a vertical face's exact XZ contact segment.</summary>
 73    public Vector2d HorizontalSegmentEnd { get; }
 74
 75    /// <summary>The exact overlap polygon for a horizontal face or volume overlap.</summary>
 76    public GridConvexPolygon2d HorizontalPolygon { get; }
 77
 78    /// <summary>The face area, or horizontal overlap area for a volume overlap.</summary>
 79    public Fixed64 CheckedArea { get; }
 80
 81    /// <summary>Whether <see cref="CheckedArea"/> is representable without saturation.</summary>
 82    public bool IsAreaRepresentable { get; }
 83
 84    /// <summary>Whether this manifold can be considered as an automatic portal before agent clearance checks.</summary>
 85    public bool IsPositiveAreaFace =>
 245686        Kind == VoxelContactKind.Face
 245687        && IsAreaRepresentable
 245688        && CheckedArea > Fixed64.Zero;
 89
 90    /// <summary>The exact width of a vertical face contact segment.</summary>
 691    public Fixed64 VerticalFaceWidth => FaceKind == VoxelContactFaceKind.Vertical
 692        ? Vector2d.Distance(HorizontalSegmentStart, HorizontalSegmentEnd)
 693        : Fixed64.Zero;
 94
 95    /// <summary>The exact height of a vertical face contact interval.</summary>
 696    public Fixed64 VerticalFaceHeight => FaceKind == VoxelContactFaceKind.Vertical
 697        ? VerticalMax - VerticalMin
 698        : Fixed64.Zero;
 99
 100    internal VoxelContactManifold(
 101        WorldVoxelIndex source,
 102        WorldVoxelIndex target,
 103        Vector3d sourceToTarget,
 104        VoxelContactKind kind,
 105        VoxelContactFaceKind faceKind,
 106        Fixed64 verticalMin,
 107        Fixed64 verticalMax,
 108        Vector2d horizontalSegmentStart,
 109        Vector2d horizontalSegmentEnd,
 110        GridConvexPolygon2d horizontalPolygon,
 111        Fixed64 checkedArea,
 112        bool isAreaRepresentable)
 113    {
 2645114        Source = source;
 2645115        Target = target;
 2645116        SourceToTarget = sourceToTarget;
 2645117        Kind = kind;
 2645118        FaceKind = faceKind;
 2645119        VerticalMin = verticalMin;
 2645120        VerticalMax = verticalMax;
 2645121        HorizontalSegmentStart = horizontalSegmentStart;
 2645122        HorizontalSegmentEnd = horizontalSegmentEnd;
 2645123        HorizontalPolygon = horizontalPolygon;
 2645124        CheckedArea = checkedArea;
 2645125        IsAreaRepresentable = isAreaRepresentable;
 2645126    }
 127}