Workspace 6.21.5
Public Member Functions | Static Public Attributes | Protected Member Functions | List of all members
SceneProcessor Class Reference

Abstract base class for all objects that can process a Scene. More...

#include <Rendering/SceneComponents/sceneprocessor.h>

Inheritance diagram for SceneProcessor:
[legend]

Public Member Functions

 ~SceneProcessor () override
 
bool process (Scene &scene)
 
bool process (Transform &transform)
 
bool visit (Annotation &annotation)
 
bool visit (Camera &camera)
 
bool visit (ClipRegion &clipRegion)
 
bool visit (Light &light)
 
bool visit (MeshModelInstance &model)
 
bool visit (SceneItemInstance &sceneItemInstance)
 
bool visit (Transform &transform)
 
- Public Member Functions inherited from Observable
virtual ~Observable ()
 
void attachObserver (Observer &observer)
 
void destroy ()
 
void detachObserver (Observer &observer)
 
void notifyEvent (const ObservableEvent &event)
 

Static Public Attributes

static const Application::LogManager::MessageCategory LOG_SCENEPROCESSOR
 

Protected Member Functions

 SceneProcessor ()
 
 SceneProcessor (const SceneProcessor &p)
 
SceneProcessoroperator= (const SceneProcessor &p)
 
virtual bool postVisits (Scene &scene)
 
virtual bool preVisits (Scene &scene)
 
virtual bool traverseScene (Scene &scene)
 
virtual bool visitImpl (Annotation &annotation)
 
virtual bool visitImpl (Camera &camera)
 
virtual bool visitImpl (ClipRegion &clipRegion)
 
virtual bool visitImpl (Light &light)
 
virtual bool visitImpl (MeshModelInstance &modelInstance)
 
virtual bool visitImpl (SceneItemInstance &sceneItemInstance)
 
virtual bool visitImpl (Transform &transform)
 
- Protected Member Functions inherited from Observable
 Observable ()
 
 Observable (const Observable &)
 

Detailed Description

A SceneProcessor object can do more or less anything with the Scene. This base class exists to allow novel use of things like the visitor design pattern with arbitrary operations on scene objects. A common subclass implementation would be to render the scene somehow, but other operations such as applying some kind of movement to the scene or updating certain properties of objects in the scene would be just as valid.

See process() for more details about how the scene processor is intended to be implemented and used.

Constructor & Destructor Documentation

◆ SceneProcessor() [1/2]

SceneProcessor ( )
protected

◆ SceneProcessor() [2/2]

SceneProcessor ( const SceneProcessor p)
protected

◆ ~SceneProcessor()

~SceneProcessor ( )
override

Member Function Documentation

◆ operator=()

SceneProcessor & operator= ( const SceneProcessor p)
protected
Parameters
pThe scene processor to copy from.

This assignment operator must not be called while executing a call to process(). It is allowable though for p to be currently executing such a call.

◆ postVisits()

bool postVisits ( Scene scene)
protectedvirtual
Parameters
sceneThe scene being visited.

This function should only ever be called by process(). Client code should not call it directly. The default implementation performs a check on this condition and returns true if the function is being called within a call to process(), or false otherwise. The default implementation performs no other action.

Subclasses may wish to provide their own implementation for postVisits() in order to clean up internal data structures or finalize some aspect of the processing. They are not required to call this base class implementation if they do so.

Reimplemented in WSGLRenderQueueBuilder, and SceneTransformProcessor.

◆ preVisits()

bool preVisits ( Scene scene)
protectedvirtual
Parameters
sceneThe scene being visited.

This function should only ever be called by process(). Client code should not call it directly. The default implementation performs a check on this condition and returns true if the function is being called within a call to process(), or false otherwise. The default implementation performs no other action.

Subclasses may wish to provide their own implementation for preVisits() in order to set up their own internal data structures. They are not required to call this base class implementation if they do so.

Reimplemented in WSGLRenderQueueBuilder, SceneBoundingBoxCalculator, and SceneTransformProcessor.

◆ process() [1/2]

bool process ( Scene scene)
Parameters
sceneThe scene to be processed.

