mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-13 17:47:12 -04:00
Client should draw blocks at map boundaries.
This commit is contained in:
parent
c756094023
commit
60b87b7a6f
@ -22,7 +22,7 @@ namespace ClassicalSharp {
|
|||||||
game.TerrainAtlasChanged += TerrainAtlasChanged;
|
game.TerrainAtlasChanged += TerrainAtlasChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
int width, length, height;
|
internal int width, length, height, edgeLevel;
|
||||||
int maxX, maxY, maxZ;
|
int maxX, maxY, maxZ;
|
||||||
byte[] counts = new byte[chunkSize3 * TileSide.Sides];
|
byte[] counts = new byte[chunkSize3 * TileSide.Sides];
|
||||||
byte[] chunk = new byte[extChunkSize3];
|
byte[] chunk = new byte[extChunkSize3];
|
||||||
@ -92,6 +92,8 @@ namespace ClassicalSharp {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( x1 == 0 || y1 == 0 || z1 == 0 || x1 + chunkSize >= width ||
|
||||||
|
y1 + chunkSize >= height || z1 + chunkSize >= length ) allSolid = false;
|
||||||
if( !( allAir || allSolid ) ) {
|
if( !( allAir || allSolid ) ) {
|
||||||
map.HeightmapHint( x1 - 1, z1 - 1, mapPtr );
|
map.HeightmapHint( x1 - 1, z1 - 1, mapPtr );
|
||||||
}
|
}
|
||||||
@ -124,8 +126,8 @@ namespace ClassicalSharp {
|
|||||||
|
|
||||||
int leftCount = counts[index++], rightCount = counts[index++],
|
int leftCount = counts[index++], rightCount = counts[index++],
|
||||||
frontCount = counts[index++], backCount = counts[index++],
|
frontCount = counts[index++], backCount = counts[index++],
|
||||||
bottomCount = counts[index++], topCount = counts[index++];
|
bottomCount = counts[index++], topCount = counts[index++];
|
||||||
if( leftCount == 0 && rightCount == 0 && frontCount == 0 &&
|
if( leftCount == 0 && rightCount == 0 && frontCount == 0 &&
|
||||||
backCount == 0 && bottomCount == 0 && topCount == 0 ) return;
|
backCount == 0 && bottomCount == 0 && topCount == 0 ) return;
|
||||||
|
|
||||||
emitsLight = info.emitsLight[tile];
|
emitsLight = info.emitsLight[tile];
|
||||||
@ -191,10 +193,9 @@ namespace ClassicalSharp {
|
|||||||
|
|
||||||
void TestAndStretchX( int xx, int index, byte tile, int chunkIndex, int value, int test, int tileSide, int offset ) {
|
void TestAndStretchX( int xx, int index, byte tile, int chunkIndex, int value, int test, int tileSide, int offset ) {
|
||||||
index += tileSide;
|
index += tileSide;
|
||||||
if( value == test ) {
|
if( counts[index] != 0 ) {
|
||||||
counts[index] = 0;
|
if( (value == test && Y < edgeLevel) ||
|
||||||
} else if( counts[index] != 0 ) {
|
(value != test && info.IsFaceHidden( tile, chunk[chunkIndex + offset], tileSide )) ) {
|
||||||
if( info.IsFaceHidden( tile, chunk[chunkIndex + offset], tileSide ) ) {
|
|
||||||
counts[index] = 0;
|
counts[index] = 0;
|
||||||
} else {
|
} else {
|
||||||
int count = StretchX( xx, index, X, Y, Z, chunkIndex, tile, tileSide );
|
int count = StretchX( xx, index, X, Y, Z, chunkIndex, tile, tileSide );
|
||||||
@ -206,10 +207,9 @@ namespace ClassicalSharp {
|
|||||||
|
|
||||||
void TestAndStretchZ( int zz, int index, byte tile, int chunkIndex, int value, int test, int tileSide, int offset ) {
|
void TestAndStretchZ( int zz, int index, byte tile, int chunkIndex, int value, int test, int tileSide, int offset ) {
|
||||||
index += tileSide;
|
index += tileSide;
|
||||||
if( value == test ) {
|
if( counts[index] != 0 ) {
|
||||||
counts[index] = 0;
|
if( (value == test && Y < edgeLevel) ||
|
||||||
} else if( counts[index] != 0 ) {
|
(value != test && info.IsFaceHidden( tile, chunk[chunkIndex + offset], tileSide )) ) {
|
||||||
if( info.IsFaceHidden( tile, chunk[chunkIndex + offset], tileSide ) ) {
|
|
||||||
counts[index] = 0;
|
counts[index] = 0;
|
||||||
} else {
|
} else {
|
||||||
int count = StretchZ( zz, index, X, Y, Z, chunkIndex, tile, tileSide );
|
int count = StretchZ( zz, index, X, Y, Z, chunkIndex, tile, tileSide );
|
||||||
@ -219,7 +219,7 @@ namespace ClassicalSharp {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
byte GetNeighbour( int chunkIndex, int face ) {
|
byte GetNeighbour( int chunkIndex, int face ) {
|
||||||
switch( face ) {
|
switch( face ) {
|
||||||
case TileSide.Left:
|
case TileSide.Left:
|
||||||
return chunk[chunkIndex - 1]; // x - 1
|
return chunk[chunkIndex - 1]; // x - 1
|
||||||
@ -248,7 +248,7 @@ namespace ClassicalSharp {
|
|||||||
chunkIndex++;
|
chunkIndex++;
|
||||||
countIndex += TileSide.Sides;
|
countIndex += TileSide.Sides;
|
||||||
int max = chunkSize - xx;
|
int max = chunkSize - xx;
|
||||||
while( count < max && x < width && CanStretch( tile, chunkIndex, x, y, z, face ) ) {
|
while( count < max && x < width && CanStretch( tile, chunkIndex, x, y, z, face ) ) {
|
||||||
counts[countIndex] = 0;
|
counts[countIndex] = 0;
|
||||||
count++;
|
count++;
|
||||||
x++;
|
x++;
|
||||||
@ -264,7 +264,7 @@ namespace ClassicalSharp {
|
|||||||
chunkIndex += extChunkSize;
|
chunkIndex += extChunkSize;
|
||||||
countIndex += chunkSize * TileSide.Sides;
|
countIndex += chunkSize * TileSide.Sides;
|
||||||
int max = chunkSize - zz;
|
int max = chunkSize - zz;
|
||||||
while( count < max && z < length && CanStretch( tile, chunkIndex, x, y, z, face ) ) {
|
while( count < max && z < length && CanStretch( tile, chunkIndex, x, y, z, face ) ) {
|
||||||
counts[countIndex] = 0;
|
counts[countIndex] = 0;
|
||||||
count++;
|
count++;
|
||||||
z++;
|
z++;
|
||||||
@ -282,6 +282,7 @@ namespace ClassicalSharp {
|
|||||||
width = map.Width;
|
width = map.Width;
|
||||||
height = map.Height;
|
height = map.Height;
|
||||||
length = map.Length;
|
length = map.Length;
|
||||||
|
edgeLevel = map.GroundHeight;
|
||||||
maxX = width - 1;
|
maxX = width - 1;
|
||||||
maxY = height - 1;
|
maxY = height - 1;
|
||||||
maxZ = length - 1;
|
maxZ = length - 1;
|
||||||
|
@ -69,6 +69,9 @@ namespace ClassicalSharp {
|
|||||||
void EnvVariableChanged( object sender, EnvVariableEventArgs e ) {
|
void EnvVariableChanged( object sender, EnvVariableEventArgs e ) {
|
||||||
if( e.Var == EnvVariable.SunlightColour || e.Var == EnvVariable.ShadowlightColour ) {
|
if( e.Var == EnvVariable.SunlightColour || e.Var == EnvVariable.ShadowlightColour ) {
|
||||||
Refresh();
|
Refresh();
|
||||||
|
} else if( e.Var == EnvVariable.WaterLevel ) {
|
||||||
|
builder.edgeLevel = game.Map.WaterHeight;
|
||||||
|
Refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user