diff options
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/makamys/neodymium/renderer/MeshQuad.java | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/main/java/makamys/neodymium/renderer/MeshQuad.java b/src/main/java/makamys/neodymium/renderer/MeshQuad.java index ca6f5a2..438f06b 100644 --- a/src/main/java/makamys/neodymium/renderer/MeshQuad.java +++ b/src/main/java/makamys/neodymium/renderer/MeshQuad.java @@ -37,6 +37,8 @@ public class MeshQuad { public static int[] totalMergeCountByPlane = new int[3]; + private MeshQuad mergeReference; + private int minPositive(int a, int b) { if(a == -1) { return b; @@ -116,8 +118,12 @@ public class MeshQuad { } } - private boolean isTranslatedCopyOf(MeshQuad o) { - if(!isValid(this) || !isValid(o) || plane != o.plane) return false; + private boolean isTranslatedCopyOf(MeshQuad o, boolean checkValid) { + if((!isValid(this) && checkValid) || !isValid(o) || plane != o.plane) return false; + + if(mergeReference != null) { + return mergeReference.isTranslatedCopyOf(o, false); + } for(int i = 1; i < 4; i++) { double relX = xs[i] - xs[0]; @@ -139,7 +145,7 @@ public class MeshQuad { } public void tryToMerge(MeshQuad o) { - if(isTranslatedCopyOf(o)) { + if(isTranslatedCopyOf(o, true)) { int numVerticesTouching = 0; boolean[] verticesTouching = new boolean[4]; for(int i = 0; i < 4; i++) { @@ -159,6 +165,8 @@ public class MeshQuad { totalMergeCountByPlane[plane.ordinal() - 1]++; + mergeReference = o; + o.deleted = true; } } |