Turns out it was the semicolons at the end of the lines the if statements were in. This took make me way longer to realize than it should've. :/

This commit is contained in:
2022-10-30 17:05:11 -04:00
parent 3aa203bac9
commit a0bec8bfc5
4 changed files with 20 additions and 18 deletions

View File

@@ -63,18 +63,18 @@ class BlockManager
{
//if(x < 16 && x >= 0 && z < 16 && z >= 0)
//{
if(x < 0 || z < 0)
if(x < 0 || y < 0 || z < 0)
{
return 0;
}
Position2D block = BlockUtilities::getBlockFromNodeCoordinates(x, z);
//printf("\n\nold x: %i, old z: %i", x, z);
//int localX = x - block.x * 16;
//int localZ = z - block.z * 16;
int localX = x - block.x * 16;
int localZ = z - block.z * 16;
//printf("\nnew x: %i, new z: %i", x, z);
//return mapBlocks[block.x][block.z].mapBlock[256 * y + localZ * 16 + localX];
return mapBlocks[block.x][block.z].getNodeAt(x, y, z);
return mapBlocks[block.x][block.z].mapBlock[256 * y + localZ * 16 + localX];
//return mapBlocks[block.x][block.z].getNodeAt(x - block.x * 16, y, z - block.z * 16);
}
bool isAir(int x, int y, int z)

View File

@@ -25,7 +25,7 @@ class NodeRenderer
glBegin(GL_QUADS);
// Front
if(blockManager.mapBlocks[block.x][block.z].getNodeAt(x - block.x * 16, y, z - block.z * 16 - 1) == 0)
if(blockManager.isAir(x, y, z + 1))
{
glTexCoord2f(.0F, .0F);
glVertex3f(x + .0F, y + 1.0F, z + .0F);
@@ -43,7 +43,7 @@ class NodeRenderer
}
// Back
if(blockManager.mapBlocks[block.x][block.z].getNodeAt(x - block.x * 16, y, z - block.z * 16 + 1) == 0)
if(blockManager.isAir(x, y, z - 1))
{
glTexCoord2f(.0F, .0F);
@@ -62,7 +62,7 @@ class NodeRenderer
}
// Right
if(blockManager.mapBlocks[block.x][block.z].getNodeAt(x - block.x * 16 + 1, y, z - block.z * 16) == 0);
if(blockManager.isAir(x + 1, y, z))
{
glTexCoord2f(1.0F, .0F);
glVertex3f(x + 1.0F, y + 1.0F, z + .0F);
@@ -80,7 +80,7 @@ class NodeRenderer
}
// Left
if(blockManager.mapBlocks[block.x][block.z].getNodeAt(x - block.x * 16 - 1, y, z - block.z * 16) == 0);
if(blockManager.isAir(x - 1, y, z))
{
glTexCoord2f(1.0F, .0F);
glVertex3f(x + .0F, y + 1.0F, z + .0F);
@@ -98,8 +98,10 @@ class NodeRenderer
}
// Bottom
if(blockManager.getNodeAt(x, y - 1, z) == 0);
//printf("\n\nx: %i, y: %i, z: %i, VALUE: %s", x, y, z, blockManager.isAir(x, y - 1, z) ? "true" : "false");
if(blockManager.isAir(x, y - 1, z))
{
//printf("\nWUT? x: %i, y: %i, z: %i, VALUE: %s", x, y, z, blockManager.isAir(x, y - 1, z) ? "true" : "false");
glTexCoord2f(.0F, .0F);
glVertex3f(x + 1.0F, y + .0F, z + .0F);
@@ -114,7 +116,7 @@ class NodeRenderer
}
// Top
/*if(blockManager.mapBlocks[block.x][block.z].getNodeAt(x - block.x * 16, y + 1, z - block.z * 16) == 0);
if(blockManager.isAir(x, y + 1, z))
{
glTexCoord2f(.0F, .0F);
glVertex3f(x + 1.0F, y + 1.0F, z + .0F);
@@ -127,7 +129,7 @@ class NodeRenderer
glTexCoord2f(.0F, 1.0F);
glVertex3f(x + 1.0F, y + 1.0F, z + 1.0F);
}*/
}
glEnd();
return 1;