fix: OOB when iterating over all cube faces

This commit is contained in:
orng 2026-03-28 13:50:35 -05:00
parent f614e661d2
commit 659b9c32cb
2 changed files with 4 additions and 2 deletions

View file

@ -59,7 +59,7 @@ Cube::Cube(ModelPart* modelPart, int xTexOffs, int yTexOffs, float x0, float y0,
vertices[7] = l3;
// 4J - added ability to mask individual faces
int faceCount = 0;
faceCount = 0;
if (faceMask & 1)
polygons[faceCount++] = _Polygon(
std::array<const Vertex, 4>{l1, u1, u2, l2}, xTexOffs + d + w,
@ -107,7 +107,7 @@ Cube::Cube(ModelPart* modelPart, int xTexOffs, int yTexOffs, float x0, float y0,
}
void Cube::render(Tesselator* t, float scale) {
for (int i = 0; i < polygons.size(); i++) {
for (int i = 0; i < faceCount; i++) {
polygons[i].render(t, scale);
}
}

View file

@ -1,5 +1,6 @@
#pragma once
#include <array>
#include <cstdint>
#include "../../Minecraft.World/Util/ArrayWithLength.h"
#include "Vertex.h"
#include "Polygon.h"
@ -10,6 +11,7 @@ class Cube {
private:
std::array<Vertex, 8> vertices;
std::array<_Polygon, 6> polygons;
uint8_t faceCount;
public:
const float x0, y0, z0, x1, y1, z1;