Integrate source airborne tilt and logical-root rendering

This commit is contained in:
UnixNight committed 2026-11-05 10:19:12 -05:00
1 parent a61f1b0284
commit 27be8ed630
36 files changed
+1953 -62

No files matched your search

+46
View File
@@ -0,0 +1,46 @@
using System.Numerics;
namespace GamePort.Game;
/// <summary>473540 degree-to-OMT cache and1003FA60 unit-scale local transform.
/// Source root is unrotated. OMT1003FC00 subsequently decomposes/re-quantizes its
/// render matrix; this helper uses its directly recovered hierarchical basis.
/// See docs/gameplay/jimmy-render-transform.md for native evidence/limits.</summary>
public static class JimmyRenderTransform
{
public static int AngleUnits(float degrees)
{
if (!float.IsFinite(degrees)) throw new ArgumentOutOfRangeException(nameof(degrees));
return (int)Math.Truncate(((double)degrees % 360) * 45.51111111111111) & 16383;
}
public static Matrix4x4 Source(Vector3 root, Vector3 euler)
{
Finite(root);
var (sx,cx) = RocketOrientation.Units(AngleUnits(euler.X));
var (sy,cy) = RocketOrientation.Units(AngleUnits(euler.Y));
var (sz,cz) = RocketOrientation.Units(AngleUnits(euler.Z));
//Row-vector convention: Rz(-roll), then Rx(-pitch), then Ry(-yaw).
//The translation is the unchanged actor root, independent of all axes.
return new(
(float)((double)cz*cy-(double)sz*sx*sy), -sz*cx, (float)((double)cz*sy+(double)sz*sx*cy), 0,
(float)((double)sz*cy+(double)cz*sx*sy), cz*cx, (float)((double)sz*sy-(double)cz*sx*cy), 0,
-cx*sy, sx, cx*cy, 0,
root.X, root.Y, root.Z, 1);
}
/// <summary>Modern compatibility adapter, not an original recovered offset.
/// A fixed sole-derived correction is local to the model, so full-axis tilt
/// remains around the source logical root and upright placement is preserved.</summary>
public static Matrix4x4 Aligned(Vector3 root, Vector3 euler, float localYCorrection)
{
if (!float.IsFinite(localYCorrection)) throw new ArgumentOutOfRangeException(nameof(localYCorrection));
return Matrix4x4.CreateTranslation(0,localYCorrection,0) * Source(root,euler);
}
private static void Finite(Vector3 value)
{
if (!float.IsFinite(value.X) || !float.IsFinite(value.Y) || !float.IsFinite(value.Z))
throw new ArgumentOutOfRangeException(nameof(value));
}
}