Skip to main content

SceneNodeComponent Class

Component that links a GameObject to a SceneNode in the scene graph. More...

Declaration

class helios::engine::modules::scene::components::SceneNodeComponent { ... }

Public Constructors Index

SceneNodeComponent (helios::scene::SceneNode *sceneNode)

Constructs a SceneNodeComponent linked to a SceneNode. More...

SceneNodeComponent (const SceneNodeComponent &other)=default

Copy constructor. More...

SceneNodeComponent (SceneNodeComponent &&) noexcept=default

Move constructor. More...

Public Operators Index

SceneNodeComponent &operator= (const SceneNodeComponent &)=default

Copy assignment operator. More...

SceneNodeComponent &operator= (SceneNodeComponent &&) noexcept=default

Move assignment operator. More...

Public Member Functions Index

boolisEnabled () const noexcept

Checks whether this component is enabled. More...

voidenable () noexcept

Enables this component. More...

voiddisable () noexcept

Disables this component. More...

voidonActivate () noexcept

Called when the owning GameObject is activated. More...

voidonDeactivate () noexcept

Called when the owning GameObject is deactivated. More...

voidonClone (const SceneNodeComponent &other)

Called after copy construction during entity cloning. More...

helios::scene::SceneNode *sceneNode () const noexcept

Returns the underlying SceneNode. More...

Protected Member Attributes Index

helios::scene::SceneNode *sceneNode_

Non-owning pointer to the associated SceneNode. More...

boolisEnabled_ = true

Whether this component is enabled. More...

Description

Component that links a GameObject to a SceneNode in the scene graph.

This component bridges the game logic layer (GameObject) with the rendering layer (SceneNode). It captures the initial AABB from the SceneNode's mesh (if available) and exposes the underlying SceneNode for other components to use.

info

The SceneNode must remain valid for the lifetime of this component.

Definition at line 35 of file SceneNodeComponent.ixx.

Public Constructors

SceneNodeComponent()

helios::engine::modules::scene::components::SceneNodeComponent::SceneNodeComponent (helios::scene::SceneNode * sceneNode)
inline explicit

Constructs a SceneNodeComponent linked to a SceneNode.

Parameters
sceneNode

Pointer to the SceneNode to control. Must not be nullptr.

Definition at line 99 of file SceneNodeComponent.ixx.

101
102 assert(sceneNode_ != nullptr && "sceneNode must not be nullptr");
103 }

References sceneNode and sceneNode_.

Referenced by onClone, operator=, operator=, SceneNodeComponent and SceneNodeComponent.

SceneNodeComponent()

helios::engine::modules::scene::components::SceneNodeComponent::SceneNodeComponent (const SceneNodeComponent & other)
default

Copy constructor.

Copies the SceneNode pointer. The actual SceneNode cloning is handled by onClone() during entity cloning.

Definition at line 111 of file SceneNodeComponent.ixx.

Reference SceneNodeComponent.

SceneNodeComponent()

helios::engine::modules::scene::components::SceneNodeComponent::SceneNodeComponent (SceneNodeComponent &&)
noexcept default

Move constructor.

Definition at line 121 of file SceneNodeComponent.ixx.

Reference SceneNodeComponent.

Public Operators

operator=()

SceneNodeComponent & helios::engine::modules::scene::components::SceneNodeComponent::operator= (const SceneNodeComponent &)
default

Copy assignment operator.

Definition at line 116 of file SceneNodeComponent.ixx.

Reference SceneNodeComponent.

operator=()

SceneNodeComponent & helios::engine::modules::scene::components::SceneNodeComponent::operator= (SceneNodeComponent &&)
noexcept default

Move assignment operator.

Definition at line 126 of file SceneNodeComponent.ixx.

Reference SceneNodeComponent.

Public Member Functions

disable()

void helios::engine::modules::scene::components::SceneNodeComponent::disable ()
inline noexcept

Disables this component.

Definition at line 70 of file SceneNodeComponent.ixx.

70 void disable() noexcept {
71 isEnabled_ = false;
72 }

Reference isEnabled_.

enable()

void helios::engine::modules::scene::components::SceneNodeComponent::enable ()
inline noexcept

Enables this component.

Definition at line 63 of file SceneNodeComponent.ixx.

63 void enable() noexcept {
64 isEnabled_ = true;
65 }

Reference isEnabled_.

isEnabled()

bool helios::engine::modules::scene::components::SceneNodeComponent::isEnabled ()
inline nodiscard noexcept

Checks whether this component is enabled.

Returns

True if enabled, false otherwise.

Definition at line 56 of file SceneNodeComponent.ixx.

56 [[nodiscard]] bool isEnabled() const noexcept {
57 return isEnabled_;
58 }

Reference isEnabled_.

onActivate()

void helios::engine::modules::scene::components::SceneNodeComponent::onActivate ()
inline noexcept

Called when the owning GameObject is activated.

Activates the SceneNode, making it visible in the scene graph.

Definition at line 79 of file SceneNodeComponent.ixx.

79 void onActivate() noexcept {
80 sceneNode_->setActive(true);
81 }

Reference sceneNode_.

onClone()

void helios::engine::modules::scene::components::SceneNodeComponent::onClone (const SceneNodeComponent & other)
inline

Called after copy construction during entity cloning.

Creates a new SceneNode for this entity by cloning the source's renderable and adding it to the same parent node. This ensures each cloned entity has its own SceneNode in the scene graph.

Parameters
other

The source component to clone from.

Definition at line 137 of file SceneNodeComponent.ixx.

137 void onClone(const SceneNodeComponent& other) {
138
139
140 auto* parent = other.sceneNode_->parent();
141
142 assert(parent != nullptr && "unexpected nullptr for SceneNode's parent");
143
144 auto sceneNode = std::make_unique<helios::scene::SceneNode>(other.sceneNode_->shareRenderable());
145
146 sceneNode_ = parent->addNode(std::move(sceneNode));
147 }

References onClone, sceneNode, sceneNode_ and SceneNodeComponent.

Referenced by onClone.

onDeactivate()

void helios::engine::modules::scene::components::SceneNodeComponent::onDeactivate ()
inline noexcept

Called when the owning GameObject is deactivated.

Deactivates the SceneNode, hiding it from the scene graph.

Definition at line 88 of file SceneNodeComponent.ixx.

88 void onDeactivate() noexcept {
89 sceneNode_->setActive(false);
90 }

Reference sceneNode_.

sceneNode()

helios::scene::SceneNode * helios::engine::modules::scene::components::SceneNodeComponent::sceneNode ()
inline nodiscard noexcept

Returns the underlying SceneNode.

Returns

Non-owning pointer to the associated SceneNode.

Definition at line 155 of file SceneNodeComponent.ixx.

155 [[nodiscard]] helios::scene::SceneNode* sceneNode() const noexcept {
156 return sceneNode_;
157 }

Reference sceneNode_.

Referenced by onClone and SceneNodeComponent.

Protected Member Attributes

isEnabled_

bool helios::engine::modules::scene::components::SceneNodeComponent::isEnabled_ = true
protected

Whether this component is enabled.

Definition at line 47 of file SceneNodeComponent.ixx.

47 bool isEnabled_ = true;

Referenced by disable, enable and isEnabled.

sceneNode_

helios::scene::SceneNode* helios::engine::modules::scene::components::SceneNodeComponent::sceneNode_
protected

Non-owning pointer to the associated SceneNode.

Definition at line 42 of file SceneNodeComponent.ixx.

Referenced by onActivate, onClone, onDeactivate, sceneNode and SceneNodeComponent.


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


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.