diff options
author | makamys <makamys@outlook.com> | 2022-06-10 17:33:13 +0200 |
---|---|---|
committer | makamys <makamys@outlook.com> | 2022-06-10 19:21:01 +0200 |
commit | e1097c3f69077be93089d1ef91aa8cdebd00d43c (patch) | |
tree | 6611a505eb69a1904315b8c5c58ea811f849f5c9 /src/main/java | |
parent | b152483006b8a61e02510de50eba4dc9dc85ab81 (diff) | |
download | Neodymium-e1097c3f69077be93089d1ef91aa8cdebd00d43c.tar.gz Neodymium-e1097c3f69077be93089d1ef91aa8cdebd00d43c.tar.bz2 Neodymium-e1097c3f69077be93089d1ef91aa8cdebd00d43c.zip |
uuh...
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/makamys/neodymium/renderer/MeshQuad.java | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/src/main/java/makamys/neodymium/renderer/MeshQuad.java b/src/main/java/makamys/neodymium/renderer/MeshQuad.java index bebdafd..7d3c50b 100644 --- a/src/main/java/makamys/neodymium/renderer/MeshQuad.java +++ b/src/main/java/makamys/neodymium/renderer/MeshQuad.java @@ -17,17 +17,17 @@ import net.minecraft.util.EnumFacing; /* * This is what a quad looks like. * - * 2--1 + * 0--1 * | | - * 3--0 + * 3--2 * * We can glue quads together, forming a "quad squadron", or "squadron" for short. * In the fragment shader we need to know which quad of the squadron we are operating on. * For this reason, we store the "squadron X" and "squadron Y" coordinates in the vertices. * Their values at vertex 0: (0, 0) - * Their values at vertex 1: (0, squadron height) + * Their values at vertex 1: (sqadron width, 0) * Their values at vertex 2: (squadron width, squadron height) - * Their values at vertex 3: (squadron width, 0) + * Their values at vertex 3: (0, squadron height) */ public class MeshQuad { @@ -51,8 +51,8 @@ public class MeshQuad { public int offset; public ChunkMesh.Flags flags; - // 0: quads glued together on edge 0-1 or 2-3 ("squadron row length") - // 1: quads glued together on edge 1-2 or 3-0 ("squadron column length") + // 0: quads glued together on edge 1-2 or 3-0 ("squadron row length") + // 1: quads glued together on edge 0-1 or 2-3 ("squadron column length") private int[] quadCountByDirection = {1, 1}; public static int[] totalMergeCountByPlane = new int[3]; @@ -109,7 +109,8 @@ public class MeshQuad { public void writeToBuffer(BufferWriter out) throws IOException { for(int vertexI = 0; vertexI < 6; vertexI++) { - int vi = new int[]{0, 1, 2, 0, 2, 3}[vertexI]; + int vi = new int[]{0, 1, 2, 2, 3, 0}[vertexI]; + int tvi = vertexI % 3; float x = xs[vi]; float y = ys[vi]; @@ -133,10 +134,10 @@ public class MeshQuad { out.writeInt(c); - out.writeByte(vi < 2 ? (byte)0 : (byte)quadCountByDirection[0]); // squadron x - out.writeByte((vi == 0 || vi == 3) ? (byte)0 : (byte)quadCountByDirection[1]); // quad z - out.writeByte(vi < 2 ? (byte)0 : 1); // which squadron corner x - out.writeByte((vi == 0 || vi == 3) ? (byte)0 : 1); // which squadron corner z + out.writeByte(tvi == 2 ? (byte)0 : (byte)quadCountByDirection[0]); // squadron x + out.writeByte(tvi != 0 ? (byte)0 : (byte)quadCountByDirection[1]); // squadron z + out.writeByte(tvi == 2 ? (byte)0 : 1); // which corner x + out.writeByte(tvi != 0 ? (byte)0 : 1); // which corner z assert out.position() % getStride() == 0; @@ -199,10 +200,10 @@ public class MeshQuad { } } - if((verticesTouching[0] && verticesTouching[1]) || (verticesTouching[2] && verticesTouching[3])) { + if((verticesTouching[1] && verticesTouching[2]) || (verticesTouching[3] && verticesTouching[0])) { quadCountByDirection[0] += o.quadCountByDirection[0]; } - if((verticesTouching[1] && verticesTouching[2]) || (verticesTouching[3] && verticesTouching[0])) { + if((verticesTouching[0] && verticesTouching[1]) || (verticesTouching[2] && verticesTouching[3])) { quadCountByDirection[1] += o.quadCountByDirection[1]; } |