Overte C++ Documentation
render::Scene Class Reference

Scene is a container for Items. Items are introduced, modified or erased in the scene through Transaction. Once per Frame, the Transaction are all flushed. During the flush the standard buckets are updated. Items are notified accordingly on any update message happening. More...

#include <Scene.h>

Public Member Functions

 Scene (glm::vec3 origin, float size)
 
ItemID allocateID ()
 Get a new, unique item ID. More...
 
bool isAllocatedID (const ItemID &id) const
 Check that the ID is valid and allocated for this scene, this a threadsafe call. More...
 
size_t getNumItems () const
 Get the total number of allocated items, this a threadsafe call. More...
 
void enqueueTransaction (const Transaction &transaction)
 Enqueue transaction to the scene. More...
 
void enqueueTransactionMove (Transaction &&transaction)
 Enqueue transaction to the scene by moving it. More...
 
uint32_t enqueueFrame ()
 Enqueue end of frame transactions boundary. More...
 
void processTransactionQueue ()
 Process the pending transactions queued. More...
 
Selection getSelection (const Selection::Name &name) const
 Access a particular selection (empty if doesn't exist) More...
 
bool isSelectionEmpty (const Selection::Name &name) const
 Check if a particular selection is empty (returns ). More...
 
void addItemToSelection (const std::string &selectionName, ItemID itemID)
 Add a single item to a selection by name. More...
 
void removeSelection (const std::string &selectionName)
 Remove a selection by name. More...
 
const Item & getItem (const ItemID &id) const
 Access a particular item from its ID. More...
 
const Item getItemSafe (const ItemID &id) const
 Same as getItem, checking if the id is valid. More...
 
const ItemSpatialTree & getSpatialTree () const
 Access the spatialized items. More...
 
const ItemIDSet & getNonspatialSet () const
 Access non-spatialized items (layered objects, backgrounds). More...
 
StagePointer getStage (const Stage::Name &name) const
 Access a particular Stage (empty pointer if it doesn't exist). More...
 
template<class T >
std::shared_ptr< T > getStage (const Stage::Name &name=T::getName()) const
 Access stage of a given type. More...
 
void resetStage (const Stage::Name &name, const StagePointer &stage)
 Assign a given instance of a stage object to a given name. More...
 
void simulate (ItemID id, RenderArgs *args)
 Perform renderer-side simulation of a given item. More...
 
HighlightStyle getOutlineStyle (ItemID id, const ViewFrustum &viewFrustum, uint16_t height)
 Returns outline style properties for a given item. More...
 

Detailed Description

Scene is a container for Items. Items are introduced, modified or erased in the scene through Transaction. Once per Frame, the Transaction are all flushed. During the flush the standard buckets are updated. Items are notified accordingly on any update message happening.

Constructor & Destructor Documentation

◆ Scene()

Scene::Scene ( glm::vec3  origin,
float  size 
)
Parameters
originCoordinates of the beginning point of the octree. Minimum X, Y and Z position that an item may have.
sizeSize of the octree. All rendered entities must fit inside.

Member Function Documentation

◆ addItemToSelection()

void Scene::addItemToSelection ( const std::string &  selectionName,
ItemID  itemID 
)

Add a single item to a selection by name.

Thread safe

Parameters
selectionNameUnique name of the selection.
itemIDItem ID.

◆ allocateID()

ItemID Scene::allocateID ( )

Get a new, unique item ID.

This call is thread safe, can be called from anywhere to allocate a new ID

Returns
New ID.

◆ enqueueFrame()

uint32_t Scene::enqueueFrame ( )

Enqueue end of frame transactions boundary.

This is a thread-safe call.

Returns
New frame number.

◆ enqueueTransaction()

void Scene::enqueueTransaction ( const Transaction &  transaction)

Enqueue transaction to the scene.

Enqueue change batch to the scene.

This is a thread-safe call.

Parameters
transactionTransaction to enqueue.

◆ enqueueTransactionMove()

void Scene::enqueueTransactionMove ( Transaction &&  transaction)

Enqueue transaction to the scene by moving it.

This is a thread-safe call.

Parameters
transactionTransaction to enqueue.

◆ getItem()

const Item& render::Scene::getItem ( const ItemID &  id) const
inline

Access a particular item from its ID.

Not thread safe. WARNING, There is no check on the validity of the ID, so this could return a bad Item.

Parameters
idItem ID, must be valid.
Returns
Item with a given ID.

◆ getItemSafe()

const Item render::Scene::getItemSafe ( const ItemID &  id) const
inline

Same as getItem, checking if the id is valid.

Not thread safe.

Parameters
idItem ID.
Returns
Item with a given ID.

◆ getNonspatialSet()

const ItemIDSet& render::Scene::getNonspatialSet ( ) const
inline

Access non-spatialized items (layered objects, backgrounds).

Not thread safe.

Returns
Set of non-spatialized items.

◆ getNumItems()

size_t render::Scene::getNumItems ( ) const
inline

Get the total number of allocated items, this a threadsafe call.

Returns
Total number of allocated items.

◆ getOutlineStyle()

HighlightStyle render::Scene::getOutlineStyle ( ItemID  id,
const ViewFrustum &  viewFrustum,
uint16_t  height 
)
inline

Returns outline style properties for a given item.

Not thread-safe.

Parameters
idItem ID.
viewFrustumCurrent view frustum from render args.
heightFramebuffer height in pixels.
Returns
Object describing outline style.

◆ getSelection()

Selection Scene::getSelection ( const Selection::Name &  name) const

Access a particular selection (empty if doesn't exist)

Thread safe.

Parameters
nameUnique name of the selection.
Returns
Object containing name and list of entities in the selection.

◆ getSpatialTree()

const ItemSpatialTree& render::Scene::getSpatialTree ( ) const
inline

Access the spatialized items.

Not thread safe.

Returns
Octree containing items.

◆ getStage() [1/2]

StagePointer Scene::getStage ( const Stage::Name &  name) const

Access a particular Stage (empty pointer if it doesn't exist).

Thread safe.

Parameters
nameStage name, as returned by getName() static function of a given stage type.
Returns
Shared pointer to the stage.

◆ getStage() [2/2]

template<class T >
std::shared_ptr<T> render::Scene::getStage ( const Stage::Name &  name = T::getName()) const
inline

Access stage of a given type.

Thread safe.

Template Parameters
TType of the stage.
Parameters
nameStage name, typically as returned by getName() static function of a given stage type.
Returns
Shared pointer to a requested stage.

◆ isAllocatedID()

bool Scene::isAllocatedID ( const ItemID &  id) const

Check that the ID is valid and allocated for this scene, this a threadsafe call.

Parameters
idID to be checked.
Returns
true if ID was already assigned.

◆ isSelectionEmpty()

bool Scene::isSelectionEmpty ( const Selection::Name &  name) const

Check if a particular selection is empty (returns ).

Thread safe.

Parameters
nameUnique name of the selection.
Returns
true if selection doesn't exist.

◆ processTransactionQueue()

void Scene::processTransactionQueue ( )

Process the pending transactions queued.

Processes all queued frames. Called on render thread on every frame and also on main thread during shutdown.

◆ removeSelection()

void Scene::removeSelection ( const std::string &  selectionName)

Remove a selection by name.

Thread safe

Parameters
selectionNameUnique name of the selection.

◆ resetStage()

void Scene::resetStage ( const Stage::Name &  name,
const StagePointer &  stage 
)

Assign a given instance of a stage object to a given name.

Used during setup when creating instances of the stage objects.

Parameters
nameStage name, typically as returned by getName() static function of a given stage type.
stageShared pointer to a stage object.

◆ simulate()

void render::Scene::simulate ( ItemID  id,
RenderArgs *  args 
)
inline

Perform renderer-side simulation of a given item.

Not thread-safe. Used for effects such as animating particle systems.

Parameters
idItem ID.
argsSee Render::Args class documentation.

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