diff --git a/src/main/java/com/enderio/core/client/render/RenderUtil.java b/src/main/java/com/enderio/core/client/render/RenderUtil.java index f36ca1c..600ced3 100644 --- a/src/main/java/com/enderio/core/client/render/RenderUtil.java +++ b/src/main/java/com/enderio/core/client/render/RenderUtil.java @@ -376,6 +376,24 @@ public class RenderUtil { } } + public static void addVerticesToTessellator(Vertex[] vertices, Tessellator tes) { + for (int i = 0; i < vertices.length; i++) { + if (vertices[i].brightness != -1) { + tes.setBrightness(vertices[i].brightness); + } + if (vertices[i].color != null) { + tes.setColorRGBA_F(vertices[i].r(), vertices[i].g(), vertices[i].b(), vertices[i].a()); + } + if (vertices[i].uv != null) { + tes.setTextureUV(vertices[i].u(), vertices[i].v()); + } + if (vertices[i].normal != null) { + tes.setNormal(vertices[i].nx(), vertices[i].ny(), vertices[i].nz()); + } + tes.addVertex(vertices[i].x(), vertices[i].y(), vertices[i].z()); + } + } + public static void renderConnectedTextureFace(IBlockAccess blockAccess, Block block, int x, int y, int z, ForgeDirection face, IIcon texture, boolean forceAllEdges) { renderConnectedTextureFace(blockAccess, block, x, y, z, face, texture, forceAllEdges, true, true); diff --git a/src/main/java/com/enderio/core/common/vecmath/Vertex.java b/src/main/java/com/enderio/core/common/vecmath/Vertex.java index f65f2eb..8b94fca 100644 --- a/src/main/java/com/enderio/core/common/vecmath/Vertex.java +++ b/src/main/java/com/enderio/core/common/vecmath/Vertex.java @@ -3,6 +3,11 @@ package com.enderio.core.common.vecmath; public class Vertex { public Vector3d xyz = new Vector3d(); + + /* + * some parts of EIO are relying on nulls as special values, can't just pre allocate new objects and set them when + * required, unless everything relying on nulls is rewritten + */ public Vector2f uv = null; public Vector3f normal = null; public Vector4f color = null; @@ -76,6 +81,42 @@ public class Vertex { this.brightness = brightness; } + public void set(Vertex other) { + xyz.set(other.xyz); + + if (other.uv != null) { + if (uv == null) { + uv = new Vector2f(other.uv); + } else { + uv.set(other.uv); + } + } else { + uv = null; + } + + if (other.normal != null) { + if (normal == null) { + normal = new Vector3f(other.normal); + } else { + normal.set(other.normal); + } + } else { + normal = null; + } + + if (other.color != null) { + if (color == null) { + color = new Vector4f(other.color); + } else { + color.set(other.color); + } + } else { + color = null; + } + + brightness = other.brightness; + } + public Vector4f getColor() { return color; }