Skip to main content

SceneNode Class

Represents a SceneNode within a SceneGraph. More...

Declaration

class helios::scene::SceneNode { ... }

Derived Classes

classCameraSceneNode

Represents an adapter for cameras, allowing spatial positioning and transformation within the scene graph. More...

Public Constructors Index

SceneNode (const SceneNode &)=delete

Delete copy constructor. A SceneNode is not copyable. More...

SceneNode () noexcept

Constructs a new SceneNode that represents no renderable object. Nodes constructed in this way should be treated as transformation nodes. More...

SceneNode (const Transform &transform) noexcept

Constructs a new SceneNode that represents no renderable object. Nodes constructed in this way should be treated as transformation nodes. More...

SceneNode (std::shared_ptr< helios::rendering::Renderable > renderable, const Transform &transform) noexcept

Constructs a new SceneNode representing a renderable object. More...

SceneNode (std::shared_ptr< helios::rendering::Renderable > renderable) noexcept

Constructs a new SceneNode representing a renderable object. More...

Public Destructor Index

~SceneNode ()=default

Public Operators Index

SceneNode &operator= (const SceneNode &)=delete

Delete copy assignment operator. More...

Public Member Functions Index

const helios::util::Guid &guid () const noexcept

Returns the globally unique identifier for this SceneNode. More...

SceneNode *addNode (std::unique_ptr< SceneNode > sceneNode)

Adds a new child node to this SceneNode. The node's parent is automatically set to **this** node. More...

const std::vector< std::unique_ptr< SceneNode > > &children () const noexcept

Returns a const ref to the list of this node's children. More...

helios::rendering::Renderable *renderable () noexcept

Returns a raw pointer to the Renderable of this SceneNode. More...

boolhasRenderable () const noexcept

Returns true if this SceneNode was configured with a Renderable. More...

const helios::rendering::Renderable *renderable () const noexcept

Returns a const pointer to the non-const Renderable of this SceneNode. More...

std::shared_ptr< helios::rendering::Renderable >shareRenderable () noexcept

Returns a shared pointer to the non-const Renderable of this SceneNode. More...

SceneNode &setScale (const helios::math::vec3f &scale) noexcept

Applies a scaling transformation to this node's **local** transform. Marks the node dirty. Implementing APIs should consider updating the worldTransform of this node before rendering. More...

SceneNode &setRotation (const helios::math::mat4f &rotation) noexcept

Applies rotation to this node's **local** transform. Marks the node dirty. Implementing APIs should consider updating the worldTransform of this node before rendering. More...

SceneNode &setTranslation (const helios::math::vec3f &translation) noexcept

Applies translation to this node's **local** transform. Marks the node dirty. Implementing APIs should consider updating the worldTransform of this node before rendering. More...

const Transform &localTransform () const noexcept

Returns this SceneNode's localTransform. More...

Transform &localTransform () noexcept

Returns this SceneNode's localTransform. More...

SceneNode *parent () const noexcept

Returns a pointer to this node's parent node. More...

boolapplyWorldTransform (const helios::math::mat4f &parentWorldTransform, helios::scene::SceneGraphKey sceneGraphKey) noexcept

Sets the world transform for this SceneNode. More...

voidsetIsRoot (helios::scene::SceneGraphKey sceneGraphKey) noexcept

Marks this node as the root of the scene graph. More...

boolisRoot () const noexcept

Checks whether this node is the root of the scene graph. More...

const helios::math::mat4f &worldTransform () noexcept

Computes and returns the world transform for this SceneNode. Will request the current world transform from the parent node to calculate this SceneNode's world transform. For efficiency, this method should cache the result and only trigger a recompute if this SceneNode is dirty (`needsUpdate_ == true`). More...

const helios::math::mat4f &cachedWorldTransform () const noexcept

Returns the current worldTransform matrix of this SceneNode **without triggering any recomputation**. This method is efficient for access when the world transform is known to be up-to-date. More...

boolneedsUpdate () const noexcept

