Vulkan Schnee 0.0.1
High-performance rendering engine
Loading...
Searching...
No Matches
EngineCore::SceneNode Class Reference

Represents a node in the scene graph, containing information about its position, rotation, and scale relative to its parent. It also holds references to its parent and children nodes. More...

#include <SceneGraph.h>

Inheritance diagram for EngineCore::SceneNode:
Collaboration diagram for EngineCore::SceneNode:

Public Member Functions

 ~SceneNode ()
Ecs::LocalTransformgetLocalTransform ()
 Gets the local transform of the scene node. The local transform is relative to the parent node.
const Ecs::LocalTransformgetLocalTransform () const
void registerWithEcs ()
entt::entity getEntity () const
 Gets the entity associated with this scene node.
void setWorldPosition (const glm::vec3 &newLocation)
 Sets the world position of the scene node. This will calculate the corresponding local position based on the parent's world transform.
void setWorldRotation (const glm::vec3 &newRotation)
 Sets the world rotation of this node with euler angles.
void setWorldRotation (const glm::quat &newRotation)
 Sets a new world rotation with a quaternion on this node.
void rotateWorld (const glm::vec3 &deltaRotation)
 Applies an incremental rotation to the current world rotation using quaternion multiplication. This avoids euler angle instability that occurs with get/set rotation round-trips.
void rotateWorld (const glm::quat &deltaRotation)
 Applies an incremental rotation to the current world rotation using quaternion multiplication.
void setWorldScale (const glm::vec3 &newScale)
 sets the scale for this node
void setLocalModelMatrix (const glm::mat4 &newModelMatrix)
 Overwrites all components of the transform.
void setWorldModelMatrix (const glm::mat4 &newModelMatrix)
 Overwrites all components of this transform.
void addChild (const std::shared_ptr< SceneNode > &newChild)
 Adds a child node to this node.
void addChildren (std::vector< std::shared_ptr< SceneNode > > newChildren)
 adds new children to this node
void clearChildren ()
 Removes all children from this node.
void removeChild (const std::shared_ptr< SceneNode > &child)
 Removes a single child from this node.
const glm::mat4 & getWorldMatrix () const
 get the world matrix as a raw glm matrix
bool isWorldMatrixDirty () const
 Checks if the world matrix has to be recalculated.
bool isRoot () const
 Checks if this node is the root node.
std::vector< std::weak_ptr< SceneNode > > getChildren () const
 Get a list of all children of this node.
void markDirtyRecursive ()
 Marks this node and its children as dirty.

Protected Member Functions

 SceneNode (entt::registry &registry, bool disableCaching=false)
 Constructs a new Scene Node object.

Private Member Functions

void updateWorldMatrix () const

Private Attributes

std::shared_ptr< SceneNodeparent = nullptr
std::vector< std::shared_ptr< SceneNode > > children
size_t indexInParent = 0
entt::entity entity
entt::registry * registry
glm::mat4 worldMatrix
bool disableCaching = false

Friends

class SceneGraph
class NodeFactory

Detailed Description

Represents a node in the scene graph, containing information about its position, rotation, and scale relative to its parent. It also holds references to its parent and children nodes.

Date
2025-07-23
Author
Konstantin Passig

Definition at line 24 of file SceneGraph.h.

Constructor & Destructor Documentation

◆ SceneNode()

EngineCore::SceneNode::SceneNode ( entt::registry & reg,
bool disableCaching = false )
explicitprotected

Constructs a new Scene Node object.

Parameters
registryentt registry where the transform should be registered to
disableCachingIf true, the world matrix of this node will be recalculated every time it is requested, rather than being cached. This is useful for nodes that change frequently.
Date
2025-07-23
Author
Konstantin Passig

Definition at line 15 of file SceneGraph.cpp.

References disableCaching, entity, registry, and worldMatrix.

Referenced by EngineCore::RootNode::RootNode().

Here is the caller graph for this function:

◆ ~SceneNode()

EngineCore::SceneNode::~SceneNode ( )

Definition at line 26 of file SceneGraph.cpp.

References entity, and registry.

Member Function Documentation

◆ addChild()

void EngineCore::SceneNode::addChild ( const std::shared_ptr< SceneNode > & newChild)

Adds a child node to this node.

Parameters
newChildchild node to add to this node
Date
2025-12-01
Author
Konstantin Passig

Definition at line 157 of file SceneGraph.cpp.

References children.

◆ addChildren()

void EngineCore::SceneNode::addChildren ( std::vector< std::shared_ptr< SceneNode > > newChildren)

adds new children to this node

Parameters
newChildrenlist of new children to add to this node
Date
2025-12-01
Author
Konstantin Passig

Definition at line 163 of file SceneGraph.cpp.

References children.

◆ clearChildren()

void EngineCore::SceneNode::clearChildren ( )

Removes all children from this node.

Date
2025-12-01
Author
Konstantin Passig

Definition at line 172 of file SceneGraph.cpp.

References children.

◆ getChildren()

