Fix MapBlock mesh neighbor face culling

master
Elias Fleckenstein 2021-03-28 13:18:59 +02:00
parent 7ae0264a8e
commit 1f8adc5b6d
2 changed files with 4 additions and 3 deletions

View File

@ -92,7 +92,7 @@ static Array make_vertices(MapBlock *block)
pos.y + noff->y,
pos.z + noff->z,
};
if (VALIDPOS(npos) && ! GNODDEF(block, npos.x, npos.y, npos.z).visible) {
if (! VALIDPOS(npos) || ! GNODDEF(block, npos.x, npos.y, npos.z).visible) {
for (int v = 0; v < 6; v++) {
Vertex vertex = {
vpos[f][v].x + offset.x,

View File

@ -1,4 +1,5 @@
#include <stdlib.h>
#include <stddef.h>
#include "mesh.h"
Mesh *mesh_create(Vertex *vertices, GLsizei count)
@ -50,9 +51,9 @@ static void mesh_configure(Mesh *mesh)
glBufferData(GL_ARRAY_BUFFER, mesh->count * sizeof(Vertex), mesh->vertices, GL_STATIC_DRAW);
glVertexAttribPointer(0, 3, GL_FLOAT, false, sizeof(Vertex), (GLvoid *)(0 * sizeof(GLfloat)));
glVertexAttribPointer(0, 3, GL_FLOAT, false, sizeof(Vertex), (GLvoid *) offsetof(Vertex, x));
glEnableVertexAttribArray(0);
glVertexAttribPointer(1, 3, GL_FLOAT, false, sizeof(Vertex), (GLvoid *)(3 * sizeof(GLfloat)));
glVertexAttribPointer(1, 3, GL_FLOAT, false, sizeof(Vertex), (GLvoid *) offsetof(Vertex, r));
glEnableVertexAttribArray(1);
glBindBuffer(GL_ARRAY_BUFFER, 0);