| | | 1 | | //======================================================================= |
| | | 2 | | // CylinderContactGeometry.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 FixedMathSharp; |
| | | 9 | | using Gravitas.Colliders; |
| | | 10 | | using System.Runtime.CompilerServices; |
| | | 11 | | |
| | | 12 | | namespace Gravitas.CollisionHandling; |
| | | 13 | | |
| | | 14 | | internal static class CylinderContactGeometry |
| | | 15 | | { |
| | | 16 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | | 17 | | public static bool IsAxisAligned( |
| | | 18 | | FixedQuaternion rotation, |
| | | 19 | | Vector3d localAxis, |
| | | 20 | | Vector3d direction) => |
| | 855 | 21 | | Vector3d.Dot( |
| | 855 | 22 | | localAxis, |
| | 855 | 23 | | rotation.Inverse().Rotate(direction)).Abs() |
| | 855 | 24 | | >= Fixed64.FromFraction(63, 64); |
| | | 25 | | |
| | | 26 | | public static void GetCapBasis(LSCylinderCollider cylinder, out Vector3d tangentA, out Vector3d tangentB) |
| | | 27 | | { |
| | 434 | 28 | | tangentA = (cylinder.Rotation * Vector3d.Right).Normalized; |
| | 434 | 29 | | tangentB = (cylinder.Rotation * Vector3d.Forward).Normalized; |
| | 434 | 30 | | } |
| | | 31 | | } |