< 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: 101
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
 14
 15
 16
 17/// <summary>
 18/// Describes exact point, edge, face, or volume contact between two cell prisms.
 19/// </summary>
 20public readonly struct VoxelContactManifold
 21{
 22    /// <summary>The source cell identity.</summary>
 23    public WorldVoxelIndex Source { get; }
 24
 25    /// <summary>The target cell identity.</summary>
 26    public WorldVoxelIndex Target { get; }
 27
 28    /// <summary>The target-center displacement from the source center.</summary>
 29    public Vector3d SourceToTarget { get; }
 30
 31    /// <summary>The exact contact classification.</summary>
 32    public VoxelContactKind Kind { get; }
 33
 34    /// <summary>The face orientation when <see cref="Kind"/> is <see cref="VoxelContactKind.Face"/>.</summary>
 35    public VoxelContactFaceKind FaceKind { get; }
 36
 37    /// <summary>The lower bound of the shared vertical interval or horizontal face plane.</summary>
 38    public Fixed64 VerticalMin { get; }
 39
 40    /// <summary>The upper bound of the shared vertical interval or horizontal face plane.</summary>
 41    public Fixed64 VerticalMax { get; }
 42
 43    /// <summary>The first endpoint of a vertical face's exact XZ contact segment.</summary>
 44    public Vector2d HorizontalSegmentStart { get; }
 45
 46    /// <summary>The second endpoint of a vertical face's exact XZ contact segment.</summary>
 47    public Vector2d HorizontalSegmentEnd { get; }
 48
 49    /// <summary>The exact overlap polygon for a horizontal face or volume overlap.</summary>
 50    public GridConvexPolygon2d HorizontalPolygon { get; }
 51
 52    /// <summary>The face area, or horizontal overlap area for a volume overlap.</summary>
 53    public Fixed64 CheckedArea { get; }
 54
 55    /// <summary>Whether <see cref="CheckedArea"/> is representable without saturation.</summary>
 56    public bool IsAreaRepresentable { get; }
 57
 58    /// <summary>Whether this manifold can be considered as an automatic portal before agent clearance checks.</summary>
 59    public bool IsPositiveAreaFace =>
 246860        Kind == VoxelContactKind.Face
 246861        && IsAreaRepresentable
 246862        && CheckedArea > Fixed64.Zero;
 63
 64    /// <summary>The exact width of a vertical face contact segment.</summary>
 665    public Fixed64 VerticalFaceWidth => FaceKind == VoxelContactFaceKind.Vertical
 666        ? Vector2d.Distance(HorizontalSegmentStart, HorizontalSegmentEnd)
 667        : Fixed64.Zero;
 68
 69    /// <summary>The exact height of a vertical face contact interval.</summary>
 670    public Fixed64 VerticalFaceHeight => FaceKind == VoxelContactFaceKind.Vertical
 671        ? VerticalMax - VerticalMin
 672        : Fixed64.Zero;
 73
 74    internal VoxelContactManifold(
 75        WorldVoxelIndex source,
 76        WorldVoxelIndex target,
 77        Vector3d sourceToTarget,
 78        VoxelContactKind kind,
 79        VoxelContactFaceKind faceKind,
 80        Fixed64 verticalMin,
 81        Fixed64 verticalMax,
 82        Vector2d horizontalSegmentStart,
 83        Vector2d horizontalSegmentEnd,
 84        GridConvexPolygon2d horizontalPolygon,
 85        Fixed64 checkedArea,
 86        bool isAreaRepresentable)
 87    {
 266288        Source = source;
 266289        Target = target;
 266290        SourceToTarget = sourceToTarget;
 266291        Kind = kind;
 266292        FaceKind = faceKind;
 266293        VerticalMin = verticalMin;
 266294        VerticalMax = verticalMax;
 266295        HorizontalSegmentStart = horizontalSegmentStart;
 266296        HorizontalSegmentEnd = horizontalSegmentEnd;
 266297        HorizontalPolygon = horizontalPolygon;
 266298        CheckedArea = checkedArea;
 266299        IsAreaRepresentable = isAreaRepresentable;
 2662100    }
 101}