std::vector< std::weak_ptr< SceneNode > > EngineCore::SceneNode::getChildren ( ) const

Get a list of all children of this node.

Returns
list of all children of this node
Date
2025-12-02
Author
Konstantin Passig

Definition at line 217 of file SceneGraph.cpp.

References children.

◆ getEntity()

entt::entity EngineCore::SceneNode::getEntity ( ) const

Gets the entity associated with this scene node.

Returns
The entt entity for this node.
Date
2025-12-01
Author
Konstantin Passig

Definition at line 49 of file SceneGraph.cpp.

References entity.

◆ getLocalTransform() [1/2]

Ecs::LocalTransform & EngineCore::SceneNode::getLocalTransform ( )

Gets the local transform of the scene node. The local transform is relative to the parent node.

Gets the local transform of the scene node. The local transform is relative to the parent node.

Returns
A reference to the local LocalTransform ECS component.
Date
2025-07-23
Author
Konstantin Passig
Returns
A reference to the local LocalTransform ECS component.
Date
2025-07-23
Author
Konstantin Passig

Definition at line 36 of file SceneGraph.cpp.

References entity, and registry.

Referenced by setLocalModelMatrix(), setWorldModelMatrix(), setWorldPosition(), setWorldRotation(), setWorldScale(), and updateWorldMatrix().

Here is the caller graph for this function:

◆ getLocalTransform() [2/2]

const Ecs::LocalTransform & EngineCore::SceneNode::getLocalTransform ( ) const

Definition at line 40 of file SceneGraph.cpp.

References entity, and registry.

◆ getWorldMatrix()

const glm::mat4 & EngineCore::SceneNode::getWorldMatrix ( ) const

get the world matrix as a raw glm matrix

Returns
the world matrix
Date
2025-12-02
Author
Konstantin Passig

Definition at line 204 of file SceneGraph.cpp.

References disableCaching, isWorldMatrixDirty(), updateWorldMatrix(), and worldMatrix.

Referenced by rotateWorld(), setWorldPosition(), setWorldRotation(), and setWorldScale().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isRoot()

bool EngineCore::SceneNode::isRoot ( ) const

Checks if this node is the root node.

Returns
true if it is the root node
Date
2025-12-02
Author
Konstantin Passig

Definition at line 213 of file SceneGraph.cpp.

References parent.

◆ isWorldMatrixDirty()

bool EngineCore::SceneNode::isWorldMatrixDirty ( ) const

Checks if the world matrix has to be recalculated.

Returns
if the world matrix is dirty
Date
2025-12-02
Author
Konstantin Passig

Definition at line 226 of file SceneGraph.cpp.

References entity, and registry.

Referenced by getWorldMatrix().

Here is the caller graph for this function:

◆ markDirtyRecursive()

void EngineCore::SceneNode::markDirtyRecursive ( )

Marks this node and its children as dirty.

Date
2025-12-02
Author
Konstantin Passig

Definition at line 230 of file SceneGraph.cpp.

References children, entity, and registry.

Referenced by setLocalModelMatrix(), setWorldModelMatrix(), setWorldPosition(), setWorldRotation(), and setWorldScale().

Here is the caller graph for this function:

◆ registerWithEcs()

void EngineCore::SceneNode::registerWithEcs ( )

Definition at line 44 of file SceneGraph.cpp.

References entity, and registry.

◆ removeChild()

void EngineCore::SceneNode::removeChild ( const std::shared_ptr< SceneNode > & child)

Removes a single child from this node.

Parameters
childthe child to remove
Date
2025-12-01
Author
Konstantin Passig

Definition at line 179 of file SceneGraph.cpp.

References children.

◆ rotateWorld() [1/2]

void EngineCore::SceneNode::rotateWorld ( const glm::quat & deltaRotation)

Applies an incremental rotation to the current world rotation using quaternion multiplication.

Parameters
deltaRotationquaternion to multiply with the current rotation
Date
2025-01-16
Author
Konstantin Passig

Definition at line 110 of file SceneGraph.cpp.

References Ecs::TransformOperators::getRotation(), getWorldMatrix(), and setWorldRotation().

Here is the call graph for this function:

◆ rotateWorld() [2/2]

void EngineCore::SceneNode::rotateWorld ( const glm::vec3 & deltaRotation)

Applies an incremental rotation to the current world rotation using quaternion multiplication. This avoids euler angle instability that occurs with get/set rotation round-trips.

Parameters
deltaRotationeuler angles (degrees) to rotate by
Date
2025-01-16
Author
Konstantin Passig

Definition at line 106 of file SceneGraph.cpp.

References rotateWorld().

Referenced by rotateWorld().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setLocalModelMatrix()

void EngineCore::SceneNode::setLocalModelMatrix ( const glm::mat4 & newModelMatrix)

Overwrites all components of the transform.

Parameters
newModelMatrixnew 4x4 model matrix
Date
06.12.2025
Author
Konstantin Passig

Definition at line 138 of file SceneGraph.cpp.

