Fix relight and removelight (#475)

* Start work on lighting engine (does not build)

* Implement getLighting

* Setting, flushing light etc works. Getting light should be working..?

* Better queue/chunk handling

* Use correct location for lighting update

* Correct set location, remove debug

* cleanup a little

* Fix fixlight

* Apply to all versions for the numpties

* Remove lighting extent if not using

* Actually bitmask blocks when setting in chunks

* Initialise Maps and Dequeues with inital size

* format

* Documentation maybe
This commit is contained in:
dordsor21
2020-05-27 11:45:08 +01:00
committed by GitHub
parent 1ff5e7761b
commit bdc14c10c7
27 changed files with 1910 additions and 93 deletions

View File

@ -205,6 +205,46 @@ public class AbstractDelegateExtent implements Extent {
public boolean setBiome(BlockVector2 position, BiomeType biome) {
return extent.setBiome(position.getX(), 0, position.getZ(), biome);
}
@Override
public boolean relight(int x, int y, int z) {
return extent.relight(x, y, z);
}
@Override
public boolean relightBlock(int x, int y, int z) {
return extent.relightBlock(x, y, z);
}
@Override
public boolean relightSky(int x, int y, int z) {
return extent.relightSky(x, y, z);
}
@Override
public void setSkyLight(int x, int y, int z, int value) {
extent.setSkyLight(x, y, z, value);
}
@Override
public void setBlockLight(int x, int y, int z, int value) {
extent.setSkyLight(x, y, z, value);
}
@Override
public int getSkyLight(int x, int y, int z) {
return extent.getSkyLight(x, y, z);
}
@Override
public int getEmmittedLight(int x, int y, int z) {
return extent.getEmmittedLight(x, y, z);
}
@Override
public int getBrightness(int x, int y, int z) {
return extent.getBrightness(x, y, z);
}
@Override
public String toString() {

View File

@ -651,6 +651,18 @@ public interface Extent extends InputExtent, OutputExtent {
return count;
}
default boolean relight(int x, int y, int z) {
return false;
}
default boolean relightBlock(int x, int y, int z) {
return false;
}
default boolean relightSky(int x, int y, int z) {
return false;
}
/**
* Have an extent processed
* - Either block (Extent) processing or chunk processing

View File

@ -85,4 +85,48 @@ public interface InputExtent {
default BiomeType getBiomeType(int x, int y, int z) {
return getBiome(MutableBlockVector2.get(x, z));
}
/**
* Get the light level at the given location
*
* @param position location
* @return the light level at the location
*/
default int getEmmittedLight(MutableBlockVector3 position) {
return getEmmittedLight(position.getX(), position.getY(), position.getZ());
}
default int getEmmittedLight(int x, int y, int z) {
return 0;
}
/**
* Get the sky light level at the given location
*
* @param position location
* @return the sky light level at the location
*/
default int getSkyLight(MutableBlockVector3 position) {
return getSkyLight(position.getX(), position.getY(), position.getZ());
}
default int getSkyLight(int x, int y, int z) {
return 0;
}
default int getBrightness(MutableBlockVector3 position) {
return getBrightness(position.getX(), position.getY(), position.getZ());
}
default int getBrightness(int x, int y, int z) {
return getFullBlock(x, y, z).getMaterial().getLightValue();
}
default int getOpacity(MutableBlockVector3 position) {
return getOpacity(position.getX(), position.getY(), position.getZ());
}
default int getOpacity(int x, int y, int z) {
return getFullBlock(x, y, z).getMaterial().getLightOpacity();
}
}

View File

@ -82,6 +82,30 @@ public interface OutputExtent {
return setBiome(MutableBlockVector2.get(x, z), biome);
}
/**
* Set the light value
*
* @param position position of the block
* @param value light level to set
*/
default void setBlockLight(BlockVector3 position, int value) {
setBlockLight(position.getX(), position.getY(), position.getZ(), value);
}
default void setBlockLight(int x, int y, int z, int value) {}
/**
* Set the sky light value
*
* @param position position of the block
* @param value light level to set
*/
default void setSkyLight(BlockVector3 position, int value) {
setSkyLight(position.getX(), position.getY(), position.getZ(), value);
}
default void setSkyLight(int x, int y, int z, int value) {}
/**
* Return an {@link Operation} that should be called to tie up loose ends
* (such as to commit changes in a buffer).