diff --git a/src/main/java/me/cortex/voxy/client/core/model/ColourDepthTextureData.java b/src/main/java/me/cortex/voxy/client/core/model/ColourDepthTextureData.java index c3dd1a46..c63af6e6 100644 --- a/src/main/java/me/cortex/voxy/client/core/model/ColourDepthTextureData.java +++ b/src/main/java/me/cortex/voxy/client/core/model/ColourDepthTextureData.java @@ -2,21 +2,25 @@ package me.cortex.voxy.client.core.model; import java.util.Arrays; -public record ColourDepthTextureData(int[] colour, int[] depth, int width, int height) { +public record ColourDepthTextureData(int[] colour, int[] depth, int width, int height, int hash) { + public ColourDepthTextureData(int[] colour, int[] depth, int width, int height) { + this(colour, depth, width, height, width * 312337173 * (Arrays.hashCode(colour) ^ Arrays.hashCode(depth)) ^ height); + } + @Override public boolean equals(Object obj) { if (obj == null) return false; var other = ((ColourDepthTextureData)obj); - return Arrays.equals(other.colour, this.colour) && Arrays.equals(other.depth, this.depth); + return this.hash == other.hash && Arrays.equals(other.colour, this.colour) && Arrays.equals(other.depth, this.depth); } @Override public int hashCode() { - return (this.width * 312337173 * (Arrays.hashCode(this.colour) ^ Arrays.hashCode(this.depth))) ^ this.height; + return this.hash; } @Override public ColourDepthTextureData clone() { - return new ColourDepthTextureData(Arrays.copyOf(this.colour, this.colour.length), Arrays.copyOf(this.depth, this.depth.length), this.width, this.height); + return new ColourDepthTextureData(Arrays.copyOf(this.colour, this.colour.length), Arrays.copyOf(this.depth, this.depth.length), this.width, this.height, this.hash); } } diff --git a/src/main/java/me/cortex/voxy/client/core/model/ModelBakerySubsystem.java b/src/main/java/me/cortex/voxy/client/core/model/ModelBakerySubsystem.java index dda99c45..09c6b95e 100644 --- a/src/main/java/me/cortex/voxy/client/core/model/ModelBakerySubsystem.java +++ b/src/main/java/me/cortex/voxy/client/core/model/ModelBakerySubsystem.java @@ -38,7 +38,7 @@ public class ModelBakerySubsystem { public void tick() { //There should be a method to access the frame time IIRC, if the user framecap is unlimited lock it to like 60 fps for computation - int BUDGET = 25;//TODO: make this computed based on the remaining free time in a frame (and like div by 2 to reduce overhead) (with a min of 1) + int BUDGET = 16;//TODO: make this computed based on the remaining free time in a frame (and like div by 2 to reduce overhead) (with a min of 1) for (int i = 0; i < BUDGET && !this.blockIdQueue.isEmpty(); i++) { int blockId = -1; diff --git a/src/main/java/me/cortex/voxy/client/core/model/ModelFactory.java b/src/main/java/me/cortex/voxy/client/core/model/ModelFactory.java index 3b813933..af15524b 100644 --- a/src/main/java/me/cortex/voxy/client/core/model/ModelFactory.java +++ b/src/main/java/me/cortex/voxy/client/core/model/ModelFactory.java @@ -59,9 +59,9 @@ public class ModelFactory { //TODO: replace the fluid BlockState with a client model id integer of the fluidState, requires looking up // the fluid state in the mipper - private record ModelEntry(List textures, int fluidBlockStateId) { - private ModelEntry(ColourDepthTextureData[] textures, int fluidBlockStateId) { - this(Stream.of(textures).map(ColourDepthTextureData::clone).toList(), fluidBlockStateId); + private record ModelEntry(ColourDepthTextureData down, ColourDepthTextureData up, ColourDepthTextureData north, ColourDepthTextureData south, ColourDepthTextureData west, ColourDepthTextureData east, int fluidBlockStateId) { + public ModelEntry(ColourDepthTextureData[] textures, int fluidBlockStateId) { + this(textures[0], textures[1], textures[2], textures[3], textures[4], textures[5], fluidBlockStateId); } }