Estella 0.113.0
A fast 2D and 3D game engine powered by WebAssembly and ECS
Loading...
Searching...
No Matches
esengine::ecs::Transform Struct Reference

Unified transform component. More...

#include <Transform.hpp>

Public Member Functions

void ensureDecomposed ()
bool auditSame (const Transform &kept) const
 What the change audit takes as unchanged since kept (Registry::auditChanges).
 Transform ()=default
 Transform (const glm::vec3 &pos)
 Transform (const glm::vec3 &pos, const glm::quat &rot)
 Transform (const glm::vec3 &pos, const glm::quat &rot, const glm::vec3 &scl)

Public Attributes

glm::vec3 position {0.0f, 0.0f, 0.0f}
glm::quat rotation {1.0f, 0.0f, 0.0f, 0.0f}
glm::vec3 scale {1.0f, 1.0f, 1.0f}
glm::vec3 worldPosition {0.0f, 0.0f, 0.0f}
glm::quat worldRotation {1.0f, 0.0f, 0.0f, 0.0f}
glm::vec3 worldScale {1.0f, 1.0f, 1.0f}
bool decomposed_ = true
glm::mat4 cachedMatrix_ {std::numeric_limits<f32>::quiet_NaN()}

Detailed Description

Unified transform component.

Contains both local (relative to parent) and world-space transforms. Local fields (position, rotation, scale) are user-controlled. World fields (worldPosition, worldRotation, worldScale) are computed by TransformSystem each frame.

Entity e = registry.create();
registry.emplace<Transform>(e, glm::vec3(10.0f, 0.0f, 0.0f));
auto& transform = registry.get<Transform>(e);
transform.position.x = 5.0f; // set local
// After TransformSystem runs:
// transform.worldPosition contains final world-space position
Entity identifier with packed index + generation.
Definition Types.hpp:135

Definition at line 45 of file Transform.hpp.

Constructor & Destructor Documentation

◆ Transform() [1/4]

esengine::ecs::Transform::Transform ( )
default

Referenced by auditSame().

◆ Transform() [2/4]

esengine::ecs::Transform::Transform ( const glm::vec3 & pos)
inlineexplicit

Definition at line 95 of file Transform.hpp.

References position.

◆ Transform() [3/4]

esengine::ecs::Transform::Transform ( const glm::vec3 & pos,
const glm::quat & rot )
inline

Definition at line 97 of file Transform.hpp.

References position, and rotation.

◆ Transform() [4/4]

esengine::ecs::Transform::Transform ( const glm::vec3 & pos,
const glm::quat & rot,
const glm::vec3 & scl )
inline

Definition at line 100 of file Transform.hpp.

References position, rotation, and scale.

Member Function Documentation

◆ auditSame()

bool esengine::ecs::Transform::auditSame ( const Transform & kept) const
inline

What the change audit takes as unchanged since kept (Registry::auditChanges).

The local fields and the world matrix, bit for bit. The world fields too, except where they were filled in since: ensureDecomposed() reads them out of a matrix that did not change, which is a read made lazily, not a write. Fields that differ under the same matrix, both already filled, were written.

Definition at line 82 of file Transform.hpp.

References Transform(), cachedMatrix_, decomposed_, position, rotation, scale, worldPosition, worldRotation, and worldScale.

◆ ensureDecomposed()

Member Data Documentation

◆ cachedMatrix_

glm::mat4 esengine::ecs::Transform::cachedMatrix_ {std::numeric_limits<f32>::quiet_NaN()}

◆ decomposed_

bool esengine::ecs::Transform::decomposed_ = true

Definition at line 66 of file Transform.hpp.

Referenced by auditSame(), and ensureDecomposed().

◆ position

glm::vec3 esengine::ecs::Transform::position {0.0f, 0.0f, 0.0f}

◆ rotation

glm::quat esengine::ecs::Transform::rotation {1.0f, 0.0f, 0.0f, 0.0f}

Definition at line 50 of file Transform.hpp.

Referenced by Transform(), Transform(), auditSame(), and EMSCRIPTEN_BINDINGS().

◆ scale

glm::vec3 esengine::ecs::Transform::scale {1.0f, 1.0f, 1.0f}

Definition at line 53 of file Transform.hpp.

Referenced by Transform(), auditSame(), and EMSCRIPTEN_BINDINGS().

◆ worldPosition

glm::vec3 esengine::ecs::Transform::worldPosition {0.0f, 0.0f, 0.0f}

◆ worldRotation

glm::quat esengine::ecs::Transform::worldRotation {1.0f, 0.0f, 0.0f, 0.0f}

◆ worldScale

glm::vec3 esengine::ecs::Transform::worldScale {1.0f, 1.0f, 1.0f}

The documentation for this struct was generated from the following file:
  • /home/runner/work/estella/estella/src/esengine/ecs/components/Transform.hpp