Base class for all objects that can process the lights in a Scene.
More...
#include <Rendering/SceneComponents/Lights/lightsprocessor.h>
There is a degree of similarity between LightsProcessor and SceneProcessor. The main difference is that a LightsProcessor is only intended to act on a scene's lights. As such, there are different visit() function overloads for Light subclasses instead of for SceneItem subclasses. The implementation of the process() function calls preVisits() before processing the lights and postVisits() after processing the lights, but in between these two calls only the Light's present in the Scene are visited. For the SceneProcessor class, all scene items are visited via the transform hierarchy.
The most common usage of a lights processor is as an internal implementation detail of a SceneProcessor.
See process() for more details about how the lights processor is intended to be implemented and used.
◆ LightsProcessor() [1/2]
Subclasses should only perform initialization in their constructor which does not depend on the scene being processed. Such processing can only be performed in preVisits().
◆ LightsProcessor() [2/2]
◆ ~LightsProcessor()
◆ logText()
void logText |
( |
const QString & |
msg | ) |
|
|
protected |
- Parameters
-
msg | The text to send to the log. |
◆ operator=()
◆ postVisits() [1/2]
bool postVisits |
( |
const QList< Light * > & |
lights | ) |
|
|
protectedvirtual |
- Parameters
-
lights | The list of lights which are being processed. |
Alternative postVisits function for processing a list of lights, rather than the entire scene.
- Returns
- True if successful, false if an error was encountered.
- See also
- postVists(Scene&)
Reimplemented in WSGLLightsProcessor.
◆ postVisits() [2/2]
bool postVisits |
( |
Scene & |
scene | ) |
|
|
protectedvirtual |
- Parameters
-
scene | The scene whose lights are being processed. |
Sub-classes might re-implement this function to perform various clean up tasks or anything which should take place after all lights have been visited.
- Returns
- True if successful, or false if an error was encountered and the processing of the scene's lights should be aborted. The default implementation performs no action and simply returns true if the processor is currently processing the scene (which should always be the case if this function is called).
- See also
- process(), preVisits()
◆ preVisits() [1/2]
bool preVisits |
( |
const QList< Light * > & |
lights | ) |
|
|
protectedvirtual |
- Parameters
-
lights | The list of lights which are being processed. |
Alternative preVisits function for processing a list of lights, rather than the entire scene.
- Returns
- True if successful, false if an error was encountered.
- See also
- preVists(Scene&)
Reimplemented in WSGLLightsProcessor.
◆ preVisits() [2/2]
bool preVisits |
( |
Scene & |
scene | ) |
|
|
protectedvirtual |
- Parameters
-
scene | The scene whose lights are being processed. |
A common usage of this function might be to count the number of enabled lights in the scene and check this against some limit imposed on the renderer. For example, OpenGL mandates that a minimum of 6 lights must be supported, and implementations often only support this minimum number (or close to it). The processor may choose to only emit a warning that lights will be skipped or it may choose to generate a hard error by returning false
.
- Returns
- True if successful, or false if an error was encountered and the processing of the scene's lights should be aborted. The default implementation performs no action and simply returns true if the processor is currently processing the scene (which should always be the case if this function is called).
- See also
- process(), postVisits()
◆ process() [1/2]
bool process |
( |
const QList< Light * > & |
lights | ) |
|
- Parameters
-
lights | The list of lights to process. |
An alternative process function that allows callers to provide a list of lights that they want to process, rather than processing every light in the scene.
- Returns
- true if successful, false otherwise.
◆ process() [2/2]
bool process |
( |
Scene & |
scene | ) |
|
- Parameters
-
scene | The scene whose lights are to be processed. |
This function will first call preVisits() to allow the processor to perform any setup or preparation needed. If that returns true, then each of the lights in scene will be visited in the order in which they were added to the scene (so essentially in an arbitrary order) by calling the light's visit() function and passing the processor itself as a parameter. The light's visit() function is expected to then call the processor's appropriate visit() overloaded function. This visitor pattern allows co-operation between a processor and the lights in a way that is extensible and requires no casting of types.
Once all items have been visited, the process() function calls postVisits() before returning.
- Returns
- True if all stages encountered no error, or false if any of preVisits(), postVisits() or any of the lights' visit() functions return false. As soon as any of these return a false result, the rest of the process() function is skipped and process() returns immediately.
◆ visit() [1/4]
- Parameters
-
light | The light being visited. |
This function should only ever be called by Light subclasses in their visit() function, which in turn should only ever be called by process().
◆ visit() [2/4]
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
◆ visit() [3/4]
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
◆ visit() [4/4]
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
◆ visitImpl() [1/4]
See visit() for details.
- Returns
- True if the light was successfully processed, or false if the function failed and processing should be aborted. The default implementation performs no action and simply returns true.
Reimplemented in WSGLLightsProcessor.
◆ visitImpl() [2/4]
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Reimplemented in WSGLLightsProcessor.
◆ visitImpl() [3/4]
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Reimplemented in WSGLLightsProcessor.
◆ visitImpl() [4/4]
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Reimplemented in WSGLLightsProcessor.