Checks whether this SceneNode needs to be updated. More...

helios::math::aabbfaabb () noexcept

Returns the axis-aligned bounding box for this SceneNode in world coordinates. More...

voidupdate () noexcept

Updates the world transform and axis-aligned bounding box of this SceneNode. More...

voidonWorldTransformUpdate () noexcept

Virtual callback invoked after the world transform has been updated. More...

helios::math::mat4finheritWorldTransform (const helios::math::mat4f &parentWorldTransform) noexcept

Filters a parent world transform based on the node's inheritance flags. More...

voidsetInheritance (const helios::math::TransformType inherit) noexcept

Sets which transform components this node inherits from its parent. More...

helios::math::TransformTypeinheritance () const noexcept

Returns the current transform inheritance flags for this node. More...

boolisActive () const noexcept

Returns whether this SceneNode and its child nodes should be considered for rendering. More...

voidsetActive (const bool active) noexcept

Sets the active state of this SceneNode. More...

Protected Member Functions Index

voidsetParent (SceneNode *parentNode)

Sets the parent of this SceneNode. Internally used once a child was added to this SceneNode. More...

Protected Member Attributes Index

boolneedsUpdate_ = true

Boolean flag to represent the dirty-state of this node. Should be set to false if the current `worldTransform_` for this node was computed, otherwise true, e.g. if the node's local transform has been changed. More...

boolisRoot_ = false

True if this node is the root of the scene graph. More...

std::shared_ptr< helios::rendering::Renderable >renderable_ = nullptr

A shared pointer to the Renderable this node represents in the SceneGraph. May be nullptr if this node does not represent a. More...

SceneNode *parent_ = nullptr

The parent node of **this** node. This will be nullptr for any root node. Implementing APIs must take care of properly assigning parent nodes when adding child nodes. More...

std::vector< std::unique_ptr< SceneNode > >children_

A list of unique pointers to this node's children. Ensures ownership of the child nodes withing the graph hierarchy. More...

math::mat4fworldTransform_ = math::mat4f::identity()

The 4x4 worldTransform-Matrix of this node. This matrix is initially set to the identity matrix. Implementing APIs MUST make sure to recompute the worldTransform before each rendering pass. More...

TransformlocalTransform_

A local transformation representing affine transformation information for this SceneNode. Encapsulates rotation, scaling and translation. More...

boolisActive_ = true

Boolean flag indicating whether this SceneNode should be considered for rendering. More...

helios::math::aabbfaabb_ {}

The axis-aligned-bounding-box for this SceneNode in world-coordinates. More...

helios::math::TransformTypeinheritance_ = helios::math::TransformType::All

Flags controlling which transform components are inherited from the parent node. More...

Private Member Attributes Index

const util::Guidguid_

A unique identifier for this SceneNode, computed automatically during instantiation. More...

Description

Represents a SceneNode within a SceneGraph.

A SceneNode holds its local transformation and a (shared) pointer to a Renderable object (the representative of a visible element). Furthermore, a SceneNode can have multiple child nodes uniquely owned by **this** SceneNode.

A SceneNode holds a global unique identifier and tracks a dirty state (`needsUpdate_`) related to any transformations that occurred on the SceneNode. Ownership is managed by a collection of unique pointers of the child nodes. SceneNodes are designed to be not copyable and not assignable to prevent duplication and to enforce the hierarchical tree structure.

The `worldTransform_` is derived from a SceneNode's `localTransform_` and the SceneNode's parent's `worldTransform`s. A call to `worldTransform()` will update the particular subtree of the SceneNode bottom-up to make sure the actual values are available with the SceneNode's `worldTransform`. A Scene might also propagate changes top-bottom - see `Scene::updateNodes()`.

Definition at line 62 of file SceneNode.ixx.

Public Constructors

SceneNode()

helios::scene::SceneNode::SceneNode (const SceneNode &)
delete

Delete copy constructor. A SceneNode is not copyable.

