Performance fixes part 1
This commit is contained in:
parent
8cde72f632
commit
8365b148d0
@ -24,7 +24,7 @@ class NodeRenderer
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
// Front
|
||||
if(blockManager.mapBlocks[block.x][block.z].isAir(x, y, z - 1))
|
||||
if(blockManager.mapBlocks[block.x][block.z].isAir(x - block.x * 16, y, z - block.z * 16 - 1))
|
||||
{
|
||||
glTexCoord2f(.0F, .0F);
|
||||
glVertex3f(x + .0F, y + 1.0F, z + .0F);
|
||||
@ -40,7 +40,7 @@ class NodeRenderer
|
||||
}
|
||||
|
||||
// Back
|
||||
if(blockManager.mapBlocks[block.x][block.z].isAir(x, y, z + 1))
|
||||
if(blockManager.mapBlocks[block.x][block.z].isAir(x - block.x * 16, y, z - block.z * 16 + 1))
|
||||
{
|
||||
glTexCoord2f(.0F, .0F);
|
||||
glVertex3f(x + .0F, y + 1.0F, z + 1.0F);
|
||||
@ -56,7 +56,7 @@ class NodeRenderer
|
||||
}
|
||||
|
||||
// Right
|
||||
if(blockManager.mapBlocks[block.x][block.z].isAir(x + 1, y, z))
|
||||
if(blockManager.mapBlocks[block.x][block.z].isAir(x - block.x * 16 + 1, y, z - block.z * 16))
|
||||
{
|
||||
glTexCoord2f(1.0F, .0F);
|
||||
glVertex3f(x + 1.0F, y + 1.0F, z + .0F);
|
||||
@ -72,7 +72,7 @@ class NodeRenderer
|
||||
}
|
||||
|
||||
// Left
|
||||
if(blockManager.mapBlocks[block.x][block.z].isAir(x - 1, y, z))
|
||||
if(blockManager.mapBlocks[block.x][block.z].isAir(x - block.x * 16 - 1, y, z - block.z * 16))
|
||||
{
|
||||
glTexCoord2f(1.0F, .0F);
|
||||
glVertex3f(x + .0F, y + 1.0F, z + .0F);
|
||||
@ -88,7 +88,7 @@ class NodeRenderer
|
||||
}
|
||||
|
||||
// Bottom
|
||||
if(blockManager.mapBlocks[block.x][block.z].getNodeAt(x, y - 1, z) == 0)
|
||||
if(blockManager.mapBlocks[block.x][block.z].getNodeAt(x - block.x * 16, y - 1, z - block.z * 16) == 0)
|
||||
{
|
||||
glTexCoord2f(.0F, .0F);
|
||||
glVertex3f(x + 1.0F, y + .0F, z + .0F);
|
||||
@ -104,7 +104,7 @@ class NodeRenderer
|
||||
}
|
||||
|
||||
// Top
|
||||
if(blockManager.mapBlocks[block.x][block.z].getNodeAt(x, y + 1, z) == 0)
|
||||
if(blockManager.mapBlocks[block.x][block.z].getNodeAt(x - block.x * 16, y + 1, z - block.z * 16) == 0)
|
||||
{
|
||||
glTexCoord2f(.0F, .0F);
|
||||
glVertex3f(x + 1.0F, y + 1.0F, z + .0F);
|
||||
|
6
main.cpp
6
main.cpp
@ -39,9 +39,9 @@ void display()
|
||||
glBegin(GL_QUADS);
|
||||
|
||||
|
||||
for(int x = 0; x < 128; x++)
|
||||
for(int x = 0; x < 64; x++)
|
||||
{
|
||||
for(int z = 0; z < 128; z++)
|
||||
for(int z = 0; z < 64; z++)
|
||||
{
|
||||
for(int y = 0; y < 256; y++)
|
||||
{
|
||||
@ -176,7 +176,7 @@ int main(int argc, char **argv)
|
||||
{
|
||||
for(int y = 0; y < 16; y++)
|
||||
{
|
||||
blockManager.mapBlocks[bx][bz].addNode(rand() % 3, 0, x, y, z);
|
||||
blockManager.mapBlocks[bx][bz].addNode(1, 0, x, y, z);
|
||||
//printf("\nGet node at: %i\n Is air: %i", nodeManager.getNodeAt(x, y + 1, z) == 0, nodeManager.isAir(x, y + 1, z));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user