Performance improved.

This commit is contained in:
Quentin BAZIN 2013-05-22 15:59:53 +02:00
parent 9bdeb94374
commit 89a4b19e1c
3 changed files with 4 additions and 7 deletions

View File

@ -27,7 +27,7 @@
#define APP_LABEL "KubKraft"
#define DIST_NEAR 0.1
#define DIST_FAR (8 << 3)
#define DIST_FAR (16 << 3)
#define CHUNK_WIDTH 8
#define CHUNK_DEPTH 8

View File

@ -266,9 +266,9 @@ void Chunk::refreshVBO() {
if ((cube == NULL) || (cube->type() == 0)) {
for(int j = 0 ; j < 4 ; j++) {
vertices.push_back(x + cubeCoords[(i * 12) + (j * 3)]);
vertices.push_back(y + cubeCoords[(i * 12) + (j * 3) + 1]);
vertices.push_back(z + cubeCoords[(i * 12) + (j * 3) + 2]);
vertices.push_back(m_x + x + cubeCoords[(i * 12) + (j * 3)]);
vertices.push_back(m_y + y + cubeCoords[(i * 12) + (j * 3) + 1]);
vertices.push_back(m_z + z + cubeCoords[(i * 12) + (j * 3) + 2]);
texCoords.push_back(getTexOffsetU(qe->type(), i, qe) + (cubeCoords[48 + (j * 3)] * 0.125));
texCoords.push_back(getTexOffsetV(qe->type()) + (cubeCoords[48 + (j * 3) + 1] * 0.125));
colors.push_back(grey[i]);

View File

@ -288,10 +288,7 @@ void Map::render() {
for(int i = 0 ; i < ((m_width >> 3) * (m_depth >> 3) * (m_height >> 3)); i++) {
if(cubeInFrustum(m_chunks[i]->x(), m_chunks[i]->y(), m_chunks[i]->z(), 8)) {
glPushMatrix();
glTranslatef(float(m_chunks[i]->x()), float(m_chunks[i]->y()), float(m_chunks[i]->z()));
m_chunks[i]->render();
glPopMatrix();
}
}