Definition at line 162 of file SceneNode.ixx.

Reference SceneNode.

Referenced by helios::scene::CameraSceneNode::addNode, addNode, operator=, parent, SceneNode, setParent, setRotation, setScale and setTranslation.

SceneNode()

helios::scene::SceneNode::SceneNode ()
inline noexcept

Constructs a new SceneNode that represents no renderable object. Nodes constructed in this way should be treated as transformation nodes.

Todo

explicitly implement move (assignment) constructor if required, since we have deleted the copy constructors

Definition at line 181 of file SceneNode.ixx.

181 SceneNode() noexcept :
182 guid_(util::Guid::generate())
183 {}

SceneNode()

helios::scene::SceneNode::SceneNode (const Transform & transform)
inline explicit noexcept

Constructs a new SceneNode that represents no renderable object. Nodes constructed in this way should be treated as transformation nodes.

Parameters
transform

The initial transformation for this node.

Definition at line 192 of file SceneNode.ixx.

192 explicit SceneNode(const Transform& transform) noexcept :
193 guid_(util::Guid::generate()),
194 localTransform_(transform)
195 {}

Reference helios::util::Guid::generate.

SceneNode()

helios::scene::SceneNode::SceneNode (std::shared_ptr< helios::rendering::Renderable > renderable, const Transform & transform)
inline explicit noexcept

Constructs a new SceneNode representing a renderable object.

Parameters
renderable

A shared_ptr to the Renderable this SceneNode represents in a Scene.

transform

The initial local transform for this node.

Definition at line 204 of file SceneNode.ixx.

204 explicit SceneNode(
205 std::shared_ptr<helios::rendering::Renderable> renderable,
206 const Transform& transform
207 ) noexcept :
208 guid_(util::Guid::generate()),
209 renderable_(std::move(renderable)),
210 localTransform_(transform)
211 {}

References helios::util::Guid::generate and renderable.

SceneNode()

helios::scene::SceneNode::SceneNode (std::shared_ptr< helios::rendering::Renderable > renderable)
inline explicit noexcept

Constructs a new SceneNode representing a renderable object.

Parameters
renderable

A shared_ptr to the Renderable this SceneNode represents in a Scene.

Definition at line 219 of file SceneNode.ixx.

219 explicit SceneNode(
220 std::shared_ptr<helios::rendering::Renderable> renderable
221 ) noexcept :
222 guid_(util::Guid::generate()),
223 renderable_(std::move(renderable))
224 {}

References helios::util::Guid::generate and renderable.

Public Destructor

~SceneNode()

virtual helios::scene::SceneNode::~SceneNode ()
virtual default

Definition at line 156 of file SceneNode.ixx.

Public Operators

operator=()

SceneNode & helios::scene::SceneNode::operator= (const SceneNode &)
delete

Delete copy assignment operator.

A SceneNode is not intended to be copied.

Definition at line 169 of file SceneNode.ixx.

Reference SceneNode.

Public Member Functions

aabb()

helios::math::aabbf helios::scene::SceneNode::aabb ()
inline nodiscard noexcept

Returns the axis-aligned bounding box for this SceneNode in world coordinates.

Returns

The AABB transformed to world space.

Definition at line 465 of file SceneNode.ixx.

465 [[nodiscard]] helios::math::aabbf aabb() noexcept {
466 if (needsUpdate()) {
467 update();
468 }
469
470 return aabb_;
471 }

References aabb_, needsUpdate and update.

addNode()

virtual SceneNode * helios::scene::SceneNode::addNode (std::unique_ptr< SceneNode > sceneNode)
inline nodiscard virtual

Adds a new child node to this SceneNode. The node's parent is automatically set to **this** node.

Parameters
sceneNode

The node to add as a child.

Returns

The raw pointer to the newly added node, or nullptr if adding failed

Definition at line 244 of file SceneNode.ixx.

244 [[nodiscard]] virtual SceneNode* addNode(std::unique_ptr<SceneNode> sceneNode) {
245 auto& ref = *children_.emplace_back(std::move(sceneNode));
246 ref.setParent(this);
247 return &ref;
248 }