Clients should call this function when they want to invoke the scene processor on scene. It will first call preVisits() to give the processor a chance to set internal data structures in preparation for a pass over the scene. If this returns false, process() fails and also returns false immediately.

If preVisits() succeeds, the function then calls visit() on the root transform of the scene. Again, if this returns false, then process() fails and returns false immediately.

If the call to visit() also succeeds, then the function calls postVisits() and returns its result. The purpose of postVisits() is to give the scene processor a chance to clean up after its pass over the scene. Another common use is to use the pass over the scene as a means of gathering information about the scene and then in the call to postVisits(), the processor carries out the main task because it has all the information about the scene at that point.

Note
Subclasses should not retain a reference to scene after this function returns.

◆ process() [2/2]

bool process ( Transform transform)

◆ traverseScene()

bool traverseScene ( Scene scene)
protectedvirtual
Parameters
sceneThe scene to traverse

Traverse the scene in some way. The default implementation will simply visit the root-group.

Reimplemented in SceneTransformProcessor.

◆ visit() [1/7]

bool visit ( Annotation annotation)
Parameters
annotationThe annotation to visit.

This function will only ever be called by the annotation being visited. If the annotation is not enabled, or the scene processor is not currently 'processing' items, the call will fail.

◆ visit() [2/7]

bool visit ( Camera camera)
Parameters
cameraThe camera scene item to visit.

This function should only ever be called by the camera object being passed as the parameter, and only as part of a call to process(). Any attempt to call the function outside of process() will fail.

After checking whether this call is part of a call to process(), the function then checks if camera is currently enabled. If it is, then it calls the virtual visitImpl(Camera&) function. Subclasses must provide their own implementation for visitImpl(Camera &) if they can process camera scene items.

Enabling a camera is not the same as using it. Many scene processors will not provide their own implementation of visitImpl(Camera&), so the enable/disable state for a camera often has little effect. For those scene processors that do process cameras, it is up to them what enabling or disabling a camera means. Quite often, for a renderer this will correspond to whether or not some visual representation of the camera should be included in the render, but you should consult the documentation of the scene processor you are interested in before relying on this.

◆ visit() [3/7]

bool visit ( ClipRegion clipRegion)
Parameters
clipRegionThe clipRegion scene item to visit.

This function should only ever by called by the clipRegion object being passed as the parameter, and only as part of the call to process(). Any attempt to call the function outside of process() will fail.

After checking whether this call is part of a call to process(), the function then checks if clipRegion is currently visible or enabled. If it is, then it calls the virtual visitImpl(ClipRegion&) function. Subclasses must provide their own implementation for visitImpl(ClipRegion&) if they can process clipRegion scene items.

◆ visit() [4/7]

bool visit ( Light light)
Parameters
lightThe light scene item to visit.

This function should only ever be called by the light object being passed as the parameter, and only as part of a call to process(). Any attempt to call the function outside of process() will fail.

After checking whether this call is part of a call to process(), the function then checks if light is currently enabled. If it is, then it calls the virtual visitImpl(Light&) function. Subclasses must provide their own implementation for visitImpl(Light&) if they can process light scene items.

◆ visit() [5/7]

bool visit ( MeshModelInstance model)
Parameters
modelThe model scene item to visit.

This function should only ever be called by the model object being passed as the parameter, and only as part of a call to process(). Any attempt to call the function outside of process() will fail.

After checking whether this call is part of a call to process(), the function then checks if model is currently enabled. If it is, then it calls the virtual visitImpl(MeshModelInstance&) function. Subclasses must provide their own implementation for visitImpl(MeshModelInstance&) if they can process model scene items. Since models are usually the main objects in a scene, it would be unusual for a scene processor to not provide their own implementation for visitImpl(MeshModelInstance&).

◆ visit() [6/7]

bool visit ( SceneItemInstance sceneItemInstance)
Parameters
sceneItemInstanceThe sceneItemInstance scene item to visit.

This function should only ever by called by the sceneItemInstance object being passed as the parameter, and only as part of the call to process(). Any attempt to call the function outside of process() will fail.

