QtCraft API C++ classes QML types Handbook

QcMovingLights Namespace

Finds and ranks the moving lights of a frame. More...

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

Variables

const float creatureGlowShare
const double farthest

Functions

float brightness(float level, double distance)
float creatureLevel(const QcMobDefinition &mob)
QList<QcMovingLight> entityLights(const QcContentRegistry &content, const QHash<quint32, QcClientEntity> &entities, double alpha)
QList<QcMovingLight> gather(const QcClientSession &session, double alpha, const QcVec3 &eye)
bool handInWorld(bool dead, QcGameModes::Rules rules)
std::optional<QcMovingLight> handLight(const QcContentRegistry &content, const QcItemStack &held, const QcVec3 &eye)
float itemLevel(const QcContentRegistry &content, QcItemId item)
QcPackedLights pack(const QList<QcMovingLight> &lights, const QcVec3 &camera, int most)
QList<QcMovingLight> select(const QList<QcMovingLight> &candidates, const QcVec3 &camera, int count)

Detailed Description

GUI thread; the helpers are pure.

Variable Documentation

const float QcMovingLights::creatureGlowShare

A glowing creature lights its surroundings with this share of its glow: a firefly (glow 15) lights about seven blocks around it, a little light rather than a torch.

const double QcMovingLights::farthest

Lights farther from the camera than this many blocks beyond their reach are not drawn.

Function Documentation

float QcMovingLights::brightness(float level, double distance)

Returns the brightness (0..1) of a light of level at distance blocks: like block light, one level less per block, a level of 15 is full brightness. The shaders compute it themselves (block.frag, entity.vert, hand.vert); this CPU copy states the rule for the tests. The distance is straight (Euclidean), so the light reaches a little farther diagonally than block light does.

float QcMovingLights::creatureLevel(const QcMobDefinition &mob)

Returns the light level the creature mob gives: creatureGlowShare of its glow.

QList<QcMovingLight> QcMovingLights::entityLights(const QcContentRegistry &content, const QHash<quint32, QcClientEntity> &entities, double alpha)

Returns the lights of the mirrored entities of content at alpha between the last two ticks: what players hold (heldBelowEyes below their eyes) and creatures hold (at creatureHeldHeight), glowing creatures (at creatureGlowHeight) and glowing items on the ground (itemCentre above them).

QList<QcMovingLight> QcMovingLights::gather(const QcClientSession &session, double alpha, const QcVec3 &eye)

Returns every moving light of session at alpha between the last two ticks, the local player's eyes at eye: handLight() when handInWorld(), then entityLights().

bool QcMovingLights::handInWorld(bool dead, QcGameModes::Rules rules)

Returns whether the local player holds anything in the world: not when dead or when rules make them a spectator.

std::optional<QcMovingLight> QcMovingLights::handLight(const QcContentRegistry &content, const QcItemStack &held, const QcVec3 &eye)

Returns the light of the local player's held stack, heldBelowEyes below eye; none for items without light in content.

float QcMovingLights::itemLevel(const QcContentRegistry &content, QcItemId item)

Returns the light level (0..15) the item of content gives when held or lying: the block light of the block it places (a torch 14, a lantern 15, a bucket of lava 15); 0 for the others.

QcPackedLights QcMovingLights::pack(const QList<QcMovingLight> &lights, const QcVec3 &camera, int most)

Returns the first most of lights (at most QcRenderOptions::maxMovingLights) for the shaders, relative to camera; lights with a position or level that is not finite are left out.

QList<QcMovingLight> QcMovingLights::select(const QList<QcMovingLight> &candidates, const QcVec3 &camera, int count)

Returns the lights of candidates a frame draws, at most count: those that bring the most light to camera first (the level less the distance), ties by position so the choice does not flicker between frames of the same scene; lights farther than their level plus farthest are left out.