References children_ and SceneNode.

applyWorldTransform()

bool helios::scene::SceneNode::applyWorldTransform (const helios::math::mat4f & parentWorldTransform, helios::scene::SceneGraphKey sceneGraphKey)
inline nodiscard noexcept

Sets the world transform for this SceneNode.

Does nothing if the current SceneNode's world transform is considered equal to the specified world transform.

Parameters
wf

The worldTransform to use for this SceneNode.

sceneGraphKey

The sceneGraphKey as constructed by the `Scene`. Serves as the passkey so this method is not callable from outside.

Returns

true if the world transform was updated, otherwise false.

Definition at line 382 of file SceneNode.ixx.

382 [[nodiscard]] bool applyWorldTransform(
383 const helios::math::mat4f& parentWorldTransform, helios::scene::SceneGraphKey sceneGraphKey
384 ) noexcept {
385
386 const auto newWt = inheritWorldTransform(parentWorldTransform);
387
388 if (!needsUpdate() && worldTransform_.same(newWt)) {
389 return false;
390 }
391
392 worldTransform_ = newWt;
393 needsUpdate_ = false;
394
395
397 return true;
398 }

References inheritWorldTransform, needsUpdate, needsUpdate_, onWorldTransformUpdate and worldTransform_.

cachedWorldTransform()

const helios::math::mat4f & helios::scene::SceneNode::cachedWorldTransform ()
inline nodiscard noexcept

Returns the current worldTransform matrix of this SceneNode **without triggering any recomputation**. This method is efficient for access when the world transform is known to be up-to-date.

Returns

The current worldTransform matrix of this SceneNode.

Definition at line 443 of file SceneNode.ixx.

443 [[nodiscard]] const helios::math::mat4f& cachedWorldTransform() const noexcept {
444 return worldTransform_;
445 }

Reference worldTransform_.

Referenced by helios::scene::Scene::createSnapshot, helios::scene::CameraSceneNode::lookAt and helios::scene::CameraSceneNode::onWorldTransformUpdate.

children()

const std::vector< std::unique_ptr< SceneNode > > & helios::scene::SceneNode::children ()
inline nodiscard noexcept

Returns a const ref to the list of this node's children.

Returns

A const ref to the list of children of this node.

Definition at line 255 of file SceneNode.ixx.

255 [[nodiscard]] const std::vector<std::unique_ptr<SceneNode>>& children() const noexcept {
256 return children_;
257 }

Reference children_.

Referenced by helios::scene::CullNoneStrategy::cull.

guid()

const helios::util::Guid & helios::scene::SceneNode::guid ()
inline nodiscard noexcept

Returns the globally unique identifier for this SceneNode.

Returns

The unique identifier for this SceneNode.

Definition at line 231 of file SceneNode.ixx.

231 [[nodiscard]] const helios::util::Guid& guid() const noexcept {
232 return guid_;
233 }

hasRenderable()

bool helios::scene::SceneNode::hasRenderable ()
inline nodiscard noexcept

Returns true if this SceneNode was configured with a Renderable.

Returns

true if the SceneNode was configured with a Renderable, otherwise false.

Definition at line 273 of file SceneNode.ixx.

273 [[nodiscard]] bool hasRenderable() const noexcept {
274 return renderable() != nullptr;
275 }

Reference renderable.

Referenced by helios::scene::Scene::createSnapshot.

inheritance()

helios::math::TransformType helios::scene::SceneNode::inheritance ()
inline nodiscard noexcept

Returns the current transform inheritance flags for this node.

Returns

The active inheritance mask.

See Also

setInheritance()

Definition at line 556 of file SceneNode.ixx.

556 [[nodiscard]] helios::math::TransformType inheritance() const noexcept {
557 return inheritance_;
558 }

Reference inheritance_.

inheritWorldTransform()

