SLProject 4.0.000
SLEntities Class Reference

Scenegraph in Data Oriented Design with flat std::vector of SLEntity. More...

#include <SLEntities.h>

Public Member Functions

void addChildEntity (SLint myParentID, SLEntity entity)
 Adds a child into the vector nodes right after its parent. More...
 
void deleteEntity (SLint id)
 Deletes a node at index id with all its children. More...
 
void deleteChildren (SLint id)
 Deletes all children of an entity with index id. More...
 
SLint updateWMRec (SLint id, SLMat4f &parentWM)
 Updates all world matrices and returns no. of updated. More...
 
SLEntitygetEntity (SLint id)
 Returns the pointer to a node if id is valid else a nullptr. More...
 
SLint getEntityID (SLNode *node)
 Returns the ID of the entity with a SLNode pointer. More...
 
SLEntitygetParent (SLint id)
 Returns the pointer to the parent of a node if id is valid else a nullptr. More...
 
SLint getParentID (SLNode *node)
 Returns the parentID of a SLNode pointer. More...
 
void dump (SLbool doTreeDump)
 Dump scenegraph as a flat vector or as a tree. More...
 
SLuint size ()
 Returns the size of the entity vector. More...
 
void clear ()
 Clears the the entities vector. More...
 

Private Attributes

SLVEntity _graph
 Vector of SLEntity of entire scenegraph. More...
 

Detailed Description

Scenegraph in Data Oriented Design with flat std::vector of SLEntity.

Member Function Documentation

◆ addChildEntity()

void SLEntities::addChildEntity ( SLint  myParentID,
SLEntity  entity 
)

Adds a child into the vector nodes right after its parent.

addChild adds a child node by inserting an SLEntities into a vector in Depth First Search order. The root node gets the parent ID -1. The child is inserted right after the parent node.

Parameters
myParentIDIndex of the parent node
entityThe entity to add as child of the parent

◆ clear()

void SLEntities::clear ( )
inline

Clears the the entities vector.

◆ deleteChildren()

void SLEntities::deleteChildren ( SLint  id)

Deletes all children of an entity with index id.

Deletes all children of an entity with the index id. Also sub-children of those children get deleted.

Parameters
idIndex of the parent entity

◆ deleteEntity()

void SLEntities::deleteEntity ( SLint  id)

Deletes a node at index id with all its children.

Deletes a node at index id with all with all children

Parameters
idIndex of node to delete

◆ dump()

void SLEntities::dump ( SLbool  doTreeDump)

Dump scenegraph as a flat vector or as a tree.

Prints the scenegraph vector flat or as hierarchical tree as follows:

Parameters
doTreeDumpFlag if dump as a tree or flat

Pattern: ID.Parent.childCount Example from SLEntities::addChild: 00.-1.04 +–01.00.01 | +–02.01.00 +–03.00.00 +–04.00.02 | +–05.04.00 | +–06.04.01 | | +–07.06.01 | | | +–08.07.00 +–09.00.00

◆ getEntity()

SLEntity * SLEntities::getEntity ( SLint  id)

Returns the pointer to a node if id is valid else a nullptr.

Returns the pointer to the node at id

Parameters
idThe index of the node to return as a pointer
Returns
The pointer of the node at id

◆ getEntityID()

SLint SLEntities::getEntityID ( SLNode node)

Returns the ID of the entity with a SLNode pointer.

Returns the ID for the passed SLNode if found else INT32_MIN

◆ getParent()

SLEntity * SLEntities::getParent ( SLint  id)

Returns the pointer to the parent of a node if id is valid else a nullptr.

Returns the pointer to the parent of the node at id

Parameters
idThe index of the node in the scenegraph vector
Returns
The pointer of the parent of the node at id

◆ getParentID()

SLint SLEntities::getParentID ( SLNode node)

Returns the parentID of a SLNode pointer.

Returns the parentID for the passed SLNode if found else INT32_MIN

◆ size()

SLuint SLEntities::size ( )
inline

Returns the size of the entity vector.

◆ updateWMRec()

SLint SLEntities::updateWMRec ( SLint  id,
SLMat4f parentWM 
)

Updates all world matrices and returns no. of updated.

Updates the world matrix recursively

Parameters
idIndex of the current node to update
parentWMWorld transform matrix of the parent
Returns
The no. of nodes updated

Member Data Documentation

◆ _graph

SLVEntity SLEntities::_graph
private

Vector of SLEntity of entire scenegraph.


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