using System.Numerics; namespace AcDream.Core.Physics; /// /// Retail Position::IsValid 0x005A9480 composed with /// Frame::IsValid 0x00534ED0. The quaternion test is performed on its /// squared norm with retail's exact 0.0002 * 5 tolerance. /// public static class PositionFrameValidation { public static bool IsValid(uint cellId, Vector3 origin, Quaternion rotation) { if (!LandDefs.InboundValidCellId(cellId) || float.IsNaN(origin.X) || float.IsNaN(origin.Y) || float.IsNaN(origin.Z) || float.IsNaN(rotation.W) || float.IsNaN(rotation.X) || float.IsNaN(rotation.Y) || float.IsNaN(rotation.Z)) { return false; } float normSquared = rotation.LengthSquared(); return !float.IsNaN(normSquared) && MathF.Abs(normSquared - 1f) <= 0.001f; } }