helios::math::mat4f helios::scene::SceneNode::inheritWorldTransform (const helios::math::mat4f & parentWorldTransform)
inline noexcept

Filters a parent world transform based on the node's inheritance flags.

This method extracts only the transform components (Translation, Rotation, Scale) that this node is configured to inherit from its parent. Components not included in `inheritance_` are replaced with identity values.

Parameters
parentWorldTransform

The parent's world transform matrix.

Returns

A filtered transform matrix containing only the inherited components.

See Also

setInheritance()

See Also

helios::math::TransformType

Definition at line 520 of file SceneNode.ixx.

520 helios::math::mat4f inheritWorldTransform(const helios::math::mat4f& parentWorldTransform) noexcept {
521 using namespace helios::math;
522
524 return parentWorldTransform * localTransform_.transform();
525 }
526
527 auto id = parentWorldTransform.decompose(inheritance_);
528
529 return id * localTransform_.transform();
530 }

References helios::math::All, inheritance_ and localTransform_.

Referenced by applyWorldTransform and update.

isActive()

bool helios::scene::SceneNode::isActive ()
inline nodiscard noexcept

Returns whether this SceneNode and its child nodes should be considered for rendering.

Returns

true if the SceneNode should be considered for rendering, otherwise false.

Definition at line 565 of file SceneNode.ixx.

565 [[nodiscard]] bool isActive() const noexcept {
566 return isActive_;
567 }

Reference isActive_.

Referenced by helios::scene::Scene::createSnapshot and helios::scene::CullNoneStrategy::cull.

isRoot()

bool helios::scene::SceneNode::isRoot ()
inline nodiscard noexcept

Checks whether this node is the root of the scene graph.

Returns

True if this is the root node.

Definition at line 414 of file SceneNode.ixx.

414 [[nodiscard]] bool isRoot() const noexcept {
415 return isRoot_;
416 }

Reference isRoot_.

localTransform()

const Transform & helios::scene::SceneNode::localTransform ()
inline nodiscard noexcept

Returns this SceneNode's localTransform.

Returns

A const reference to this SceneNode's `Transform` object.

Definition at line 346 of file SceneNode.ixx.

346 [[nodiscard]] const Transform& localTransform() const noexcept {
347 return localTransform_;
348 }

Reference localTransform_.

Referenced by helios::scene::CameraSceneNode::lookAtLocal.

localTransform()

Transform & helios::scene::SceneNode::localTransform ()
inline nodiscard noexcept

Returns this SceneNode's localTransform.

Returns

A reference to this SceneNode's `Transform` object.

Definition at line 355 of file SceneNode.ixx.

355 [[nodiscard]] Transform& localTransform() noexcept {
356 return localTransform_;
357 }

Reference localTransform_.

needsUpdate()

bool helios::scene::SceneNode::needsUpdate ()
inline nodiscard noexcept

Checks whether this SceneNode needs to be updated.

The SceneNode is considered "dirty" if either the `localTransform_` needs an update, or if the `needsUpdate_` property is set to true.

Returns

true if this SceneNode is considered to be dirty, otherwise false.

Definition at line 455 of file SceneNode.ixx.

455 [[nodiscard]] bool needsUpdate() const noexcept {
456 return needsUpdate_ || localTransform_.needsUpdate();
457 }

References localTransform_ and needsUpdate_.

Referenced by aabb, applyWorldTransform and worldTransform.

onWorldTransformUpdate()

virtual void helios::scene::SceneNode::onWorldTransformUpdate ()
inline noexcept virtual

Virtual callback invoked after the world transform has been updated.

Derived classes can override this method to perform additional processing when the node's world transform changes, such as updating dependent resources or triggering view matrix recalculations in camera nodes.

Definition at line 499 of file SceneNode.ixx.

499 virtual void onWorldTransformUpdate() noexcept {
500 if (renderable_) {
501 const auto& localAABB = renderable_->localAABB();
502 aabb_ = localAABB.applyTransform(worldTransform_);
503 }
504 }

