Skip to content

Commit 0610588

Browse files
committed
Attempt to improve mesher just a small ammount
1 parent 8007b05 commit 0610588

File tree

3 files changed

+22
-26
lines changed

3 files changed

+22
-26
lines changed

src/main/java/me/cortex/voxy/client/core/DistanceTracker.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ public DistanceTracker(RenderTracker tracker, int[] lodRingScales, int renderDis
9898
for (int y = this.minYSection >> capRing; y <= this.maxYSection >> capRing; y++) {
9999
this.tracker.removeCache(capRing, x, y, z);
100100
}
101-
});*/
101+
});
102+
*/
102103
}
103104

104105
if (isTerminatingRing) {

src/main/java/me/cortex/voxy/client/core/rendering/building/QuadEncoder.java

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -11,30 +11,25 @@ public static int encodePosition(int face, int otherAxis, int encodedMeshedData)
1111
if (Mesher2D.getW(encodedMeshedData) > 16 || Mesher2D.getH(encodedMeshedData) > 16) {
1212
throw new IllegalStateException("Width or height > 16");
1313
}
14-
int out = face;
15-
out |= switch (face >> 1) {
16-
case 0 ->
17-
(Mesher2D.getX(encodedMeshedData) << 21) |
18-
(otherAxis << 16) |
19-
(Mesher2D.getZ(encodedMeshedData) << 11) |
20-
((Mesher2D.getW(encodedMeshedData)-1) << 7) |
21-
((Mesher2D.getH(encodedMeshedData)-1) << 3);
14+
int dat = face;
15+
dat |= ((Mesher2D.getW(encodedMeshedData) - 1) << 7) |
16+
((Mesher2D.getH(encodedMeshedData) - 1) << 3);
2217

23-
case 1 ->
24-
(Mesher2D.getX(encodedMeshedData) << 21) |
25-
(Mesher2D.getZ(encodedMeshedData) << 16) |
26-
(otherAxis << 11) |
27-
((Mesher2D.getW(encodedMeshedData)-1) << 7) |
28-
((Mesher2D.getH(encodedMeshedData)-1) << 3);
29-
30-
case 2 ->
31-
(otherAxis << 21) |
32-
(Mesher2D.getX(encodedMeshedData) << 16) |
33-
(Mesher2D.getZ(encodedMeshedData) << 11) |
34-
((Mesher2D.getW(encodedMeshedData)-1) << 7) |
35-
((Mesher2D.getH(encodedMeshedData)-1) << 3);
36-
default -> throw new IllegalStateException("Unexpected value: " + (face >> 1));
37-
};
38-
return out;
18+
if (face>>1 == 0) {
19+
return dat |
20+
(Mesher2D.getX(encodedMeshedData) << 21) |
21+
(otherAxis << 16) |
22+
(Mesher2D.getZ(encodedMeshedData) << 11);
23+
}
24+
if (face>>1 == 1) {
25+
return dat |
26+
(Mesher2D.getX(encodedMeshedData) << 21) |
27+
(Mesher2D.getZ(encodedMeshedData) << 16) |
28+
(otherAxis << 11);
29+
}
30+
return dat |
31+
(otherAxis << 21) |
32+
(Mesher2D.getX(encodedMeshedData) << 16) |
33+
(Mesher2D.getZ(encodedMeshedData) << 11);
3934
}
4035
}

src/main/java/me/cortex/voxy/client/core/util/Mesher2D.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
//TODO: redo this so that it works as you are inserting data into it maybe? since it should be much faster??
88

9-
public class Mesher2D {
9+
public final class Mesher2D {
1010
private final int size;
1111
private final int maxSize;
1212
private final long[] data;

0 commit comments

Comments
 (0)