From 492e2a707aad71e321f12522752ac52681d8f315 Mon Sep 17 00:00:00 2001 From: mcrcortex <18544518+MCRcortex@users.noreply.github.com> Date: Mon, 7 Jul 2025 22:20:46 +1000 Subject: [PATCH] Fix compatibility when joml.fastmath is enabled, fixes physics mod causing everything to detonate Version bump --- gradle.properties | 2 +- .../core/model/bakery/ModelTextureBakery.java | 19 ++++++++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/gradle.properties b/gradle.properties index 86dbdc20..19cc6698 100644 --- a/gradle.properties +++ b/gradle.properties @@ -14,6 +14,6 @@ loader_version=0.16.14 fabric_version=0.128.1+1.21.7 # Mod Properties -mod_version = 0.2.2-alpha +mod_version = 0.2.3-alpha maven_group = me.cortex archives_base_name = voxy \ No newline at end of file diff --git a/src/main/java/me/cortex/voxy/client/core/model/bakery/ModelTextureBakery.java b/src/main/java/me/cortex/voxy/client/core/model/bakery/ModelTextureBakery.java index e4a70a31..906f57e0 100644 --- a/src/main/java/me/cortex/voxy/client/core/model/bakery/ModelTextureBakery.java +++ b/src/main/java/me/cortex/voxy/client/core/model/bakery/ModelTextureBakery.java @@ -18,6 +18,8 @@ import net.minecraft.world.biome.ColorResolver; import net.minecraft.world.chunk.light.LightingProvider; import org.jetbrains.annotations.Nullable; import org.joml.Matrix4f; +import org.joml.Quaternionf; +import org.joml.Vector3f; import org.lwjgl.opengl.GL14; import static org.lwjgl.opengl.GL11.*; @@ -335,11 +337,22 @@ public class ModelTextureBakery { private static void addView(int i, float pitch, float yaw, float rotation, int flip) { var stack = new MatrixStack(); stack.translate(0.5f,0.5f,0.5f); - stack.multiply(RotationAxis.POSITIVE_Z.rotationDegrees(rotation)); - stack.multiply(RotationAxis.POSITIVE_X.rotationDegrees(pitch)); - stack.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(yaw)); + stack.multiply(makeQuatFromAxisExact(new Vector3f(0,0,1), rotation)); + stack.multiply(makeQuatFromAxisExact(new Vector3f(1,0,0), pitch)); + stack.multiply(makeQuatFromAxisExact(new Vector3f(0,1,0), yaw)); stack.multiplyPositionMatrix(new Matrix4f().scale(1-2*(flip&1), 1-(flip&2), 1-((flip>>1)&2))); stack.translate(-0.5f,-0.5f,-0.5f); VIEWS[i] = new Matrix4f(stack.peek().getPositionMatrix()); } + + private static Quaternionf makeQuatFromAxisExact(Vector3f vec, float angle) { + angle = (float) Math.toRadians(angle); + float hangle = angle / 2.0f; + float sinAngle = (float) Math.sin(hangle); + float invVLength = (float) (1/Math.sqrt(vec.lengthSquared())); + return new Quaternionf(vec.x * invVLength * sinAngle, + vec.y * invVLength * sinAngle, + vec.z * invVLength * sinAngle, + Math.cos(hangle)); + } }