References aabb_, renderable_ and worldTransform_.

Referenced by applyWorldTransform, helios::scene::CameraSceneNode::onWorldTransformUpdate and update.

parent()

SceneNode * helios::scene::SceneNode::parent ()
inline nodiscard noexcept

Returns a pointer to this node's parent node.

Returns

The pointer to this node's parent, or nullptr if no parent exists, e.g. for the root node.

Definition at line 365 of file SceneNode.ixx.

365 [[nodiscard]] SceneNode* parent() const noexcept {
366 return parent_;
367 }

References parent_ and SceneNode.

Referenced by helios::scene::CameraSceneNode::lookAt.

renderable()

helios::rendering::Renderable * helios::scene::SceneNode::renderable ()
inline nodiscard noexcept

Returns a raw pointer to the Renderable of this SceneNode.

Returns

A raw pointer to the Renderable, may be nullptr if none is set.

Definition at line 264 of file SceneNode.ixx.

264 [[nodiscard]] helios::rendering::Renderable* renderable() noexcept {
265 return renderable_.get();
266 }

Reference renderable_.

Referenced by helios::scene::Scene::createSnapshot, hasRenderable, SceneNode and SceneNode.

renderable()

const helios::rendering::Renderable * helios::scene::SceneNode::renderable ()
inline nodiscard noexcept

Returns a const pointer to the non-const Renderable of this SceneNode.

Returns

A shared_ptr to the Renderable, may be nullptr if none is set.

Definition at line 282 of file SceneNode.ixx.

282 [[nodiscard]] const helios::rendering::Renderable* renderable() const noexcept {
283 return renderable_.get();
284 }

Reference renderable_.

setActive()

void helios::scene::SceneNode::setActive (const bool active)
inline noexcept

Sets the active state of this SceneNode.

The active state determines whether the SceneNode should be considered for rendering.

Parameters
active

true to consider this SceneNodefor rendering, otherwise false.

Definition at line 576 of file SceneNode.ixx.

576 void setActive(const bool active) noexcept {
577 isActive_ = active;
578 }

Reference isActive_.

setInheritance()

void helios::scene::SceneNode::setInheritance (const helios::math::TransformType inherit)
inline noexcept

Sets which transform components this node inherits from its parent.

By default, nodes inherit all transform components (`TransformType::All`). Use this method to selectively inherit only Translation, Rotation, or Scale, enabling behaviors like cameras that follow an object's position but maintain independent orientation.

Parameters
inherit

The inheritance flags to apply.

See Also

helios::math::TransformType

Definition at line 544 of file SceneNode.ixx.

544 void setInheritance(const helios::math::TransformType inherit) noexcept {
545 inheritance_ = inherit;
546 needsUpdate_ = true;
547 }

References inheritance_ and needsUpdate_.

setIsRoot()

void helios::scene::SceneNode::setIsRoot (helios::scene::SceneGraphKey sceneGraphKey)
inline noexcept

Marks this node as the root of the scene graph.

Parameters
sceneGraphKey

The passkey for scene-graph-only access.

Definition at line 405 of file SceneNode.ixx.

405 void setIsRoot(helios::scene::SceneGraphKey sceneGraphKey) noexcept {
406 isRoot_ = true;
407 }

Reference isRoot_.

setRotation()

SceneNode & helios::scene::SceneNode::setRotation (const helios::math::mat4f & rotation)
inline noexcept

Applies rotation to this node's **local** transform. Marks the node dirty. Implementing APIs should consider updating the worldTransform of this node before rendering.

Parameters
rotation

The helios::math::mat4f rotation matrix.

Returns

A reference to this SceneNode.

Definition at line 319 of file SceneNode.ixx.

319 SceneNode& setRotation(const helios::math::mat4f& rotation) noexcept {
320 localTransform_.setRotation(rotation);
321 needsUpdate_ = true;
322 return *this;
323 }

References localTransform_, needsUpdate_ and SceneNode.