After checking whether this call is part of a call to process(), the function then checks if sceneItemInstance is currently enabled. If it is, then it calls the virtual visitImpl(SceneItemInstance&) function. Subclasses must provide their own implementation for visitImpl(SceneItemInstance&) if they can process sceneItemInstance scene items.

◆ visit() [7/7]

bool visit ( Transform transform)
Parameters
transformThe transform to visit.

This function should only ever be called by the transform object being passed as the parameter, and only as part of a call to process(). Any attempt to call the function outside of process() will fail.

After checking whether this call is part of a call to process(), the function then checks if transform is currently enabled. If it is, then it calls the virtual visitImpl(Transform&) function. Subclasses can provide their own implementation for visitImpl(Transform&) to handle transforms in some custom way, but the default implementation will often be sufficient. Note that if transform is not enabled, visitImpl(Transform&) is not called and this normally means that all children of transform are also not visited.

◆ visitImpl() [1/7]

bool visitImpl ( Annotation annotation)
protectedvirtual
Parameters
annotationThe annotation to visit.
Note
This function will only be called if sceneItemInstance is enabled (this is controlled by the visit(Annotation&) function which is the only place visitImpl should be called from).

The default implementation does nothing.

Reimplemented in WSGLRenderQueueBuilder.

◆ visitImpl() [2/7]

bool visitImpl ( Camera camera)
protectedvirtual
Parameters
cameraThe camera to visit.
Note
This function will only be called if camera is enabled (this is controlled by the visit(Camera &) function which is the only place visitImpl(Camera&) should be called from).

The default implementation does nothing.

Reimplemented in WSGLRenderQueueBuilder, and SceneTransformProcessor.

◆ visitImpl() [3/7]

bool visitImpl ( ClipRegion clipRegion)
protectedvirtual
Parameters
clipRegionThe clip region to visit.
Note
This function will only be called if clipRegion is enabled (this is controlled by the visit(ClipRegion&) function which is the only place visitImpl(ClipRegion&) should be called from).

The default implementation does nothing.

Reimplemented in WSGLRenderQueueBuilder, and SceneTransformProcessor.

◆ visitImpl() [4/7]

bool visitImpl ( Light light)
protectedvirtual
Parameters
lightThe light to visit.
Note
This function will only be called if light is enabled (this is controlled by the visit(Light&) function which is the only place visitImpl(Light&) should be called from).

The default implementation does nothing.

Reimplemented in WSGLRenderQueueBuilder.

◆ visitImpl() [5/7]

bool visitImpl ( MeshModelInstance modelInstance)
protectedvirtual
Parameters
modelInstanceThe model to visit.
Note
This function will only be called if modelInstance is enabled (this is controlled by the visit(MeshModelInstance&) function which is the only place visitImpl(MeshModelInstance&) should be called from).

The default implementation does nothing. Most subclasses will override this function.

Reimplemented in WSGLRenderQueueBuilder, and SceneBoundingBoxCalculator.

◆ visitImpl() [6/7]

bool visitImpl ( SceneItemInstance sceneItemInstance)
protectedvirtual
Parameters
sceneItemInstanceThe sceneItemInstance to visit.
Note
This function will only be called if sceneItemInstance is enabled (this is controlled by the visit(SceneItemInstance&) function which is the only place visitImpl(SceneItemInstance&) should be called from).

The default implementation does nothing.

Reimplemented in WSGLRenderQueueBuilder, and SceneTransformProcessor.

◆ visitImpl() [7/7]

bool visitImpl ( Transform transform)
protectedvirtual
Parameters
transformThe transform to visit.
Note
This function will only be called if transform is enabled (this is controlled by the visit(Transform&) function which is the only place visitImpl(Transform&) should be called from).

The default implementation visits each of the transform's immediate children. If subclasses need to record under what transform they are currently processing, they will most likely need to override this function. If doing so, subclasses should endeavour to implement their overridden function in terms of the default implementation specified here, since this gives consistent behavior and also provides the benefit of a few consistency checks.

Reimplemented in WSGLRenderQueueBuilder, and SceneTransformProcessor.

Member Data Documentation

◆ LOG_SCENEPROCESSOR

const Application::LogManager::MessageCategory LOG_SCENEPROCESSOR
static