QtCraft API C++ classes QML types Handbook

QcTreeShape Namespace

Block layout of tree and column features, shared by world generation and growing saplings so that grown trees look like generated ones. More...

Header: #include <worldgen/terrain/QcTreeShape.h>

Classes

struct Params

Types

enum class Crown { Round, Cone, Bush, GiantCone, GiantRound }
Put

Functions

void build(const QcTreeShape::Params &params, QcBlockPos base, double random, quint64 seed, const QcTreeShape::Put &put)
void buildInChunk(QcChunk &chunk, const QcTreeShape::Params &params, QcBlockPos base, double random, quint64 seed)
std::optional<QcTreeShape::Crown> crownOf(const QString &shape)
int height(const QcTreeShape::Params &params, double random)
std::pair<QcBlockId, QcBlockId> lyingTrunks(const QcContentRegistry &content, QcBlockId trunk)
bool mayReplace(const QcTreeShape::Params &params, QcBlockId existing, QcBlockId block, bool onlyIntoAir)
QcTreeShape::Params paramsOf(const QcContentRegistry &content, const QcFeatureDefinition &feature)
int reach(const QcTreeShape::Params &params)
std::array<QcBlockId, 4> vinesOf(const QcContentRegistry &content, QcBlockId vine)

Detailed Description

Classes

class Params

The shape of one feature with its blocks resolved, as paramsOf() reads it from a feature definition. More...

Type Documentation

enum class QcTreeShape::Crown

Crown of a tree (decision E-822): the small round and cone crowns, a bush of leaves around a single log, and the giant trees standing on a 2×2 trunk (a tall spruce with a layered cone, a jungle giant with branches and a wide flat crown).

ConstantValueDescription
QcTreeShape::Crown::Round0Two wide layers under two narrow ones, ragged corners.
QcTreeShape::Crown::Cone1Rings shrinking towards the top, from two blocks above the ground.
QcTreeShape::Crown::Bush2Leaves around and over the logs.
QcTreeShape::Crown::GiantCone3A tall spruce on a 2×2 trunk with a layered cone.
QcTreeShape::Crown::GiantRound4A jungle giant on a 2×2 trunk with branches and a wide flat crown.

[alias] QcTreeShape::Put

Receives every block of the feature; onlyIntoAir marks blocks (leaves, vines) that may replace only what mayReplace() allows. Returns whether the block was placed (or, outside the area the receiver writes, would be): vines hang only on blocks that were.

Function Documentation

void QcTreeShape::build(const QcTreeShape::Params &params, QcBlockPos base, double random, quint64 seed, const QcTreeShape::Put &put)

Emits the feature with params standing on base (the lowest trunk block; of a giant the north-west one) to put. random picks the trunk height; seed decides the ragged corners of crowns, the branches and the vines.

void QcTreeShape::buildInChunk(QcChunk &chunk, const QcTreeShape::Params &params, QcBlockPos base, double random, quint64 seed)

Builds the feature with params, base, random and seed into chunk as build() does, keeping the blocks inside the chunk and the world height; blocks marked onlyIntoAir only where mayReplace() allows.

std::optional<QcTreeShape::Crown> QcTreeShape::crownOf(const QString &shape)

Returns the crown named by a feature's shape ("round", "cone", "bush", "giant_cone", "giant_round").

int QcTreeShape::height(const QcTreeShape::Params &params, double random)

Returns the trunk height of a feature with params for a random value in [0, 1).

std::pair<QcBlockId, QcBlockId> QcTreeShape::lyingTrunks(const QcContentRegistry &content, QcBlockId trunk)

Returns trunk lying along x and along z (its axis property set with content), as Params::trunkX and trunkZ.

bool QcTreeShape::mayReplace(const QcTreeShape::Params &params, QcBlockId existing, QcBlockId block, bool onlyIntoAir)

Returns whether block of a tree with params may go where existing is: anything when onlyIntoAir is false (trunks); otherwise air, and for a block that is none of the tree's vine states also one of them (leaves over the vines of another tree; a vine of this one may then hold on to them).

QcTreeShape::Params QcTreeShape::paramsOf(const QcContentRegistry &content, const QcFeatureDefinition &feature)

Returns the shape of feature with the blocks of content (air for unknown blocks).

int QcTreeShape::reach(const QcTreeShape::Params &params)

Returns how many blocks the feature with params reaches sideways from base (at most, for every height); 0 for features that are no tree.

std::array<QcBlockId, 4> QcTreeShape::vinesOf(const QcContentRegistry &content, QcBlockId vine)

Returns the vine states of the block vine with the blocks of content (air for air), in the order of Params::vines.