References getLocalTransform(), markDirtyRecursive(), and Ecs::LocalTransform::matrix.

Here is the call graph for this function:

◆ setWorldModelMatrix()

void EngineCore::SceneNode::setWorldModelMatrix ( const glm::mat4 & newModelMatrix)

Overwrites all components of this transform.

Parameters
newModelMatrixnew 4x4 model matrix
Date
06.12.2025
Author
Konstantin Passig

Definition at line 144 of file SceneGraph.cpp.

References getLocalTransform(), markDirtyRecursive(), Ecs::LocalTransform::matrix, and parent.

Here is the call graph for this function:

◆ setWorldPosition()

void EngineCore::SceneNode::setWorldPosition ( const glm::vec3 & newLocation)

Sets the world position of the scene node. This will calculate the corresponding local position based on the parent's world transform.

Sets the world position of the scene node. This will calculate the corresponding local position based on the parent's world transform.

Parameters
newLocationThe new position in world space.
Date
2025-07-23
Author
Konstantin Passig
Parameters
newLocationThe new position in world space.
Date
2025-07-23
Author
Konstantin Passig

Definition at line 57 of file SceneGraph.cpp.

References getLocalTransform(), Ecs::TransformOperators::getRotation(), Ecs::TransformOperators::getScale(), getWorldMatrix(), markDirtyRecursive(), Ecs::LocalTransform::matrix, parent, and Ecs::TransformOperators::setPosition().

Here is the call graph for this function:

◆ setWorldRotation() [1/2]

void EngineCore::SceneNode::setWorldRotation ( const glm::quat & newRotation)

Sets a new world rotation with a quaternion on this node.

Parameters
newRotationquaternion rotation
Date
2025-12-01
Author
Konstantin Passig

Definition at line 85 of file SceneGraph.cpp.

References getLocalTransform(), Ecs::TransformOperators::getPosition(), Ecs::TransformOperators::getScale(), getWorldMatrix(), markDirtyRecursive(), Ecs::LocalTransform::matrix, parent, and Ecs::TransformOperators::setRotation().

Here is the call graph for this function:

◆ setWorldRotation() [2/2]

void EngineCore::SceneNode::setWorldRotation ( const glm::vec3 & newRotation)

Sets the world rotation of this node with euler angles.

Parameters
newRotationyaw pitch roll
Date
2025-12-01
Author
Konstantin Passig

Definition at line 81 of file SceneGraph.cpp.

References setWorldRotation().

Referenced by rotateWorld(), and setWorldRotation().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setWorldScale()

void EngineCore::SceneNode::setWorldScale ( const glm::vec3 & newScale)

sets the scale for this node

Parameters
newScalethe scale to be set to
Date
2025-12-01
Author
Konstantin Passig

Definition at line 117 of file SceneGraph.cpp.

References getLocalTransform(), Ecs::TransformOperators::getPosition(), Ecs::TransformOperators::getRotation(), getWorldMatrix(), markDirtyRecursive(), Ecs::LocalTransform::matrix, parent, and Ecs::TransformOperators::setScale().

Here is the call graph for this function:

◆ updateWorldMatrix()

void EngineCore::SceneNode::updateWorldMatrix ( ) const
private

Definition at line 189 of file SceneGraph.cpp.

References disableCaching, entity, getLocalTransform(), Ecs::LocalTransform::matrix, parent, registry, and worldMatrix.

Referenced by getWorldMatrix().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ NodeFactory

friend class NodeFactory
friend

Definition at line 26 of file SceneGraph.h.

References disableCaching, NodeFactory, and registry.

Referenced by NodeFactory.

◆ SceneGraph

friend class SceneGraph
friend

Definition at line 25 of file SceneGraph.h.

References SceneGraph.

Referenced by SceneGraph.

Member Data Documentation

◆ children

std::vector<std::shared_ptr<SceneNode> > EngineCore::SceneNode::children
private

◆ disableCaching

bool EngineCore::SceneNode::disableCaching = false
private

Definition at line 244 of file SceneGraph.h.

Referenced by getWorldMatrix(), NodeFactory, SceneNode(), and updateWorldMatrix().

◆ entity

entt::entity EngineCore::SceneNode::entity
private

◆ indexInParent

size_t EngineCore::SceneNode::indexInParent = 0
private

Definition at line 238 of file SceneGraph.h.

◆ parent

std::shared_ptr<SceneNode> EngineCore::SceneNode::parent = nullptr
private

◆ registry

◆ worldMatrix

glm::mat4 EngineCore::SceneNode::worldMatrix
mutableprivate

Definition at line 243 of file SceneGraph.h.

Referenced by getWorldMatrix(), SceneNode(), and updateWorldMatrix().


The documentation for this class was generated from the following files:
  • /home/magerbeton/Documents/gl3-vulkan/Engine/include/Engine/World/SceneGraph.h
  • /home/magerbeton/Documents/gl3-vulkan/Engine/src/Engine/World/SceneGraph.cpp