QcLightVolume Class
Block light of a box-shaped volume of cells: sources flood outwards breadth-first, every step into a cell costs max(1, opacity of that cell) levels, cells of opacity 15 stay dark and no step crosses a face that a partial shape covers (QcLightPassage). More...
| Header: | #include <common/world/QcLightVolume.h> |
Public Functions
| void | addSource(int x, int y, int z, int level) |
| bool | contains(int x, int y, int z) const |
| bool | hasSources() const |
| int | level(int x, int y, int z) const |
| void | propagate() |
| void | setOpacity(int x, int y, int z, int opacity, quint8 blockedFaces = 0) |
| int | sizeX() const |
| int | sizeY() const |
| int | sizeZ() const |
Static Public Members
| bool | anySourceNear(const QcContentRegistry &content, QcBlockPos pos, int reach, const std::function<const QcChunk *(QcChunkPos)> &chunkAt) |
| int | blockLightAt(const QcBlockAccess &world, QcBlockPos pos) |
| const int | maxLevel |
Detailed Description
The result is the unique fixpoint "brightest source minus cheapest path", so recomputing a volume after a change (a torch removed) gives exactly what an incremental update would. Cells outside read 0.
Member Function Documentation
void QcLightVolume::addSource(int x, int y, int z, int level)
Adds a source in the cell (x, y, z): it shines with level in its own cell, whatever that cell's opacity.
[static] bool QcLightVolume::anySourceNear(const QcContentRegistry &content, QcBlockPos pos, int reach, const std::function<const QcChunk *(QcChunkPos)> &chunkAt)
Returns whether the sections of the chunks chunkAt returns within reach of pos hold a block of content that emits light (palette check, no block reads).
[static] int QcLightVolume::blockLightAt(const QcBlockAccess &world, QcBlockPos pos)
Returns the block light at pos of world, from all sources within reach (unloaded cells are dark walls).
bool QcLightVolume::contains(int x, int y, int z) const
Returns whether the cell (x, y, z) lies in the volume.
bool QcLightVolume::hasSources() const
Returns whether sources wait to be flooded.
int QcLightVolume::level(int x, int y, int z) const
Returns the level of the cell (x, y, z); 0 outside.
void QcLightVolume::propagate()
Floods all sources added so far.
void QcLightVolume::setOpacity(int x, int y, int z, int opacity, quint8 blockedFaces = 0)
Sets the opacity of the cell (x, y, z) to opacity (clamped to 0..15); blockedFaces: faces of the cell light cannot cross (QcLightPassage bits). Cells outside are ignored.
int QcLightVolume::sizeX() const
Returns the volume's size along x.
int QcLightVolume::sizeY() const
Returns the volume's size along y.
int QcLightVolume::sizeZ() const
Returns the volume's size along z.
Member Variable Documentation
const int QcLightVolume::maxLevel
The highest light level.