mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-05-21 02:12:54 +00:00
fix: OOB when iterating over all cube faces
This commit is contained in:
parent
f614e661d2
commit
659b9c32cb
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue