mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-16 19:15:14 -04:00
Fix heightmaps sometimes being updated incorrectly. (Thanks goodlyay)
This commit is contained in:
parent
0b8582eb78
commit
39f315e12a
@ -31,7 +31,7 @@ namespace ClassicalSharp {
|
|||||||
if( min.Z != 0 ) flags &= ~(1 << TileSide.Front);
|
if( min.Z != 0 ) flags &= ~(1 << TileSide.Front);
|
||||||
if( max.Z != 1 ) flags &= ~(1 << TileSide.Back);
|
if( max.Z != 1 ) flags &= ~(1 << TileSide.Back);
|
||||||
|
|
||||||
if( (min.Y != 0 && max.Y == 1) || IsAir[tile] ) {
|
if( (min.Y != 0 && max.Y == 1) && !IsAir[tile] ) {
|
||||||
flags &= ~(1 << TileSide.Top);
|
flags &= ~(1 << TileSide.Top);
|
||||||
flags &= ~(1 << TileSide.Bottom);
|
flags &= ~(1 << TileSide.Bottom);
|
||||||
}
|
}
|
||||||
|
@ -104,8 +104,8 @@ namespace ClassicalSharp {
|
|||||||
|
|
||||||
InitBoundingBoxes();
|
InitBoundingBoxes();
|
||||||
InitSounds();
|
InitSounds();
|
||||||
InitLightOffsets();
|
|
||||||
SetupCullingCache();
|
SetupCullingCache();
|
||||||
|
InitLightOffsets();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetDefaultBlockPermissions( InventoryPermissions canPlace, InventoryPermissions canDelete ) {
|
public void SetDefaultBlockPermissions( InventoryPermissions canPlace, InventoryPermissions canDelete ) {
|
||||||
|
@ -25,7 +25,8 @@ namespace ClassicalSharp {
|
|||||||
bool didBlock = info.BlocksLight[oldBlock];
|
bool didBlock = info.BlocksLight[oldBlock];
|
||||||
bool nowBlocks = info.BlocksLight[newBlock];
|
bool nowBlocks = info.BlocksLight[newBlock];
|
||||||
if( didBlock == nowBlocks ) return;
|
if( didBlock == nowBlocks ) return;
|
||||||
int offset = (info.LightOffset[newBlock] >> TileSide.Top) & 1;
|
int oldOffset = (info.LightOffset[oldBlock] >> TileSide.Top) & 1;
|
||||||
|
int newOffset = (info.LightOffset[newBlock] >> TileSide.Top) & 1;
|
||||||
|
|
||||||
int index = (z * Width) + x;
|
int index = (z * Width) + x;
|
||||||
int height = heightmap[index];
|
int height = heightmap[index];
|
||||||
@ -33,16 +34,19 @@ namespace ClassicalSharp {
|
|||||||
// We have to calculate the entire column for visibility, because the old/new block info is
|
// We have to calculate the entire column for visibility, because the old/new block info is
|
||||||
// useless if there is another block higher than block.y that blocks sunlight.
|
// useless if there is another block higher than block.y that blocks sunlight.
|
||||||
CalcHeightAt( x, maxY, z, index );
|
CalcHeightAt( x, maxY, z, index );
|
||||||
} else if( (y - offset >= height) ) {
|
} else if( (y - newOffset >= height) ) {
|
||||||
if( nowBlocks ) {
|
if( nowBlocks ) {
|
||||||
heightmap[index] = (short)(y - offset);
|
heightmap[index] = (short)(y - newOffset);
|
||||||
} else {
|
} else {
|
||||||
// Part of the column is now visible to light, we don't know how exactly how high it should be though.
|
// Part of the column is now visible to light, we don't know how exactly how high it should be though.
|
||||||
// However, we know that if the old block was above or equal to light height, then the new light height must be <= old block.y
|
// However, we know that if the old block was above or equal to light height, then the new light height must be <= old block.y
|
||||||
CalcHeightAt( x, y, z, index );
|
CalcHeightAt( x, y, z, index );
|
||||||
}
|
}
|
||||||
} else {
|
} else if( y == height && oldOffset == 0 ) {
|
||||||
CalcHeightAt( x, maxY, z, index );
|
if( nowBlocks )
|
||||||
|
heightmap[index] = (short)(y - newOffset);
|
||||||
|
else
|
||||||
|
CalcHeightAt( x, y - 1, z, index );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user