From 12e83cd6004a68517d6c98fc145770296696cd66 Mon Sep 17 00:00:00 2001 From: Ruben Panzich Date: Tue, 23 Jun 2026 11:45:04 +0800 Subject: [PATCH] Fix mirrored orientation in GetPhaseTransform --- .../Apple.PHASE_Unity/Assets/Runtime/PHASEHelpers.cs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/plug-ins/Apple.PHASE/Apple.PHASE_Unity/Assets/Runtime/PHASEHelpers.cs b/plug-ins/Apple.PHASE/Apple.PHASE_Unity/Assets/Runtime/PHASEHelpers.cs index c5de5d7d..b0378c74 100644 --- a/plug-ins/Apple.PHASE/Apple.PHASE_Unity/Assets/Runtime/PHASEHelpers.cs +++ b/plug-ins/Apple.PHASE/Apple.PHASE_Unity/Assets/Runtime/PHASEHelpers.cs @@ -812,13 +812,11 @@ static public MeshData GetMeshData(MeshFilter meshFilter, Transform transform) /// A Matrix4x4 representing a transform in PHASE coordinates. static public Matrix4x4 GetPhaseTransform(Transform inTransform) { - Matrix4x4 phaseTransform = new Matrix4x4(inTransform.right, inTransform.up, inTransform.forward, new Vector4()); - Vector3 position = RhConversionMat * inTransform.position; - phaseTransform.m30 = position.x; - phaseTransform.m31 = position.y; - phaseTransform.m32 = position.z; - phaseTransform.m33 = 1.0f; - return phaseTransform; + // RhConversionMat (S) flips Z. S * M * S keeps a proper rotation; flipping one + // side only gave a reflection. The native side reads this matrix transposed, + // so pass S * M^T * S. + Matrix4x4 rigid = Matrix4x4.TRS(inTransform.position, inTransform.rotation, Vector3.one); + return RhConversionMat * rigid.transpose * RhConversionMat; } static private Vector3 GetCombinedHierachyScale(Transform inTransform)