diff --git a/src/main/java/com/gtnewhorizon/gtnhlib/client/model/loading/NdQuadBuilder.java b/src/main/java/com/gtnewhorizon/gtnhlib/client/model/loading/NdQuadBuilder.java index 6cb9afee..b0341ad9 100644 --- a/src/main/java/com/gtnewhorizon/gtnhlib/client/model/loading/NdQuadBuilder.java +++ b/src/main/java/com/gtnewhorizon/gtnhlib/client/model/loading/NdQuadBuilder.java @@ -1,12 +1,5 @@ package com.gtnewhorizon.gtnhlib.client.model.loading; -import static com.gtnewhorizon.gtnhlib.client.model.json.FaceRewindHelper.DOWN; -import static com.gtnewhorizon.gtnhlib.client.model.json.FaceRewindHelper.EAST; -import static com.gtnewhorizon.gtnhlib.client.model.json.FaceRewindHelper.NORTH; -import static com.gtnewhorizon.gtnhlib.client.model.json.FaceRewindHelper.SOUTH; -import static com.gtnewhorizon.gtnhlib.client.model.json.FaceRewindHelper.UP; -import static com.gtnewhorizon.gtnhlib.client.model.json.FaceRewindHelper.WEST; - import java.util.Arrays; import net.minecraft.client.Minecraft; @@ -16,7 +9,6 @@ import net.minecraftforge.common.util.ForgeDirection; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.joml.Matrix4f; import org.joml.Vector3f; import org.lwjgl.opengl.GL11; @@ -34,7 +26,6 @@ public class NdQuadBuilder extends Quad implements QuadBuilder { private ForgeDirection lightFace = ForgeDirection.UP; private int geometryFlags = 0; private boolean isGeometryInvalid = true; - private int tag = 0; final Vector3f faceNormal = new Vector3f(); public final Material mat = new Material(); @Setter @@ -52,28 +43,6 @@ public class NdQuadBuilder extends Quad implements QuadBuilder { return out; } - /** - * See {@link #build(QuadView)}. This rotates the output by the given matrix. - */ - public QuadView build(QuadView out, Matrix4f rotMat) { - - this.pos(0, this.pos(0).mulPosition(rotMat)); - this.pos(1, this.pos(1).mulPosition(rotMat)); - this.pos(2, this.pos(2).mulPosition(rotMat)); - - if (this.drawMode == GL11.GL_QUADS) this.pos(3, this.pos(3).mulPosition(rotMat)); - else this.quadrangulate(); - - this.computeGeometry(); - - // Reset the cull face - this.setCullFace(); - - out.copyFrom(this); - this.clear(); - return out; - } - private void clear() { Arrays.fill(this.data, 0); @@ -81,7 +50,6 @@ public class NdQuadBuilder extends Quad implements QuadBuilder { this.lightFace = ForgeDirection.UP; this.geometryFlags = 0; this.isGeometryInvalid = true; - this.tag(0); this.setColorIndex(-1); this.mat.reset(); this.drawMode = GL11.GL_QUADS; @@ -148,77 +116,11 @@ public class NdQuadBuilder extends Quad implements QuadBuilder { isGeometryInvalid = true; } - @Override - public void pos(int vertexIndex, Vector3f vec) { - - this.setX(vertexIndex, vec.x); - this.setY(vertexIndex, vec.y); - this.setZ(vertexIndex, vec.z); - isGeometryInvalid = true; - } - - @Override - public Vector3f pos(int vertexIndex) { - - return new Vector3f(this.getX(vertexIndex), this.getY(vertexIndex), this.getZ(vertexIndex)); - } - @Override public float posByIndex(int vertexIndex, int coordinateIndex) { return Float.intBitsToFloat(this.data[vertexIndex * Quad.VERTEX_STRIDE + Quad.X_INDEX + coordinateIndex]); } - final int MIN_X = 0; - final int MIN_Y = 1; - final int MIN_Z = 2; - final int MAX_X = 3; - final int MAX_Y = 4; - final int MAX_Z = 5; - - /** - * Rewinds the quad to the standard order. Works as long as four vertex positions have been assigned, and will not - * rewind any non-position data. Recommended to do immediately after vertex assignment, and to set/reset UVs, - * colors, etc. afterwards. - * - * PS: this should only be used on quads parallel to the block grid. - * - * TODO: this doesn't actually work - */ - public void rewind(float x, float y, float z, float X, float Y, float Z) { - boolean[] targets = switch (getLightFace()) { - case DOWN -> DOWN; - case UP -> UP; - case NORTH -> NORTH; - case SOUTH -> SOUTH; - case WEST -> WEST; - case EAST -> EAST; - case UNKNOWN -> throw new RuntimeException("Expected non-UNKNOWN face!"); - }; - - final float ox = getX(0); - final float oy = getY(0); - final float oz = getZ(0); - - // Reset the vertices, given the bounds - int iFirst = 0; - for (int i = 0; i < 4; ++i) { - final float px = targets[i * 3] ? X : x; - final float py = targets[i * 3 + 1] ? Y : y; - final float pz = targets[i * 3 + 2] ? Z : z; - pos(i, px, py, pz); - - // Save the original first vertex - if (px == ox && py == oy && pz == oz) iFirst = i; - } - - // Shift the UVs - copy to a temp array, then copy back in the right order, wrapping appropriately - float[] uvs = { getTexU(0), getTexV(0), getTexU(1), getTexV(1), getTexU(2), getTexV(2), getTexU(3), - getTexV(3) }; - for (int i = 0; i < 4; ++i) { - uv((i + iFirst) % 4, uvs[i * 2], uvs[i * 2 + 1]); - } - } - @Override public void spriteBake(String spriteName, int bakeFlags) { @@ -280,15 +182,6 @@ public class NdQuadBuilder extends Quad implements QuadBuilder { } } - public int tag() { - return this.tag; - } - - @Override - public void tag(int tag) { - this.tag = tag; - } - @Override public void uv(int vertexIndex, float u, float v) { diff --git a/src/main/java/com/gtnewhorizon/gtnhlib/client/renderer/quad/ModelQuad.java b/src/main/java/com/gtnewhorizon/gtnhlib/client/renderer/quad/ModelQuad.java index ad9a61e1..944bbbab 100644 --- a/src/main/java/com/gtnewhorizon/gtnhlib/client/renderer/quad/ModelQuad.java +++ b/src/main/java/com/gtnewhorizon/gtnhlib/client/renderer/quad/ModelQuad.java @@ -84,11 +84,6 @@ public class ModelQuad implements ModelQuadViewMutable { @Override public void setCullFace(ForgeDirection f) {} - @Override - public int getLight(int idx) { - return this.data[vertexOffset(idx) + LIGHT_INDEX]; - } - @Override public int getNormal(int idx) { return this.data[vertexOffset(idx) + NORMAL_INDEX]; diff --git a/src/main/java/com/gtnewhorizon/gtnhlib/client/renderer/quad/ModelQuadView.java b/src/main/java/com/gtnewhorizon/gtnhlib/client/renderer/quad/ModelQuadView.java index 2e3cdf49..e4e81e57 100644 --- a/src/main/java/com/gtnewhorizon/gtnhlib/client/renderer/quad/ModelQuadView.java +++ b/src/main/java/com/gtnewhorizon/gtnhlib/client/renderer/quad/ModelQuadView.java @@ -1,7 +1,5 @@ package com.gtnewhorizon.gtnhlib.client.renderer.quad; -import java.nio.ByteBuffer; - import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraftforge.common.util.ForgeDirection; @@ -47,11 +45,6 @@ public interface ModelQuadView { */ int getFlags(); - /** - * @return The lightmap texture coordinates for the vertex at index {@param idx} - */ - int getLight(int idx); - /** * @return The integer-encoded normal vector for the vertex at index {@param idx} */ @@ -75,26 +68,6 @@ public interface ModelQuadView { */ ForgeDirection getLightFace(); - /** - * Copies this quad's data into the specified buffer starting at the given position. - * - * @param buf The buffer to write this quad's data to - * @param position The starting byte index to write to - */ - default void copyInto(ByteBuffer buf, int position) { - for (int i = 0; i < 4; i++) { - buf.putFloat(position, this.getX(i)); - buf.putFloat(position + 4, this.getY(i)); - buf.putFloat(position + 8, this.getZ(i)); - buf.putInt(position + 12, this.getColor(i)); - buf.putFloat(position + 16, this.getTexU(i)); - buf.putFloat(position + 20, this.getTexV(i)); - buf.putInt(position + 24, this.getLight(i)); - - position += 28; - } - } - /** * @return The sprite texture used by this quad, or null if none is attached */ diff --git a/src/main/java/com/gtnewhorizon/gtnhlib/client/renderer/quad/Quad.java b/src/main/java/com/gtnewhorizon/gtnhlib/client/renderer/quad/Quad.java index 52b03760..d263bb9a 100644 --- a/src/main/java/com/gtnewhorizon/gtnhlib/client/renderer/quad/Quad.java +++ b/src/main/java/com/gtnewhorizon/gtnhlib/client/renderer/quad/Quad.java @@ -90,11 +90,6 @@ public class Quad implements QuadView { return this.data[idx * VERTEX_STRIDE + COLOR_INDEX]; } - @Override - public int getLight(int idx) { - return this.data[idx * VERTEX_STRIDE + LIGHTMAP_INDEX]; - } - @Override public int getNormal(int idx) { return this.data[idx * VERTEX_STRIDE + NORMAL_INDEX]; @@ -250,7 +245,6 @@ public class Quad implements QuadView { this.setTexU(3, this.getTexU(2)); this.setTexV(3, this.getTexV(2)); - this.setLight(3, this.getLight(2)); this.setColor(3, this.getColor(2)); this.setNormal(3, this.getNormal(2)); } @@ -333,13 +327,6 @@ public class Quad implements QuadView { public boolean hasColor; public boolean hasNormals; - public Flags(byte flags) { - hasTexture = (flags & 1) != 0; - hasBrightness = (flags & 2) != 0; - hasColor = (flags & 4) != 0; - hasNormals = (flags & 8) != 0; - } - public Flags(boolean hasTexture, boolean hasBrightness, boolean hasColor, boolean hasNormals) { this.hasTexture = hasTexture; this.hasBrightness = hasBrightness; diff --git a/src/main/java/com/gtnewhorizon/gtnhlib/client/renderer/quad/QuadBuilder.java b/src/main/java/com/gtnewhorizon/gtnhlib/client/renderer/quad/QuadBuilder.java index e44d906b..b62b1c7b 100644 --- a/src/main/java/com/gtnewhorizon/gtnhlib/client/renderer/quad/QuadBuilder.java +++ b/src/main/java/com/gtnewhorizon/gtnhlib/client/renderer/quad/QuadBuilder.java @@ -5,7 +5,6 @@ import net.minecraftforge.common.util.ForgeDirection; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.Nullable; -import org.joml.Matrix4f; import org.joml.Vector3f; import com.gtnewhorizon.gtnhlib.client.model.loading.NdQuadBuilder; @@ -82,11 +81,6 @@ public interface QuadBuilder { */ QuadView build(QuadView out); - /** - * See {@link #build(QuadView)}. This also rotates the output by the given matrix. - */ - QuadView build(QuadView out, Matrix4f rotMat); - /** * Tries to automatically set the culling and nominal face from the quad's geometry. */ @@ -122,16 +116,6 @@ public interface QuadBuilder { */ void pos(int vertexIndex, float x, float y, float z); - /** - * Convenience: set pos with a vector. See {@link #pos(int, float, float, float)}. - */ - void pos(int vertexIndex, Vector3f vec); - - /** - * Gets the vertex position as a vector. This allocates a new vector, do not use in dynamic rendering! - */ - Vector3f pos(int vertexIndex); - /** * Convenience: access x, y, z by index 0-2. */ @@ -166,14 +150,6 @@ public interface QuadBuilder { */ void square(ForgeDirection nominalFace, float left, float bottom, float right, float top, float depth); - int tag(); - - /** - * Encodes an integer tag with this quad that can later be retrieved via {@link #tag()}. Useful for models that want - * to perform conditional transformation or filtering on static meshes. - */ - void tag(int tag); - /** * Set texture coordinates. */ diff --git a/src/main/java/com/gtnewhorizon/gtnhlib/client/renderer/quad/QuadView.java b/src/main/java/com/gtnewhorizon/gtnhlib/client/renderer/quad/QuadView.java index 4f65a424..20a167a0 100644 --- a/src/main/java/com/gtnewhorizon/gtnhlib/client/renderer/quad/QuadView.java +++ b/src/main/java/com/gtnewhorizon/gtnhlib/client/renderer/quad/QuadView.java @@ -4,14 +4,6 @@ import net.minecraftforge.common.util.ForgeDirection; public interface QuadView extends ModelQuadViewMutable { - /** - * Allocates a new quad - use sparingly, and not at all in render paths if you can help it. We don't need another - * Malice Doors. - */ - static QuadView allocate() { - return new Quad(); - } - boolean isShade(); boolean isDeleted();