TransformComponent
- Module
- Components
- Header
#include "Components/TransformComponent.h"- Namespace
Mowo- Reflection
- Reflected by MowoHeaderTool
Properties
| Type | Name | Description |
|---|---|---|
Vec3 | position | Shown as UE's "Location"; the key stays "position". |
Vec3 | rotation | Stored in radians, edited in degrees. The inspector reads that off the unit rather than off this component's name, which is what it did before. |
Vec3 | scale | |
EMobility | mobility | Default EMobility::Movable. |
Mat4 | worldMatrix | Computed by TransformSystem each frame |
Vec3 | lastPosition | Mirror of the local fields as of the last TransformSystem pass. The next pass memcmps them against the live fields to skip clean subtrees, so there is no MarkDirty() — plain field writes are detected. NaN init forces a full rebuild on the first frame. Default Vec3(std::numeric_limits<float>::quiet_NaN()). |
Vec3 | lastRotation | Default Vec3(std::numeric_limits<float>::quiet_NaN()). |
Vec3 | lastScale | Default Vec3(std::numeric_limits<float>::quiet_NaN()). |
uint32_t | worldVersion | worldVersion bumps on every worldMatrix rebuild; children compare it against lastParentVersion to catch a moved parent (their own local fields are unchanged but their world position is stale). Default 0. |
uint32_t | lastParentVersion | Default 0. |
uint32_t | shadowSeenVersion | The worldVersion the shadow pass last saw and the render frame it last changed on: a Movable caster that moved recently draws in the dynamic shadow layer instead of invalidating the cached static one. Default 0. |
uint32_t | shadowMovedFrame | Default 0. |
EntityID | lastParent | The parent worldMatrix was last composed against. Versions are per-entity counters, so a child moved to a new parent whose version happens to equal the old one's — or unparented, with no parent version left to compare — kept the old parent's world matrix without this. Default INVALID_ENTITY. |
uint32_t | firstChildSlotHint | World slot hints for the RelationshipComponent links TransformSystem follows (this entity's first child, its next sibling), so the hierarchy walk reaches a child without the id → slot hash. Checked against the id on every use; a stale or copied hint just costs the hash once. Default UINT32_MAX. |
uint32_t | nextSiblingSlotHint | Default UINT32_MAX. |
Constructors
| Signature | Name | Description |
|---|---|---|
TransformComponent() : position(0.0f, 0.0f, 0.0f), rotation(0.0f, 0.0f, 0.0f), s… | TransformComponent | |
explicit TransformComponent(const Vec3& pos) : position(pos), rotation(0.0f, 0.0… | TransformComponent | |
TransformComponent(const Vec3& pos, const Vec3& rot) : position(pos), rotation(r… | TransformComponent | |
TransformComponent(const Vec3& pos, const Vec3& rot, const Vec3& scl) : position… | TransformComponent |
Public functions
| Returns | Name | Description |
|---|---|---|
void | Translate | |
float | GetScaleX | |
Mat4 | GetLocalMatrix | Order: Scale -> RotZ -> RotY -> RotX -> Translate, i.e. |
Mat4 | GetMatrix | Local only — parented entities need GetWorldMatrix(). |
Mat4 | GetWorldMatrix | Baked by TransformSystem each frame. |
Vec3 | GetWorldPosition | Extracted from worldMatrix, so it includes the parent transform. |
Vec3 | GetForward | Basis columns of R = Rx * Ry * Rz — the exact rotation GetLocalMatrix bakes and Quat::FromEuler/ToEuler round-trip, so a decomposed quat (actor sync, physics, imports) yields the same vectors as the quat itself. |
Vec3 | GetRight | Right is +X: R * (1, 0, 0) — roll participates here. |
Vec3 | GetUp |
Function details
TransformComponent
TransformComponent() : position(0.0f, 0.0f, 0.0f), rotation(0.0f, 0.0f, 0.0f), scale(1.0f, 1.0f, 1.0f), worldMatrix(1.0f)TransformComponent
explicit TransformComponent(const Vec3& pos) : position(pos), rotation(0.0f, 0.0f, 0.0f), scale(1.0f, 1.0f, 1.0f)TransformComponent
TransformComponent(const Vec3& pos, const Vec3& rot) : position(pos), rotation(rot), scale(1.0f, 1.0f, 1.0f)TransformComponent
TransformComponent(const Vec3& pos, const Vec3& rot, const Vec3& scl) : position(pos), rotation(rot), scale(scl)Translate
void Translate(Vec3 delta)GetScaleX
float GetScaleX() constGetLocalMatrix
Mat4 GetLocalMatrix() constOrder: Scale -> RotZ -> RotY -> RotX -> Translate, i.e. T * Rx * Ry * Rz * S, composed analytically: the 3x3 block is Rx*Ry*Rz expanded with its columns scaled, ~30 ops instead of four Mat4 products. Rounding differs from the matrix product only in op order; equivalence is locked by --trs-test.
GetMatrix
Mat4 GetMatrix() constLocal only — parented entities need GetWorldMatrix().
GetWorldMatrix
Mat4 GetWorldMatrix() constBaked by TransformSystem each frame. For root entities == GetLocalMatrix().
GetWorldPosition
Vec3 GetWorldPosition() constExtracted from worldMatrix, so it includes the parent transform.
GetForward
Vec3 GetForward() constBasis columns of R = Rx * Ry * Rz — the exact rotation GetLocalMatrix bakes and Quat::FromEuler/ToEuler round-trip, so a decomposed quat (actor sync, physics, imports) yields the same vectors as the quat itself. Forward = R * (0, 0, -1); the -Z column has no roll terms.
GetRight
Vec3 GetRight() constRight is +X: R * (1, 0, 0) — roll participates here.
GetUp
Vec3 GetUp() const