Class Scene
Container for all scene objects and scene-wide state. More...
#include <Scene.h>
Inherits the following classes: UID
Public Types
| Type | Name |
|---|---|
| typedef std::vector< Resource< Object > > | ResList Ordered list of objects. |
| typedef std::unordered_map< int, Resource< Object > > | ResPool Object pool indexed by UID . |
| typedef std::shared_ptr< Object > | Resource Shared ownership wrapper for scene objects. |
| enum | SceneModifStatus Scene modification status flags for change tracking. |
Public Attributes
| Type | Name |
|---|---|
| ResPool< Camera > | cam_list Camera objects. |
| ResPool< DebugLine > | dLine_list Debug line primitives. |
| ResPool< DebugPoints > | dPoints_list Debug point primitives. |
| ResPool< Environment > | envir_list Environment objects (skybox, IBL) |
| ResPool< Light > | light_list Light objects (point, sun, spot, area) |
| ResPool< Mesh > | mesh_list Mesh objects. |
| ResPool< ObjectID > | obj_list All scene objects (base type) |
| ResPool< PolygonLight > | poly_light_list Polygonal area lights. |
| ResList< PostProcessing > | pps_list Post-processing effect stack. |
| Resource< SDFField > | sdf_field Signed Distance Field for soft shadows. |
| ResPool< Sprite > | sprite_list 2D sprite overlays |
Public Functions
| Type | Name |
|---|---|
| bool | CheckStatus (SceneModifStatus tar) Checks if a status flag is set. |
| Camera * | GetActiveCamera () Returns the active camera. |
| Environment * | GetActiveEnvironment () Returns the active environment. |
| ObjectID * | GetObjectID (int _id) Retrieves object by UID . |
| PostProcessing * | GetPPS (int _tar) Returns post-processing effect by index. |
| void | ResetStatus () Resets scene status to NoChanges. |
| Scene () Constructs an empty scene. |
|
| void | SetSceneStatus (int tar, bool value) Directly sets scene status (replaces existing). |
| void | UpdateObjTransforms () Updates all object transforms in hierarchy. |
| void | UpdateSceneStatus (int tar, bool value) Updates scene status flag (bitwise OR). |
| void | UseCamera (Resource< Camera > camera) Registers a camera in the scene. |
| void | UseDebugLine (Resource< DebugLine > dline) Registers debug lines in the scene. |
| void | UseDebugPoints (Resource< DebugPoints > dpoints) Registers debug points in the scene. |
| void | UseEnvironment (Resource< Environment > envir) Registers an environment in the scene. |
| void | UseLight (Resource< Light > light) Registers a light in the scene. |
| void | UseMesh (Resource< Mesh > mesh) Registers a mesh in the scene. |
| void | UsePolygonLight (Resource< PolygonLight > polyLight) Registers a polygonal light in the scene. |
| void | UsePostProcessing (Resource< PostProcessing > pps) Registers a post-processing effect. |
| void | UseSDF (Resource< SDFField > sdf) Assigns the scene's SDF field. |
| void | _debugStatus () Prints current status flags to debug output. |
| ~Scene () Destroys the scene and all owned objects. |
Public Functions inherited from UID
See UID
| Type | Name |
|---|---|
| int | GetObjectID () const Returns the unique ID of this object. |
| UID () Constructs a UID and assigns a unique ID. |
|
| virtual | ~UID () = default Virtual destructor for polymorphic use. |
Public Static Functions inherited from UID
See UID
| Type | Name |
|---|---|
| int | GetTotalAllocated () Returns total number of UIDs allocated. |
Detailed Description
Scene aggregates all renderable and non-renderable objects in a scene. It provides typed pools (ResPool) for each object category, enabling efficient iteration and lookup by ID. Active objects (camera, environment) are cached for fast access during rendering.
Scene Modification Tracking: * SceneModifStatus flags track which aspects of the scene changed * Renderer can optimize updates by checking status flags * Flags reset after processing to avoid redundant work
Object Lifetime: * Objects owned via shared_ptr (reference counted) * Removing from map triggers destruction if no other references exist * GPU resources released in object destructors
Note:
Inheritance: UID provides unique scene identifier.
Note:
Thread-safety: Not thread-safe. Access from main thread only.
Public Types Documentation
typedef ResList
Ordered list of objects.
using Scene::ResList = std::vector<Resource<Object> >;
typedef ResPool
Object pool indexed by UID .
using Scene::ResPool = std::unordered_map<int, Resource<Object> >;
typedef Resource
Shared ownership wrapper for scene objects.
using Scene::Resource = std::shared_ptr<Object>;
enum SceneModifStatus
Scene modification status flags for change tracking.
enum Scene::SceneModifStatus {
NoChanges = 0,
ObjectTransChanged = 1 << 0,
LightChanged = 1 << 1,
CameraChanged = 1 << 2,
ShaderChanged = 1 << 3,
MaterialChanged = 1 << 4,
SceneChanged = ObjectTransChanged | LightChanged | CameraChanged | ShaderChanged | MaterialChanged,
SDFChanged = 1 << 8
};
Public Attributes Documentation
variable cam_list
Camera objects.
ResPool<Camera> Scene::cam_list;
variable dLine_list
Debug line primitives.
ResPool<DebugLine> Scene::dLine_list;
variable dPoints_list
Debug point primitives.
ResPool<DebugPoints> Scene::dPoints_list;
variable envir_list
Environment objects (skybox, IBL)
ResPool<Environment> Scene::envir_list;
variable light_list
Light objects (point, sun, spot, area)
ResPool<Light> Scene::light_list;
variable mesh_list
Mesh objects.
ResPool<Mesh> Scene::mesh_list;
variable obj_list
All scene objects (base type)
ResPool<ObjectID> Scene::obj_list;
variable poly_light_list
Polygonal area lights.
ResPool<PolygonLight> Scene::poly_light_list;
variable pps_list
Post-processing effect stack.
ResList<PostProcessing> Scene::pps_list;
variable sdf_field
Signed Distance Field for soft shadows.
Resource<SDFField> Scene::sdf_field;
variable sprite_list
2D sprite overlays
ResPool<Sprite> Scene::sprite_list;
Public Functions Documentation
function CheckStatus
Checks if a status flag is set.
bool Scene::CheckStatus (
SceneModifStatus tar
)
Parameters:
tarStatus flag(s) to check
Returns:
True if any of the specified flags are set
function GetActiveCamera
Returns the active camera.
Camera * Scene::GetActiveCamera ()
Returns:
Pointer to active Camera, or nullptr if none
Note:
First camera in cam_list is considered active (TODO: explicit active flag).
function GetActiveEnvironment
Returns the active environment.
Environment * Scene::GetActiveEnvironment ()
Returns:
Pointer to active Environment, or nullptr if none
Note:
First environment in envir_list is considered active.
function GetObjectID
Retrieves object by UID .
ObjectID * Scene::GetObjectID (
int _id
)
Parameters:
_idUnique object identifier
Returns:
Pointer to ObjectID, or nullptr if not found
function GetPPS
Returns post-processing effect by index.
PostProcessing * Scene::GetPPS (
int _tar
)
Parameters:
_tarEffect index in pps_list
Returns:
Pointer to PostProcessing effect, or nullptr if out of range
function ResetStatus
Resets scene status to NoChanges.
void Scene::ResetStatus ()
Note:
Called after Renderer processes all scene updates.
function Scene
Constructs an empty scene.
Scene::Scene ()
function SetSceneStatus
Directly sets scene status (replaces existing).
void Scene::SetSceneStatus (
int tar,
bool value
)
Parameters:
tarNew status valuevalueUnused (legacy parameter)
function UpdateObjTransforms
Updates all object transforms in hierarchy.
void Scene::UpdateObjTransforms ()
Note:
Propagates parent transforms to children recursively.
function UpdateSceneStatus
Updates scene status flag (bitwise OR).
void Scene::UpdateSceneStatus (
int tar,
bool value
)
Parameters:
tarTarget status flag(s) to setvalueIf true, set flag; if false, clear flag
Note:
Multiple flags can be combined via bitwise OR.
function UseCamera
Registers a camera in the scene.
void Scene::UseCamera (
Resource < Camera > camera
)
Parameters:
cameraShared pointer to Camera object
Note:
Adds to cam_list and obj_list.
function UseDebugLine
Registers debug lines in the scene.
void Scene::UseDebugLine (
Resource < DebugLine > dline
)
Parameters:
dlineShared pointer to DebugLine object
Note:
Adds to dLine_list.
function UseDebugPoints
Registers debug points in the scene.
void Scene::UseDebugPoints (
Resource < DebugPoints > dpoints
)
Parameters:
dpointsShared pointer to DebugPoints object
Note:
Adds to dPoints_list.
function UseEnvironment
Registers an environment in the scene.
void Scene::UseEnvironment (
Resource < Environment > envir
)
Parameters:
envirShared pointer to Environment object
Note:
Adds to envir_list and obj_list. Replaces active environment.
function UseLight
Registers a light in the scene.
void Scene::UseLight (
Resource < Light > light
)
Parameters:
lightShared pointer to Light object
Note:
Adds to light_list and obj_list.
function UseMesh
Registers a mesh in the scene.
void Scene::UseMesh (
Resource < Mesh > mesh
)
Parameters:
meshShared pointer to Mesh object
Note:
Adds to mesh_list and obj_list.
function UsePolygonLight
Registers a polygonal light in the scene.
void Scene::UsePolygonLight (
Resource < PolygonLight > polyLight
)
Parameters:
polyLightShared pointer to PolygonLight object
Note:
Adds to poly_light_list and obj_list.
function UsePostProcessing
Registers a post-processing effect.
void Scene::UsePostProcessing (
Resource < PostProcessing > pps
)
Parameters:
ppsShared pointer to PostProcessing object
Note:
Appends to pps_list (order determines application sequence).
function UseSDF
Assigns the scene's SDF field.
void Scene::UseSDF (
Resource < SDFField > sdf
)
Parameters:
sdfShared pointer to SDFField object
Note:
Replaces existing SDF field.
function _debugStatus
Prints current status flags to debug output.
void Scene::_debugStatus ()
Note:
Development tool for debugging scene update logic.
function ~Scene
Destroys the scene and all owned objects.
Scene::~Scene ()
Note:
GPU resources released via object destructors.
The documentation for this class was generated from the following file src/scene/Scene.h