| | | 1 | | //======================================================================= |
| | | 2 | | // ConeSurfaceSelection.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 | | |
| | | 8 | | using System; |
| | | 9 | | using static FixedMathSharp.Geometry.CylinderContactAlgebra; |
| | | 10 | | using static FixedMathSharp.Geometry.ContactQuadratic; |
| | | 11 | | |
| | | 12 | | namespace FixedMathSharp.Geometry; |
| | | 13 | | |
| | | 14 | | /// <summary>Caller-owned retained finite-support branches and degenerate families.</summary> |
| | | 15 | | internal ref struct ConeSurfaceSelection |
| | | 16 | | { |
| | | 17 | | private readonly Span<SegmentConeSurfaceCandidate> candidates; |
| | | 18 | | internal int Count { get; private set; } |
| | 1615 | 19 | | internal SegmentConeSurfaceCandidate this[int index] => candidates[..Count][index]; |
| | | 20 | | |
| | | 21 | | internal ConeSurfaceSelection(Span<SegmentConeSurfaceCandidate> candidates) |
| | | 22 | | { |
| | 360 | 23 | | this.candidates = candidates; Count = 0; |
| | 180 | 24 | | } |
| | | 25 | | |
| | | 26 | | internal void Add(in SegmentConeSurfaceCandidate candidate) |
| | | 27 | | { |
| | 1012 | 28 | | if (Count == candidates.Length) |
| | 1 | 29 | | throw new InvalidOperationException("The caller-owned surface candidate storage is full."); |
| | 1011 | 30 | | candidates[Count++] = candidate; |
| | 1011 | 31 | | } |
| | | 32 | | } |