Skip to content

Commit bfb933f

Browse files
committed
Fixed rotated cuboids
1 parent 5776e51 commit bfb933f

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/main/java/dev/latvian/mods/klib/shape/CuboidShape.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,16 @@ public void buildQuads(float x, float y, float z, VertexCallback callback) {
6666
float sz = size.z() / 2F;
6767

6868
if (!rotation.isNone()) {
69-
callback = callback.withTransformedPositionsAndNormals(rotation.rotateYXZ(new Matrix4f()), rotation.rotateYXZ(new Matrix3f()), true);
69+
var mat4 = new Matrix4f();
70+
var mat3 = new Matrix3f();
71+
mat4.translate(x, y, z);
72+
rotation.rotateYXZ(mat4);
73+
rotation.rotateYXZ(mat3);
74+
callback = callback.withTransformedPositionsAndNormals(mat4, mat3, true);
75+
CuboidBuilder.quads(-sx, -sy, -sz, sx, sy, sz, callback);
76+
} else {
77+
CuboidBuilder.quads(x - sx, y - sy, z - sz, x + sx, y + sy, z + sz, callback);
7078
}
71-
72-
CuboidBuilder.quads(x - sx, y - sy, z - sz, x + sx, y + sy, z + sz, callback);
7379
}
7480

7581
@Override

0 commit comments

Comments
 (0)