Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tile::shouldRenderFace logic cleanup #104

Merged
merged 1 commit into from
Dec 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 29 additions & 12 deletions source/world/tile/Tile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -754,18 +754,35 @@ void Tile::addAABBs(Level* pLevel, int x, int y, int z, const AABB* aabb, std::v

bool Tile::shouldRenderFace(LevelSource* pSrc, int x, int y, int z, int dir)
{
if (z == -1 && dir == DIR_ZNEG) return false;
if (z == C_MAX_CHUNKS_Z * 16 && dir == DIR_ZPOS) return false;
if (x == -1 && dir == DIR_XNEG) return false;
if (x == C_MAX_CHUNKS_X * 16 && dir == DIR_XPOS) return false;
if (y == -1 && dir == DIR_YNEG) return false;

if (dir == DIR_YNEG && m_aabb.min.y > 0.0f) return true;
if (dir == DIR_YPOS && m_aabb.max.y < 1.0f) return true;
if (dir == DIR_ZNEG && m_aabb.min.z > 0.0f) return true;
if (dir == DIR_ZPOS && m_aabb.max.z < 1.0f) return true;
if (dir == DIR_XNEG && m_aabb.min.x > 0.0f) return true;
if (dir == DIR_XPOS && m_aabb.max.x < 1.0f) return true;
//if ((y | x | z) > C_MAX_CHUNKS_Z * 16)
// return false;

switch (dir)
{
case DIR_ZNEG:
if (z == -1) return false;
if (m_aabb.min.z > 0.0f) return true;
break;
case DIR_ZPOS:
if (z == C_MAX_CHUNKS_Z * 16) return false;
if (m_aabb.max.z < 1.0f) return true;
break;
case DIR_XNEG:
if (x == -1) return false;
if (m_aabb.min.x > 0.0f) return true;
break;
case DIR_XPOS:
if (x == C_MAX_CHUNKS_X * 16) return false;
if (m_aabb.max.x < 1.0f) return true;
break;
case DIR_YNEG:
if (y == -1) return false;
if (m_aabb.min.y > 0.0f) return true;
break;
case DIR_YPOS:
if (m_aabb.max.y < 1.0f) return true;
break;
}

Tile* pTile = Tile::tiles[pSrc->getTile(x, y, z)];
if (!pTile)
Expand Down