summaryrefslogtreecommitdiff
path: root/quadtree.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'quadtree.cpp')
-rw-r--r--quadtree.cpp30
1 files changed, 23 insertions, 7 deletions
diff --git a/quadtree.cpp b/quadtree.cpp
index 8bc366c..c60fd27 100644
--- a/quadtree.cpp
+++ b/quadtree.cpp
@@ -238,18 +238,34 @@ void Quadtree::QuadChunk::make_vbo() {
for(unsigned int index = 0; index < node_count; index++) {
Quadtree::QuadNode *node = nodes[index];
- float tex_coords[4][3][2] = {
- {{.5, .5}, {0, 0}, {0, 1}},
- {{.5, .5}, {0, 1}, {1, 1}},
- {{.5, .5}, {1, 1}, {1, 0}},
- {{.5, .5}, {1, 0}, {0, 0}}
+ float tex_coords[4][4][3][2] = {
+ {{{.25, .25}, {0, 0}, {0, .5}},
+ {{.25, .25}, {0, .5}, {.5, .5}},
+ {{.25, .25}, {.5, .5}, {.5, 0}},
+ {{.25, .25}, {.5, 0}, {0, 0}}},
+
+ {{{.75, .25}, {.5, 0}, {.5, .5}},
+ {{.75, .25}, {.5, .5}, {1, .5}},
+ {{.75, .25}, {1, .5}, {1, 0}},
+ {{.75, .25}, {1, 0}, {.5, 0}}},
+
+ {{{.25, .75}, {0, .5}, {0, 1}},
+ {{.25, .75}, {0, 1}, {.5, 1}},
+ {{.25, .75}, {.5, 1}, {.5, .5}},
+ {{.25, .75}, {.5, .5}, {0, .5}}},
+
+ {{{.75, .75}, {.5, .5}, {.5, 1}},
+ {{.75, .75}, {.5, 1}, {1, 1}},
+ {{.75, .75}, {1, 1}, {1, .5}},
+ {{.75, .75}, {1, .5}, {.5, .5}}}
};
for(int i = 0; i < 4; i++) {
float *v = buffer + vertex_chunk_size*index + 3*3*i;
for(int j = 0; j < 3; j++) {
float *tc = buffer + vertices_size + normals_size + tex_coord_chunk_size*index + 6*i + 2*j;
- tc[0] = tex_coords[i][j][0]*node->width;
- tc[1] = tex_coords[i][j][1]*node->height;
+ int k = (fmodf(node->x, 2) == 0 ? 1 : 0) + (fmodf(node->y, 2) == 0 ? 2 : 0);
+ tc[0] = tex_coords[k][i][j][0]*node->width;
+ tc[1] = tex_coords[k][i][j][1]*node->height;
}
v[0] = node->vertex_array[0];