Referenced by helios::scene::CameraSceneNode::lookAt and helios::scene::CameraSceneNode::lookAtLocal.

setScale()

SceneNode & helios::scene::SceneNode::setScale (const helios::math::vec3f & scale)
inline noexcept

Applies a scaling transformation to this node's **local** transform. Marks the node dirty. Implementing APIs should consider updating the worldTransform of this node before rendering.

Parameters
scale

The helios::math::vec3f representing the node's scaling factors.

Returns

A reference to this SceneNode.

Definition at line 304 of file SceneNode.ixx.

304 SceneNode& setScale(const helios::math::vec3f& scale) noexcept {
305 localTransform_.setScale(scale);
306 needsUpdate_ = true;
307 return *this;
308 }

References localTransform_, needsUpdate_ and SceneNode.

setTranslation()

SceneNode & helios::scene::SceneNode::setTranslation (const helios::math::vec3f & translation)
inline noexcept

Applies translation to this node's **local** transform. Marks the node dirty. Implementing APIs should consider updating the worldTransform of this node before rendering.

Parameters
translation

The helios::math::vec3f representing the node's translation.

Returns

A reference to this SceneNode.

Definition at line 335 of file SceneNode.ixx.

335 SceneNode& setTranslation(const helios::math::vec3f& translation) noexcept {
336 localTransform_.setTranslation(translation);
337 needsUpdate_ = true;
338 return *this;
339 }

References localTransform_, needsUpdate_ and SceneNode.

shareRenderable()

std::shared_ptr< helios::rendering::Renderable > helios::scene::SceneNode::shareRenderable ()
inline nodiscard noexcept

Returns a shared pointer to the non-const Renderable of this SceneNode.

Returns

A shared_ptr to the Renderable, may be nullptr if none is set.

Definition at line 291 of file SceneNode.ixx.

291 [[nodiscard]] std::shared_ptr<helios::rendering::Renderable> shareRenderable() noexcept {
292 return renderable_;
293 }

Reference renderable_.

update()

void helios::scene::SceneNode::update ()
inline noexcept

Updates the world transform and axis-aligned bounding box of this SceneNode.

Recomputes the `worldTransform_` based on the parent's world transform and this node's `localTransform_`. Also updates the `aabb_` to reflect the current world-space bounds.

Definition at line 480 of file SceneNode.ixx.

480 void update() noexcept {
481 needsUpdate_ = false;
482
483 if (parent_ == nullptr) {
484 worldTransform_ = localTransform_.transform();
485 } else {
487 }
488
490 }

References inheritWorldTransform, localTransform_, needsUpdate_, onWorldTransformUpdate, parent_ and worldTransform_.

Referenced by aabb and worldTransform.

worldTransform()

const helios::math::mat4f & helios::scene::SceneNode::worldTransform ()
inline noexcept

Computes and returns the world transform for this SceneNode. Will request the current world transform from the parent node to calculate this SceneNode's world transform. For efficiency, this method should cache the result and only trigger a recompute if this SceneNode is dirty (`needsUpdate_ == true`).

Returns

The current world transform matrix for this scene node.

Definition at line 427 of file SceneNode.ixx.

428 if (needsUpdate()) {
429 update();
430 }
431
432 return worldTransform_;
433 }

References needsUpdate, update and worldTransform_.

Referenced by helios::scene::CameraSceneNode::lookAt.

Protected Member Functions

setParent()

void helios::scene::SceneNode::setParent (SceneNode * parentNode)
inline protected

Sets the parent of this SceneNode. Internally used once a child was added to this SceneNode.

Parameters
parentNode

The parent of this SceneNode

See Also

addNode()

Definition at line 151 of file SceneNode.ixx.

151 void setParent(SceneNode* parentNode) {
152 parent_ = parentNode;
153 }

References parent_ and SceneNode.

Protected Member Attributes

aabb_

helios::math::aabbf helios::scene::SceneNode::aabb_ {}
protected

The axis-aligned-bounding-box for this SceneNode in world-coordinates.

