| | | 1 | | //======================================================================= |
| | | 2 | | // MeshJoinedSurfaceRegions.Member.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 | | |
| | | 8 | | using System; |
| | | 9 | | using FixedMathSharp; |
| | | 10 | | using FixedMathSharp.Geometry; |
| | | 11 | | using Gravitas.Colliders; |
| | | 12 | | using SwiftCollections; |
| | | 13 | | |
| | | 14 | | namespace Gravitas.CollisionHandling; |
| | | 15 | | |
| | | 16 | | /// <summary> |
| | | 17 | | /// Retains one mesh surface's geometry lifetime, admitted regions, and joined boundary spans. |
| | | 18 | | /// </summary> |
| | | 19 | | internal sealed class Member<TFrame> where TFrame : struct |
| | | 20 | | { |
| | | 21 | | internal LSMeshCollider Collider = null!; |
| | | 22 | | internal int Triangle, Owner, Offset; |
| | | 23 | | internal uint PreparedVersion; |
| | | 24 | | internal long PreparedLifetime; |
| | | 25 | | internal TFrame Frame; |
| | 943 | 26 | | internal readonly MeshSurfaceConnectivity Connectivity = new(); |
| | 943 | 27 | | internal MeshSurfaceBoundaryDomain Boundary = new(); |
| | 943 | 28 | | internal readonly SwiftList<int> Admitted = new(); |
| | 943 | 29 | | internal bool[] JoinedSpans = Array.Empty<bool>(); |
| | | 30 | | internal bool BoundaryTrusted; |
| | | 31 | | |
| | | 32 | | internal RationalSegmentInterval GetRetainedInterval(ref int span) |
| | | 33 | | { |
| | 10302 | 34 | | ReadOnlySpan<BoundarySpan3D> pieces = Boundary.Spans; |
| | 10302 | 35 | | var first = pieces[span]; |
| | | 36 | | // Classification cuts are not physical features. Only an actually |
| | | 37 | | // suppressed joined span can split a retained original edge. |
| | 10350 | 38 | | while (span + 1 < pieces.Length && pieces[span + 1].First == first.First && pieces[span + 1].Second == first.Sec |
| | 10398 | 39 | | && !JoinedSpans[span + 1]) span++; |
| | 10302 | 40 | | var last = pieces[span]; |
| | 10302 | 41 | | return new RationalSegmentInterval(first.Interval.IsClipped ? first.Interval.WideLowerNumerator : default, |
| | 10302 | 42 | | first.Interval.IsClipped ? first.Interval.WideLowerDenominator : Signed832.ExtendValue(Signed192.Signed(1)), |
| | 10302 | 43 | | last.Interval.IsClipped ? last.Interval.WideUpperNumerator : Signed832.ExtendValue(Signed192.Signed(1)), |
| | 10302 | 44 | | last.Interval.IsClipped ? last.Interval.WideUpperDenominator : Signed832.ExtendValue(Signed192.Signed(1))); |
| | | 45 | | } |
| | | 46 | | } |