QtCraft API C++ classes QML types Handbook

QcBlockLightEngine Class

Block light of all loaded chunks on the client (decision E-049): the shared QcLightEngine (decision E-389) with block light only, plus immutable section snapshots for the mesher. More...

Header: #include <clientcore/light/QcBlockLightEngine.h>

Public Types

struct Changes
struct SectionUpdate

Public Functions

void addChunk(std::shared_ptr<const QcChunk> chunk)
void changeBlock(QcBlockPos pos, std::shared_ptr<const QcChunk> chunk)
bool hasChunk(QcChunkPos pos) const
int level(QcBlockPos pos) const
void removeChunk(QcChunkPos pos)
QcChunkLight snapshot(QcChunkPos pos) const
QcBlockLightEngine::Changes takeChanges()
quint64 visitedCells() const

Detailed Description

The engine keeps the light up to date incrementally; takeChanges() publishes the sections whose levels differ from their last snapshot and names the sections whose meshes read a changed cell. Sky light stays in the mesher. Not thread-safe: one thread uses it.

Member Function Documentation

void QcBlockLightEngine::addChunk(std::shared_ptr<const QcChunk> chunk)

Adds the snapshot chunk and spreads the light of its sources and of its neighbours into it.

void QcBlockLightEngine::changeBlock(QcBlockPos pos, std::shared_ptr<const QcChunk> chunk)

Updates the light after the block at pos changed; chunk is the snapshot after the change.

bool QcBlockLightEngine::hasChunk(QcChunkPos pos) const

Returns whether the chunk at pos is loaded.

int QcBlockLightEngine::level(QcBlockPos pos) const

Returns the current level at pos; 0 in unloaded chunks.

void QcBlockLightEngine::removeChunk(QcChunkPos pos)

Removes the chunk at pos and the light it gave its neighbours.

QcChunkLight QcBlockLightEngine::snapshot(QcChunkPos pos) const

Returns the published light of the chunk at pos (as of the last takeChanges()).

QcBlockLightEngine::Changes QcBlockLightEngine::takeChanges()

Returns what changed since the last call and starts over.

quint64 QcBlockLightEngine::visitedCells() const

Returns the cells visited by the propagation steps so far (work measure for benchmarks).