Engine → Physics → physics_layers.h
physics_layer_table
| Type | Class |
| Namespace | conjure::physics |
| Include File Path | engine/include/conjure/physics/physics_layers.h |
| Source File Path | engine/src/physics/physics_layers.cpp |
| API ↗ | Bodies, colliders and characters, Physics |
Syntax
Constructors
| Access | Signature | Description |
|---|---|---|
| public | physics_layer_table(); | One layer "default" that collides with itself. |
| public | physics_layer_table(
const physics_layer_table &) = default; | |
| public | physics_layer_table(
physics_layer_table &&) noexcept = default; |
Destructors
| Access | Signature | Description |
|---|---|---|
| public | ~physics_layer_table(); |
Variables
| Access | Name | Type | Default | Description |
|---|---|---|---|---|
| private | mCollides | std:: | {} | |
| private | mNames | core:: | {} |
Functions
Public
add_layer
add_layer[[nodiscard]] core::result<u8> add_layer(
core::string_id name);Appends a layer that collides with every existing layer and itself; returns its index. LAYER_LIMIT_REACHED, DUPLICATE_LAYER (also for the null id).
collides
collidesTrue when the two layers collide; false for indices outside the table.
collision_mask
collision_mask[[nodiscard]] physics_layer_mask collision_mask(
u8 layer) const noexcept;The layers layer collides with (the empty mask for an index outside the table).
find
find[[nodiscard]] std::optional<u8> find(
core::string_id name) const noexcept;The index of the layer with this name, or nullopt.
from_json
from_json[[nodiscard]] static core::result<physics_layer_table> from_json(
const core::json::value §ion);Builds a table from the project.json section: "names" (required, 1..32 unique strings) and "ignore" (optional pairs of names that do not collide). LAYER_CONFIG_INVALID, LAYER_LIMIT_REACHED, DUPLICATE_LAYER, UNKNOWN_LAYER. Everything collides unless ignored.
name
name[[nodiscard]] core::string_id name(
u8 layer) const noexcept;The name of a layer (the null id for an index outside the table).
set_collides
set_collidesSets whether two layers collide (symmetric). Indices outside the table are ignored.
to_json
to_json[[nodiscard]] core::result<void> to_json(
core::json::writer &out) const;Writes {"ignore": [[a, b], ...], "names": [...]} with sorted keys and the ignored pairs in ascending (a, b) index order, so the text equals the canonical form of its parse. Fails with LAYER_CONFIG_INVALID when a layer name was never interned (it cannot be spelt).
validate
validate[[nodiscard]] core::result<void> validate() const;LAYER_CONFIG_INVALID when the table is empty or the matrix is not symmetric, DUPLICATE_LAYER when two layers share a name.
Operator Overloads
Public
operator=
operator=physics_layer_table &operator=(
const physics_layer_table &) = default;physics_layer_table &operator=(
physics_layer_table &&) noexcept = default;operator==
operator==[[nodiscard]] bool operator==(
const physics_layer_table &other) const noexcept;