Definition at line 129 of file SceneNode.ixx.

Referenced by aabb and onWorldTransformUpdate.

children_

std::vector<std::unique_ptr<SceneNode> > helios::scene::SceneNode::children_
protected

A list of unique pointers to this node's children. Ensures ownership of the child nodes withing the graph hierarchy.

Definition at line 103 of file SceneNode.ixx.

103 std::vector<std::unique_ptr<SceneNode>> children_;

Referenced by addNode and children.

inheritance_

helios::math::TransformType helios::scene::SceneNode::inheritance_ = helios::math::TransformType::All
protected

Flags controlling which transform components are inherited from the parent node.

By default set to `TransformType::All`, meaning translation, rotation, and scale are all inherited from the parent's world transform. Use `setInheritance()` to selectively disable inheritance of specific components.

See Also

setInheritance()

See Also

inheritWorldTransform()

Definition at line 141 of file SceneNode.ixx.

Referenced by inheritance, inheritWorldTransform, helios::scene::CameraSceneNode::lookAt and setInheritance.

isActive_

bool helios::scene::SceneNode::isActive_ = true
protected

Boolean flag indicating whether this SceneNode should be considered for rendering.

Definition at line 124 of file SceneNode.ixx.

124 bool isActive_ = true;

Referenced by isActive and setActive.

isRoot_

bool helios::scene::SceneNode::isRoot_ = false
protected

True if this node is the root of the scene graph.

Definition at line 83 of file SceneNode.ixx.

83 bool isRoot_ = false;

Referenced by isRoot and setIsRoot.

localTransform_

Transform helios::scene::SceneNode::localTransform_
protected

A local transformation representing affine transformation information for this SceneNode. Encapsulates rotation, scaling and translation.

Definition at line 118 of file SceneNode.ixx.

Referenced by inheritWorldTransform, localTransform, localTransform, needsUpdate, setRotation, setScale, setTranslation and update.

needsUpdate_

bool helios::scene::SceneNode::needsUpdate_ = true
protected

Boolean flag to represent the dirty-state of this node. Should be set to false if the current `worldTransform_` for this node was computed, otherwise true, e.g. if the node's local transform has been changed.

Definition at line 78 of file SceneNode.ixx.

78 bool needsUpdate_ = true;

Referenced by applyWorldTransform, needsUpdate, setInheritance, setRotation, setScale, setTranslation and update.

parent_

SceneNode* helios::scene::SceneNode::parent_ = nullptr
protected

The parent node of **this** node. This will be nullptr for any root node. Implementing APIs must take care of properly assigning parent nodes when adding child nodes.

Definition at line 97 of file SceneNode.ixx.

97 SceneNode* parent_ = nullptr;

Referenced by parent, setParent and update.

renderable_

std::shared_ptr<helios::rendering::Renderable> helios::scene::SceneNode::renderable_ = nullptr
protected

A shared pointer to the Renderable this node represents in the SceneGraph. May be nullptr if this node does not represent a.

Definition at line 89 of file SceneNode.ixx.

89 std::shared_ptr<helios::rendering::Renderable> renderable_ = nullptr;

Referenced by onWorldTransformUpdate, renderable, renderable and shareRenderable.

worldTransform_

math::mat4f helios::scene::SceneNode::worldTransform_ = math::mat4f::identity()
protected

The 4x4 worldTransform-Matrix of this node. This matrix is initially set to the identity matrix. Implementing APIs MUST make sure to recompute the worldTransform before each rendering pass.

Definition at line 111 of file SceneNode.ixx.

Referenced by applyWorldTransform, cachedWorldTransform, onWorldTransformUpdate, update and worldTransform.

Private Member Attributes

guid_

const util::Guid helios::scene::SceneNode::guid_

A unique identifier for this SceneNode, computed automatically during instantiation.

Definition at line 69 of file SceneNode.ixx.

69 const util::Guid guid_;

The documentation for this class was generated from the following file:


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.