Skip to content

EntropyCanvas::Transform

Core transform component - represents position, rotation, and scale in 3D space. More…

#include <Transform.h>

Name
structMatrixCache
Cached matrices - computed once, reused until invalidated.
Name
glm::vec3worldScale() const
Get world-space scale (computed from world matrix column lengths).
glm::quatworldRotation() const
Get world-space rotation (extracted from world matrix, assumes no skew).
glm::vec3worldPosition() const
Get world-space position (translation column of world matrix).
TransformwithPosition(const glm::vec3 & pos)
Create transform with position only.
glm::vec3up() const
Get the up direction vector (positive Y in local space).
glm::mat4toMatrix() const
Compute the local-to-world transformation matrix.
voidsetWorldMatrix(const glm::mat4 & parentWorldMatrix) const
Set the world matrix from parent chain computation.
glm::vec3right() const
Get the right direction vector (positive X in local space).
voidrecomputeCache() const
Recompute all cached local matrices.
voidmarkWorldDirty() const
Mark world matrices as needing recomputation.
boolisWorldDirty() const
Check if world matrices need recomputation.
boolisIdentity() const
Check if this is an identity transform.
voidinvalidateCache() const
Invalidate the local matrix cache.
Transformidentity()
Create identity transform (no translation/rotation/scale).
glm::vec3forward() 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 )
Name
struct EntropyCanvas::Transform::MatrixCache_cache
ENTROPY_SKIP_USD_SCHEMA
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.

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).

inline glm::vec3 worldPosition() const

Get world-space position (translation column of world matrix).

static inline 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.

Note: For cached access, prefer cachedModelMatrix().

void setWorldMatrix(
const glm::mat4 & parentWorldMatrix
) const

Set the world matrix from parent chain computation.

Parameters:

  • parentWorldMatrix Parent’s world matrix (identity for root entities)

Called by TransformPropagationSystem during propagation.

glm::vec3 right() const

Get the right direction vector (positive X in local space).

void recomputeCache() const

Recompute all cached local matrices.

Called lazily on first access after invalidation.

inline void markWorldDirty() const

Mark world matrices as needing recomputation.

Called when entity is reparented or when ancestor transforms change.

inline bool isWorldDirty() const

Check if world matrices need recomputation.

inline bool isIdentity() const

Check if this is an identity transform.

inline void invalidateCache() const

Invalidate the local matrix cache.

Called by ECS observer on transform change. Also marks world matrices as dirty since they depend on local.

static inline Transform identity()

Create identity transform (no translation/rotation/scale).

glm::vec3 forward() const

Get the forward direction vector (negative Z in local space).

inline const glm::mat3 & cachedWorldNormalMatrix() const

Get cached world normal matrix (inverse-transpose of upper-left 3x3).

Used for transforming normals correctly under non-uniform scale in world space.

inline const glm::mat4 & cachedWorldMatrixTransposed() const

Get cached transposed world matrix.

inline const glm::mat4 & cachedWorldMatrix() const

Get cached world matrix (local-to-world transformation).

Note: Must call setWorldMatrix() or propagate transforms before accessing.

This accounts for the entire parent hierarchy.

const glm::mat3 & cachedNormalMatrix() const

Get cached normal matrix (inverse-transpose of upper-left 3x3).

Used for transforming normals correctly under non-uniform scale.

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
)
struct EntropyCanvas::Transform::MatrixCache _cache;
ENTROPY_SKIP_USD_SCHEMA;

Updated on 2026-01-26 at 16:50:32 -0500