Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void replicateOldMulPoseBehavior(@NotNull PoseStack poseStack, float angle, float x, float y, float z) {
- // Quaternion fields
- float q_sin = Mth.sin(angle * 0.5F);
- float q_x = x * q_sin;
- float q_y = y * q_sin;
- float q_z = z * q_sin;
- float q_w = Mth.cos(angle * 0.5F);
- // Matrix4f/Matrix3f fields
- float m_xFactor = 2.0F * q_x * q_x;
- float m_yFactor = 2.0F * q_y * q_y;
- float m_zFactor = 2.0F * q_z * q_z;
- float m_xy = q_x * q_y;
- float m_yz = q_y * q_z;
- float m_zx = q_z * q_x;
- float m_xw = q_x * q_w;
- float m_yw = q_y * q_w;
- float m_zw = q_z * q_w;
- float m_m00 = 1.0F - m_yFactor - m_zFactor;
- float m_m01 = 2.0F * (m_xy - m_zw);
- float m_m02 = 2.0F * (m_zx + m_yw);
- float m_m10 = 2.0F * (m_xy + m_zw);
- float m_m11 = 1.0F - m_zFactor - m_xFactor;
- float m_m12 = 2.0F * (m_yz - m_xw);
- float m_m20 = 2.0F * (m_zx - m_yw);
- float m_m21 = 2.0F * (m_yz + m_xw);
- float m_m22 = 1.0F - m_xFactor - m_yFactor;
- PoseStack.Pose lastPose = poseStack.last();
- Matrix4f pose = lastPose.pose();
- Matrix3f normal = lastPose.normal();
- // Multiply pose matrix
- pose.m00(m_m00 * pose.m00() + m_m01 * pose.m10() + m_m02 * pose.m20());
- pose.m01(m_m00 * pose.m01() + m_m01 * pose.m11() + m_m02 * pose.m21());
- pose.m02(m_m00 * pose.m02() + m_m01 * pose.m12() + m_m02 * pose.m22());
- pose.m03(m_m00 * pose.m03() + m_m01 * pose.m13() + m_m02 * pose.m23());
- pose.m10(m_m10 * pose.m00() + m_m11 * pose.m10() + m_m12 * pose.m20());
- pose.m11(m_m10 * pose.m01() + m_m11 * pose.m11() + m_m12 * pose.m21());
- pose.m12(m_m10 * pose.m02() + m_m11 * pose.m12() + m_m12 * pose.m22());
- pose.m13(m_m10 * pose.m03() + m_m11 * pose.m13() + m_m12 * pose.m23());
- pose.m20(m_m20 * pose.m00() + m_m21 * pose.m10() + m_m22 * pose.m20());
- pose.m21(m_m20 * pose.m01() + m_m21 * pose.m11() + m_m22 * pose.m21());
- pose.m22(m_m20 * pose.m02() + m_m21 * pose.m12() + m_m22 * pose.m22());
- pose.m23(m_m20 * pose.m03() + m_m21 * pose.m13() + m_m22 * pose.m23());
- // Multiply normal matrix
- normal.m00(m_m00 * normal.m00() + m_m01 * normal.m10() + m_m02 * normal.m20());
- normal.m01(m_m00 * normal.m01() + m_m01 * normal.m11() + m_m02 * normal.m21());
- normal.m02(m_m00 * normal.m02() + m_m01 * normal.m12() + m_m02 * normal.m22());
- normal.m10(m_m10 * normal.m00() + m_m11 * normal.m10() + m_m12 * normal.m20());
- normal.m11(m_m10 * normal.m01() + m_m11 * normal.m11() + m_m12 * normal.m21());
- normal.m12(m_m10 * normal.m02() + m_m11 * normal.m12() + m_m12 * normal.m22());
- normal.m20(m_m20 * normal.m00() + m_m21 * normal.m10() + m_m22 * normal.m20());
- normal.m21(m_m20 * normal.m01() + m_m21 * normal.m11() + m_m22 * normal.m21());
- normal.m22(m_m20 * normal.m02() + m_m21 * normal.m12() + m_m22 * normal.m22());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement