EntropyCanvas::Transform
EntropyCanvas::Transform
Section titled “EntropyCanvas::Transform”Core transform component - represents position, rotation, and scale in 3D space. More…
#include <Transform.h>
Public Classes
Section titled “Public Classes”| Name | |
|---|---|
| struct | MatrixCache Cached matrices - computed once, reused until invalidated. |
Public Functions
Section titled “Public Functions”| Name | |
|---|---|
| glm::vec3 | worldScale() const Get world-space scale (computed from world matrix column lengths). |
| glm::quat | worldRotation() const Get world-space rotation (extracted from world matrix, assumes no skew). |
| glm::vec3 | worldPosition() const Get world-space position (translation column of world matrix). |
| Transform | withPosition(const glm::vec3 & pos) Create transform with position only. |
| glm::vec3 | up() const Get the up direction vector (positive Y in local space). |
| glm::mat4 | toMatrix() const Compute the local-to-world transformation matrix. |
| void | setWorldMatrix(const glm::mat4 & parentWorldMatrix) const Set the world matrix from parent chain computation. |
| glm::vec3 | right() const Get the right direction vector (positive X in local space). |
| void | recomputeCache() const Recompute all cached local matrices. |
| void | markWorldDirty() const Mark world matrices as needing recomputation. |
| bool | isWorldDirty() const Check if world matrices need recomputation. |
| bool | isIdentity() const Check if this is an identity transform. |
| void | invalidateCache() const Invalidate the local matrix cache. |
| Transform | identity() Create identity transform (no translation/rotation/scale). |
| glm::vec3 | forward() const Get the forward direction vector (negative Z in local space). |
| const glm::mat3 & | cachedWorldNormalMatrix() const Get cached world normal matrix (inverse-transpose of upper-left 3x3). |
| const glm::mat4 & | cachedWorldMatrixTransposed() const Get cached transposed world matrix. |
| const glm::mat4 & | cachedWorldMatrix() const Get cached world matrix (local-to-world transformation). |
| const glm::mat3 & | cachedNormalMatrix() const Get cached normal matrix (inverse-transpose of upper-left 3x3). |
| const glm::mat4 & | cachedModelMatrixTransposed() const Get cached transposed model matrix, recomputing if dirty. |
| const glm::mat4 & | cachedModelMatrix() const Get cached model matrix, recomputing if dirty. |
| ENTROPY_REGISTER_TYPE(Transform ) | |
| ENTROPY_FIELD(glm::vec3 , position ) | |
| ENTROPY_FIELD(glm::quat , rotation ) | |
| ENTROPY_FIELD(glm::vec3 , scale ) |
Public Attributes
Section titled “Public Attributes”| Name | |
|---|---|
| struct EntropyCanvas::Transform::MatrixCache | _cache |
| ENTROPY_SKIP_USD_SCHEMA |
Detailed Description
Section titled “Detailed Description”struct EntropyCanvas::Transform;Core transform component - represents position, rotation, and scale in 3D space.
This is the canonical Transform definition for all Entropy Canvas applications. Both CanvasEngine (server) and SDK clients use this same type.
Properties are individually addressable via PropertyRegistry for efficient network synchronization (using ENTROPY_FIELD macros).
Matrix computation is cached and only recomputed when invalidateCache() is called. The cache is invalidated via ECS observer when transform changes.
World Transform: The component also stores world-space matrices computed from the entity hierarchy. These are set by TransformPropagationSystem which traverses parent chains.
- For root entities: world matrix = local matrix
- For child entities: world matrix = parent.world * local
The worldDirty flag indicates the world matrices need recomputation.
Public Functions Documentation
Section titled “Public Functions Documentation”function worldScale
Section titled “function worldScale”glm::vec3 worldScale() constGet world-space scale (computed from world matrix column lengths).
function worldRotation
Section titled “function worldRotation”glm::quat worldRotation() constGet world-space rotation (extracted from world matrix, assumes no skew).
function worldPosition
Section titled “function worldPosition”inline glm::vec3 worldPosition() constGet world-space position (translation column of world matrix).
function withPosition
Section titled “function withPosition”static inline Transform withPosition( const glm::vec3 & pos)Create transform with position only.
function up
Section titled “function up”glm::vec3 up() constGet the up direction vector (positive Y in local space).
function toMatrix
Section titled “function toMatrix”glm::mat4 toMatrix() constCompute the local-to-world transformation matrix.
Note: For cached access, prefer cachedModelMatrix().
function setWorldMatrix
Section titled “function setWorldMatrix”void setWorldMatrix( const glm::mat4 & parentWorldMatrix) constSet the world matrix from parent chain computation.
Parameters:
- parentWorldMatrix Parent’s world matrix (identity for root entities)
Called by TransformPropagationSystem during propagation.
function right
Section titled “function right”glm::vec3 right() constGet the right direction vector (positive X in local space).
function recomputeCache
Section titled “function recomputeCache”void recomputeCache() constRecompute all cached local matrices.
Called lazily on first access after invalidation.
function markWorldDirty
Section titled “function markWorldDirty”inline void markWorldDirty() constMark world matrices as needing recomputation.
Called when entity is reparented or when ancestor transforms change.
function isWorldDirty
Section titled “function isWorldDirty”inline bool isWorldDirty() constCheck if world matrices need recomputation.
function isIdentity
Section titled “function isIdentity”inline bool isIdentity() constCheck if this is an identity transform.
function invalidateCache
Section titled “function invalidateCache”inline void invalidateCache() constInvalidate the local matrix cache.
Called by ECS observer on transform change. Also marks world matrices as dirty since they depend on local.
function identity
Section titled “function identity”static inline Transform identity()Create identity transform (no translation/rotation/scale).
function forward
Section titled “function forward”glm::vec3 forward() constGet the forward direction vector (negative Z in local space).
function cachedWorldNormalMatrix
Section titled “function cachedWorldNormalMatrix”inline const glm::mat3 & cachedWorldNormalMatrix() constGet cached world normal matrix (inverse-transpose of upper-left 3x3).
Used for transforming normals correctly under non-uniform scale in world space.
function cachedWorldMatrixTransposed
Section titled “function cachedWorldMatrixTransposed”inline const glm::mat4 & cachedWorldMatrixTransposed() constGet cached transposed world matrix.
function cachedWorldMatrix
Section titled “function cachedWorldMatrix”inline const glm::mat4 & cachedWorldMatrix() constGet cached world matrix (local-to-world transformation).
Note: Must call setWorldMatrix() or propagate transforms before accessing.
This accounts for the entire parent hierarchy.
function cachedNormalMatrix
Section titled “function cachedNormalMatrix”const glm::mat3 & cachedNormalMatrix() constGet cached normal matrix (inverse-transpose of upper-left 3x3).
Used for transforming normals correctly under non-uniform scale.
function cachedModelMatrixTransposed
Section titled “function cachedModelMatrixTransposed”const glm::mat4 & cachedModelMatrixTransposed() constGet cached transposed model matrix, recomputing if dirty.
function cachedModelMatrix
Section titled “function cachedModelMatrix”const glm::mat4 & cachedModelMatrix() constGet cached model matrix, recomputing if dirty.
function ENTROPY_REGISTER_TYPE
Section titled “function ENTROPY_REGISTER_TYPE”ENTROPY_REGISTER_TYPE( Transform)function ENTROPY_FIELD
Section titled “function ENTROPY_FIELD”ENTROPY_FIELD( glm::vec3 , position)function ENTROPY_FIELD
Section titled “function ENTROPY_FIELD”ENTROPY_FIELD( glm::quat , rotation)function ENTROPY_FIELD
Section titled “function ENTROPY_FIELD”ENTROPY_FIELD( glm::vec3 , scale)Public Attributes Documentation
Section titled “Public Attributes Documentation”variable _cache
Section titled “variable _cache”struct EntropyCanvas::Transform::MatrixCache _cache;variable ENTROPY_SKIP_USD_SCHEMA
Section titled “variable ENTROPY_SKIP_USD_SCHEMA”ENTROPY_SKIP_USD_SCHEMA;Updated on 2026-01-26 at 16:50:32 -0500