feat: TU0 leafs

This commit is contained in:
str1k3r committed 2026-10-10 13:45:33 -04:00
1 parent 6315c27226
commit 32b2e4f50e
4 files changed
+1 -80

No files matched your search

+1
View File
@@ -59,6 +59,7 @@ protected:
virtual int getSpawnResourcesAuxValue(int data);
public:
virtual bool isSolidRender(bool isServerLevel = false);
virtual bool isCubeShaped() { return false; }
virtual Icon *getTexture(int face, int data);
void setFancy(bool fancyGraphics);
-22
View File
@@ -2946,28 +2946,6 @@ bool Level::isSolidRenderTile(int x, int y, int z)
Tile *tile = Tile::tiles[getTile(x, y, z)];
if (tile == NULL) return false;
// 4J - addition here to make rendering big blocks of leaves more efficient. Normally leaves never consider themselves as solid, so
// blocks of leaves will have all sides of each block completely visible. Changing to consider as solid if this block is surrounded by
// other leaves (or solid things). This is paired with another change in Tile::getTexture which makes such solid tiles actually visibly solid (these
// textures exist already for non-fancy graphics). Note: this tile-specific code is here rather than making some new virtual method in the tiles,
// for the sake of efficiency - I don't imagine we'll be doing much more of this sort of thing
if( tile->id == Tile::leaves_Id )
{
int axo[6] = { 1,-1, 0, 0, 0, 0};
int ayo[6] = { 0, 0, 1,-1, 0, 0};
int azo[6] = { 0, 0, 0, 0, 1,-1};
for( int i = 0; i < 6; i++ )
{
int t = getTile(x + axo[i], y + ayo[i] , z + azo[i]);
if( ( t != Tile::leaves_Id ) && ( ( Tile::tiles[t] == NULL ) || !Tile::tiles[t]->isSolidRender() ) )
{
return false;
}
}
return true;
}
return tile->isSolidRender(!isClientSide);
}
-22
View File
@@ -254,28 +254,6 @@ bool Region::isSolidRenderTile(int x, int y, int z)
Tile *tile = Tile::tiles[getTile(x, y, z)];
if (tile == NULL) return false;
// 4J - addition here to make rendering big blocks of leaves more efficient. Normally leaves never consider themselves as solid, so
// blocks of leaves will have all sides of each block completely visible. Changing to consider as solid if this block is surrounded by
// other leaves (or solid things). This is paired with another change in Tile::getTexture which makes such solid tiles actually visibly solid (these
// textures exist already for non-fancy graphics). Note: this tile-specific code is here rather than making some new virtual method in the tiles,
// for the sake of efficiency - I don't imagine we'll be doing much more of this sort of thing
if( tile->id == Tile::leaves_Id )
{
int axo[6] = { 1,-1, 0, 0, 0, 0};
int ayo[6] = { 0, 0, 1,-1, 0, 0};
int azo[6] = { 0, 0, 0, 0, 1,-1};
for( int i = 0; i < 6; i++ )
{
int t = getTile(x + axo[i], y + ayo[i] , z + azo[i]);
if( ( t != Tile::leaves_Id ) && ( ( Tile::tiles[t] == NULL ) || !Tile::tiles[t]->isSolidRender() ) )
{
return false;
}
}
return true;
}
return tile->isSolidRender();
}
-36
View File
@@ -738,45 +738,9 @@ bool Tile::isSolidFace(LevelSource *level, int x, int y, int z, int face)
Icon *Tile::getTexture(LevelSource *level, int x, int y, int z, int face)
{
// 4J - addition here to make rendering big blocks of leaves more efficient. Normally leaves never consider themselves as solid, so
// blocks of leaves will have all sides of each block completely visible. Changing to consider as solid if this block is surrounded by
// other leaves (or solid things). This is paired with another change in Level::isSolidRenderTile/Region::isSolidRenderTile which makes things solid
// code-wise (ie for determining visible sides of neighbouring blocks). This change just makes the texture a solid one (tex + 1) which
// we already have in the texture map for doing non-fancy graphics. Note: this tile-specific code is here rather than making some new virtual
// method in the tiles, for the sake of efficiency - I don't imagine we'll be doing much more of this sort of thing
int tileId = level->getTile(x, y, z);
int tileData = level->getData(x, y, z);
if( tileId == Tile::leaves_Id )
{
bool opaque = true;
int axo[6] = { 1,-1, 0, 0, 0, 0};
int ayo[6] = { 0, 0, 1,-1, 0, 0};
int azo[6] = { 0, 0, 0, 0, 1,-1};
for( int i = 0; (i < 6) && opaque; i++ )
{
int t = level->getTile(x + axo[i], y + ayo[i] , z + azo[i]);
if( ( t != Tile::leaves_Id ) && ( ( Tile::tiles[t] == NULL ) || !Tile::tiles[t]->isSolidRender() ) )
{
opaque = false;
}
}
Icon *icon = NULL;
if(opaque)
{
Tile::leaves->setFancy(false);
icon = getTexture(face, tileData);
Tile::leaves->setFancy(true);
}
else
{
icon = getTexture(face, tileData);
}
return icon;
}
return getTexture(face, tileData);
}