]> git.lizzy.rs Git - dragonblocks_alpha.git/commitdiff
Fix MapBlock mesh neighbor face culling
authorElias Fleckenstein <eliasfleckenstein@web.de>
Sun, 28 Mar 2021 11:18:59 +0000 (13:18 +0200)
committerElias Fleckenstein <eliasfleckenstein@web.de>
Sun, 28 Mar 2021 11:18:59 +0000 (13:18 +0200)
src/mapblock_meshgen.c
src/mesh.c

index aaf4d6fd5167d5dfa7aa802798ee4249b5902717..db82edd7981696c46d7902591b361e4aa8d8d6ad 100644 (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,
index a4a7ff0a2a0da0085065e343d321ffb6386ce44c..295e39c57f93093e03e0c672ac09351077633ad0 100644 (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);