| | | 1 | | //======================================================================= |
| | | 2 | | // TriangleConeContactSelection.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 | | |
| | | 10 | | namespace FixedMathSharp.Geometry; |
| | | 11 | | |
| | | 12 | | /// <summary>One exact cone support winner and its unrounded local normal.</summary> |
| | | 13 | | internal ref struct TriangleConeContactSelection |
| | | 14 | | { |
| | | 15 | | internal const int Apex = 0, BasePole = 1, BaseRim = 2, Generator = 3; |
| | | 16 | | internal Span<ulong> Values; |
| | | 17 | | internal Span<int> Signs; |
| | | 18 | | internal int GapSign, Mask, Feature; |
| | | 19 | | internal bool HasValue; |
| | | 20 | | internal TriangleConeContactSelection(Span<ulong> values, Span<int> signs) |
| | | 21 | | { |
| | 274 | 22 | | Values = values; Signs = signs; |
| | 274 | 23 | | GapSign = Mask = Feature = 0; HasValue = false; |
| | 137 | 24 | | } |
| | | 25 | | |
| | 9750 | 26 | | internal readonly bool Separated => HasValue && GapSign < 0; |
| | 4263 | 27 | | internal readonly ConvexContactCandidate Candidate => new(Values, Signs, GapSign); |
| | | 28 | | |
| | | 29 | | internal void Keep(scoped Span<ulong> values, scoped Span<int> signs, int gapSign, int mask, int feature) |
| | | 30 | | { |
| | 4076 | 31 | | if (Separated || HasValue && WideConvexPrismRelations.CompareConvexContactCandidates( |
| | 4076 | 32 | | new ConvexContactCandidate(values, signs, gapSign), Candidate) >= 0) |
| | 3714 | 33 | | return; |
| | 724 | 34 | | values.CopyTo(Values); signs.CopyTo(Signs); |
| | 1448 | 35 | | GapSign = gapSign; Mask = mask; Feature = feature; HasValue = true; |
| | 362 | 36 | | } |
| | | 37 | | } |