diff options
author | makamys <makamys@outlook.com> | 2022-06-21 07:27:41 +0200 |
---|---|---|
committer | makamys <makamys@outlook.com> | 2022-06-21 08:27:14 +0200 |
commit | 4cede31534a3e2df297b32f1832a103c110fdb0e (patch) | |
tree | 56b5ac48b38ac3470f34ad4d92c049223b45dc76 /src/main/java | |
parent | 9af39b831004051e7c20c56e63b2d95bffc34cfe (diff) | |
download | Neodymium-4cede31534a3e2df297b32f1832a103c110fdb0e.tar.gz Neodymium-4cede31534a3e2df297b32f1832a103c110fdb0e.tar.bz2 Neodymium-4cede31534a3e2df297b32f1832a103c110fdb0e.zip |
Don't merge non-rectangles
Fixes Carpenter's Blocks incompatibility
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/makamys/neodymium/renderer/MeshQuad.java | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/main/java/makamys/neodymium/renderer/MeshQuad.java b/src/main/java/makamys/neodymium/renderer/MeshQuad.java index 1ff4173..1244d5d 100644 --- a/src/main/java/makamys/neodymium/renderer/MeshQuad.java +++ b/src/main/java/makamys/neodymium/renderer/MeshQuad.java @@ -50,6 +50,8 @@ public class MeshQuad { // Is positive U direction parallel to edge 0-1? public boolean uDirectionIs01; + public boolean isRectangle; + // 0: quads glued together on edge 1-2 or 3-0 ("megaquad row length") // 1: quads glued together on edge 0-1 or 2-3 ("megaquad column length") private int[] quadCountByDirection = {1, 1}; @@ -104,6 +106,11 @@ public class MeshQuad { uDirectionIs01 = us[0] != us[1]; updateMinMaxXYZ(); + updateIsRectangle(); + if(!isRectangle) { + // merging non-rectangles (e.g. Carpenter's Blocks wedge) is buggy, don't do it + noMerge = true; + } vectorA.set(xs[1] - xs[0], ys[1] - ys[0], zs[1] - zs[0]); vectorB.set(xs[2] - xs[1], ys[2] - ys[1], zs[2] - zs[1]); @@ -292,6 +299,27 @@ public class MeshQuad { } } + private void updateIsRectangle() { + isRectangle = + vertexExists(minX, minY, minZ) && + vertexExists(minX, minY, maxZ) && + vertexExists(minX, maxY, minZ) && + vertexExists(minX, maxY, maxZ) && + vertexExists(maxX, minY, minZ) && + vertexExists(maxX, minY, maxZ) && + vertexExists(maxX, maxY, minZ) && + vertexExists(maxX, maxY, maxZ); + } + + private boolean vertexExists(float x, float y, float z) { + for(int i = 0; i < 4; i++) { + if(xs[i] == x && ys[i] == y && zs[i] == z) { + return true; + } + } + return false; + } + // maybe minXYZ and maxXYZ should be arrays instead public double getMin(int coord) { return coord == 0 ? minX : coord == 1 ? minY : coord == 2 ? minZ : -1; |