mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-24 05:10:42 -04:00
Compare light colour instead of isLit, allows for custom lighting implementations.
This commit is contained in:
parent
fe7b494a84
commit
c9167859fb
@ -417,7 +417,8 @@ namespace ClassicalSharp {
|
||||
|
||||
int Lit(int x, int y, int z, int cIndex) {
|
||||
if (x < 0 || y < 0 || z < 0
|
||||
|| x >= width || y >= height || z >= length) return 7;
|
||||
|| x >= width || y >= height || z >= length) return 7; // all faces lit
|
||||
|
||||
int flags = 0;
|
||||
BlockID block = chunk[cIndex];
|
||||
int lightHeight = light.heightmap[(z * width) + x];
|
||||
@ -426,8 +427,10 @@ namespace ClassicalSharp {
|
||||
// Use fact Light(Y.Bottom) == Light((Y - 1).Top)
|
||||
int offset = (lightFlags >> Side.Bottom) & 1;
|
||||
flags |= ((y - offset) > lightHeight ? 1 : 0);
|
||||
|
||||
// Light is same for all the horizontal faces
|
||||
flags |= (y > lightHeight ? 2 : 0);
|
||||
|
||||
// Use fact Light((Y + 1).Bottom) == Light(Y.Top)
|
||||
offset = (lightFlags >> Side.Top) & 1;
|
||||
flags |= ((y - offset) >= lightHeight ? 4 : 0);
|
||||
|
@ -297,25 +297,6 @@ namespace ClassicalSharp {
|
||||
&& info.Draw[chunk[chunkIndex + 324 + 18]] != DrawType.Gas;
|
||||
}
|
||||
|
||||
protected bool IsLit(int x, int y, int z, int face, BlockID block) {
|
||||
int offset = (info.LightOffset[block] >> face) & 1;
|
||||
switch (face) {
|
||||
case Side.Left:
|
||||
return x < offset || y > light.heightmap[(z * width) + (x - offset)];
|
||||
case Side.Right:
|
||||
return x > (maxX - offset) || y > light.heightmap[(z * width) + (x + offset)];
|
||||
case Side.Front:
|
||||
return z < offset || y > light.heightmap[((z - offset) * width) + x];
|
||||
case Side.Back:
|
||||
return z > (maxZ - offset) || y > light.heightmap[((z + offset) * width) + x];
|
||||
case Side.Bottom:
|
||||
return y <= 0 || (y - 1 - offset) >= (light.heightmap[(z * width) + x]);
|
||||
case Side.Top:
|
||||
return y >= maxY || (y - offset) >= (light.heightmap[(z * width) + x]);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void OnNewMapLoaded() {
|
||||
map = game.World;
|
||||
env = game.World.Env;
|
||||
|
@ -67,11 +67,30 @@ namespace ClassicalSharp {
|
||||
return count;
|
||||
}
|
||||
|
||||
bool CanStretch(BlockID initialBlock, int chunkIndex, int x, int y, int z, int face) {
|
||||
BlockID rawBlock = chunk[chunkIndex];
|
||||
return rawBlock == initialBlock
|
||||
&& !info.IsFaceHidden(rawBlock, chunk[chunkIndex + offsets[face]], face)
|
||||
&& (fullBright || IsLit(X, Y, Z, face, initialBlock) == IsLit(x, y, z, face, rawBlock));
|
||||
bool CanStretch(BlockID initial, int chunkIndex, int x, int y, int z, int face) {
|
||||
BlockID cur = chunk[chunkIndex];
|
||||
return cur == initial
|
||||
&& !info.IsFaceHidden(cur, chunk[chunkIndex + offsets[face]], face)
|
||||
&& (fullBright || (LightCol(X, Y, Z, face, initial) == LightCol(x, y, z, face, cur)));
|
||||
}
|
||||
|
||||
int LightCol(int x, int y, int z, int face, BlockID block) {
|
||||
int offset = (info.LightOffset[block] >> face) & 1;
|
||||
switch (face) {
|
||||
case Side.Left:
|
||||
return x < offset ? light.OutsideXSide : light.LightCol_XSide_Fast(x, y, z);
|
||||
case Side.Right:
|
||||
return x > (maxX - offset) ? light.OutsideXSide : light.LightCol_XSide_Fast(x, y, z);
|
||||
case Side.Front:
|
||||
return z < offset ? light.OutsideZSide : light.LightCol_ZSide_Fast(x, y, z);
|
||||
case Side.Back:
|
||||
return z > (maxZ - offset) ? light.OutsideZSide : light.LightCol_ZSide_Fast(x, y, z);
|
||||
case Side.Bottom:
|
||||
return y <= 0 ? light.OutsideYBottom : light.LightCol_YBottom_Fast(x, y, z);
|
||||
case Side.Top:
|
||||
return y >= maxY ? light.Outside : light.LightCol_YTop_Fast(x, y, z);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected override void PreStretchTiles(int x1, int y1, int z1) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user