From 12c924751a07d1c20a6f119bf047afb7d39f1dea Mon Sep 17 00:00:00 2001 From: RainWarrior Date: Sun, 7 Feb 2016 17:49:06 +0300 Subject: [PATCH] Fix TRSRTransformation.toItemTransform. Closes #2425. --- .../client/model/TRSRTransformation.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/minecraftforge/client/model/TRSRTransformation.java b/src/main/java/net/minecraftforge/client/model/TRSRTransformation.java index 5f1f0d222..83167e84f 100644 --- a/src/main/java/net/minecraftforge/client/model/TRSRTransformation.java +++ b/src/main/java/net/minecraftforge/client/model/TRSRTransformation.java @@ -157,6 +157,12 @@ public class TRSRTransformation implements IModelState, ITransformation return ret; } + public static Vector3f toYXZDegrees(Quat4f q) + { + Vector3f yxz = toYXZ(q); + return new Vector3f((float)Math.toDegrees(yxz.x), (float)Math.toDegrees(yxz.y), (float)Math.toDegrees(yxz.z)); + } + public static Vector3f toYXZ(Quat4f q) { float w2 = q.w * q.w; @@ -164,19 +170,19 @@ public class TRSRTransformation implements IModelState, ITransformation float y2 = q.y * q.y; float z2 = q.z * q.z; float l = w2 + x2 + y2 + z2; - float sx = 2 * q.y * q.z - 2 * q.w * q.x; + float sx = 2 * q.w * q.x - 2 * q.y * q.z; float x = (float)Math.asin(sx / l); if(Math.abs(sx) > .999f * l) { return new Vector3f( - 2 * (float)Math.atan2(q.y, q.w), x, + 2 * (float)Math.atan2(q.y, q.w), 0 ); } return new Vector3f( - (float)Math.atan2(2 * q.x * q.z + 2 * q.y * q.w, w2 - x2 - y2 + z2), x, + (float)Math.atan2(2 * q.x * q.z + 2 * q.y * q.w, w2 - x2 - y2 + z2), (float)Math.atan2(2 * q.x * q.y + 2 * q.w * q.z, w2 - x2 + y2 - z2) ); } @@ -443,7 +449,7 @@ public class TRSRTransformation implements IModelState, ITransformation */ public ItemTransformVec3f toItemTransform() { - return new ItemTransformVec3f(toLwjgl(getTranslation()), toLwjgl(toYXZ(getLeftRot())), toLwjgl(getScale())); + return new ItemTransformVec3f(toLwjgl(toYXZDegrees(getLeftRot())), toLwjgl(getTranslation()), toLwjgl(getScale())); } public Matrix4f getMatrix()