Skip to content

Commit 0d60d8f

Browse files
committed
Fixed matrix multiplication
1 parent cec35d2 commit 0d60d8f

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/main/java/dev/latvian/mods/klib/KLibClientEventHandler.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@
1111
public class KLibClientEventHandler {
1212
@SubscribeEvent(priority = EventPriority.HIGHEST)
1313
public static void setup(FrameGraphSetupEvent event) {
14-
ClientMatrices.MODEL_VIEW.set(event.getModelViewMatrix());
15-
ClientMatrices.PROJECTION.set(event.getProjectionMatrix());
16-
ClientMatrices.WORLD.set(event.getProjectionMatrix().mul(event.getModelViewMatrix()));
17-
ClientMatrices.INVERSE_WORLD.set(ClientMatrices.WORLD).invert();
14+
ClientMatrices.updateMain(event.getModelViewMatrix(), event.getProjectionMatrix());
1815
}
1916
}

src/main/java/dev/latvian/mods/klib/math/ClientMatrices.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package dev.latvian.mods.klib.math;
22

33
import org.joml.Matrix4f;
4+
import org.joml.Matrix4fc;
45

56
public interface ClientMatrices {
67
Matrix4f MODEL_VIEW = new Matrix4f();
@@ -9,4 +10,11 @@ public interface ClientMatrices {
910
Matrix4f INVERSE_WORLD = new Matrix4f();
1011
Matrix4f PERSPECTIVE = new Matrix4f();
1112
Matrix4f FRUSTUM = new Matrix4f();
13+
14+
static void updateMain(Matrix4fc modelView, Matrix4fc projection) {
15+
MODEL_VIEW.set(modelView);
16+
PROJECTION.set(projection);
17+
WORLD.set(projection).mul(modelView);
18+
INVERSE_WORLD.set(WORLD).invert();
19+
}
1220
}

0 commit comments

Comments
 (0)