Support for more than one mapblock/chunk | WARNING: Shitty performance, even on RTX 3070

This commit is contained in:
2022-10-29 14:09:42 -04:00
parent 6b05eaf331
commit 8cde72f632
4 changed files with 59 additions and 45 deletions

View File

@@ -6,10 +6,12 @@
class NodeManager;
class BlockManager;
extern NodeManager nodeManager;
extern BlockManager blockManager;
struct Position2D
{
int x;

View File

@@ -19,9 +19,12 @@ class NodeRenderer
int renderNode(int x, int y, int z)
{
Position2D block = BlockUtilities::getBlockFromNodeCoordinates(x, z); // The block the node at (x, y, z) is in
glBegin(GL_QUADS);
// Front
if(nodeManager.isAir(x, y, z - 1))
if(blockManager.mapBlocks[block.x][block.z].isAir(x, y, z - 1))
{
glTexCoord2f(.0F, .0F);
glVertex3f(x + .0F, y + 1.0F, z + .0F);
@@ -37,7 +40,7 @@ class NodeRenderer
}
// Back
if(nodeManager.isAir(x, y, z + 1))
if(blockManager.mapBlocks[block.x][block.z].isAir(x, y, z + 1))
{
glTexCoord2f(.0F, .0F);
glVertex3f(x + .0F, y + 1.0F, z + 1.0F);
@@ -53,7 +56,7 @@ class NodeRenderer
}
// Right
if(nodeManager.isAir(x + 1, y, z))
if(blockManager.mapBlocks[block.x][block.z].isAir(x + 1, y, z))
{
glTexCoord2f(1.0F, .0F);
glVertex3f(x + 1.0F, y + 1.0F, z + .0F);
@@ -69,7 +72,7 @@ class NodeRenderer
}
// Left
if(nodeManager.isAir(x - 1, y, z))
if(blockManager.mapBlocks[block.x][block.z].isAir(x - 1, y, z))
{
glTexCoord2f(1.0F, .0F);
glVertex3f(x + .0F, y + 1.0F, z + .0F);
@@ -85,7 +88,7 @@ class NodeRenderer
}
// Bottom
if(nodeManager.getNodeAt(x, y - 1, z) == 0)
if(blockManager.mapBlocks[block.x][block.z].getNodeAt(x, y - 1, z) == 0)
{
glTexCoord2f(.0F, .0F);
glVertex3f(x + 1.0F, y + .0F, z + .0F);
@@ -101,7 +104,7 @@ class NodeRenderer
}
// Top
if(nodeManager.getNodeAt(x, y + 1, z) == 0)
if(blockManager.mapBlocks[block.x][block.z].getNodeAt(x, y + 1, z) == 0)
{
glTexCoord2f(.0F, .0F);
glVertex3f(x + 1.0F, y + 1.0F, z + .0F);

View File

@@ -54,15 +54,15 @@ class TextureHandler
{
if(nodeManager.getNodeAt(x, y, z) == 1)
{
//if(nodeManager.getNodeAt(x, y, z) == 1)
//{
glBindTexture(GL_TEXTURE_2D, textures);
}
//}
else if(nodeManager.getNodeAt(x, y, z) == 2)
{
glBindTexture(GL_TEXTURE_2D, textures1);
}
//else if(nodeManager.getNodeAt(x, y, z) == 2)
//{
//glBindTexture(GL_TEXTURE_2D, textures1);
//}
}