class SceneInstance

Contains information about an instantiated scene.

Public

Constructors

SceneInstance

SceneInstance(ConstructPrivately dummy, const String &name, const HSceneObject &root, const UUID &associatedResourceId)

Methods

~SceneInstance

~SceneInstance() noexcept

Initialize

void Initialize() override

Initializes all the internal data of this object.

Must be called right after construction for new objects, or after deserialization for deserialized objects. If requested, render proxy is created and queued for initialization on the render thread.

Destroy

void Destroy() override

Frees all the data held by this object.

If the object has a render proxy, the internal reference to the render proxy will be released, but the proxy will not be destroyed unless this was the last reference. If render proxy destruction does happen, it is not immediate, but rather queued for destruction on the render thread.

GetName

const String &GetName() const

Name of the scene.

GetRoot

const HSceneObject &GetRoot() const

Root object of the scene.

IsActive

bool IsActive() const

Checks is the scene currently active.

IF inactive the scene properties aside from the name are undefined.

GetPhysicsScene

const SPtr<PhysicsScene> &GetPhysicsScene() const

Representation of the scene used by the physics sub-system.

Contains all the objects that can be physically interacted with. Exact implementation depends on the physics plugin used.

GetRendererScene

const SPtr<RendererScene> &GetRendererScene() const

Representation of the scene used by the renderer.

Contains all the objects that need to be rendered. Exact implementation depends on the renderer plugin used.

GetAnimationScene

const SPtr<AnimationScene> &GetAnimationScene() const

Returns the object responsible for updating animations in this scene.

GetParticleScene

const SPtr<ParticleScene> &GetParticleScene() const

Returns the object responsible for updating particles in this scene.

GetTime

const SceneTime &GetTime() const

Returns an object that manages time associated with this scene.

GetTime

SceneTime &GetTime()

Easier way to access the Time module.

GetAssociatedResourceId

const UUID &GetAssociatedResourceId() const

Returns the ID of the resource that the scene instance is associated with (e.g. resource the scene was loaded from.).

GetAllCameras

const UnorderedMap<UUID, HCamera> &GetAllCameras() const

Returns all cameras in the scene.

GetMainCamera

HCamera GetMainCamera() const

Returns the camera in the scene marked as main.

Main camera controls the final render surface that is displayed to the user. If there are multiple main cameras, the first one found returned.

GetEditorSceneInstance

SPtr<IEditorSceneInstance> GetEditorSceneInstance() const

Editor scene instance, if running from within the editor.

Clear

void Clear(bool forceAll = false)

Removes all scene objects from the scene, except for persistent objects.

If is true, removes even the persistent objects.

CreateSceneObject

HSceneObject CreateSceneObject(const String &name, u32 flags = 0)

Creates a new scene object in the scene instance.

name
Name of the scene object.
flags
Optional flags that control object behavior. See SceneObjectFlags.

staticCreate

static SPtr<SceneInstance> Create(const String &name)

Creates a new empty scene instance.

staticCreate

static SPtr<SceneInstance> Create(const String &name, const HSceneObject &root)

Creates a new scene instance with an existing hierarchy.

staticCreate

static SPtr<SceneInstance> Create(const String &name, const HSceneObject &root, const UUID &associatedResourceId)

Creates a new scene instance with an existing hierarchy and associated resource ID.

Internal

Methods

GetECSRegistry

ecs::Registry &GetECSRegistry()

Returns the ECS registry for this scene.

GetECSRegistry

const ecs::Registry &GetECSRegistry() const

GetGameObjectCollection

const SPtr<GameObjectCollection> &GetGameObjectCollection() const

Returns the game object collection storing all the scene's game objects.

SetAssociatedResourceId

void SetAssociatedResourceId(const UUID &id)

Sets the ID of the resource that the scene instance is associated with (e.g. resource the scene was loaded from.).

SetRoot

void SetRoot(const HSceneObject &newRoot)

Changes the root scene object.

Any persistent objects will remain in the scene, now parented to the new root. All non-persistent objects in the old root are destroyed.

FixedUpdate

void FixedUpdate()

Called every frame before Update().

Calls FixedUpdate() methods on all active components and advances physics.

Update

void Update()

Called every frame.

Calls Update() methods on all active components.

RegisterCamera

void RegisterCamera(const HCamera &camera)

Notifies the scene instance that a new camera was created.

UnregisterCamera

void UnregisterCamera(const HCamera &camera)

Notifies the scene instance that a camera was removed.

NotifyMainCameraStateChanged

void NotifyMainCameraStateChanged(const HCamera &camera)

Notifies the scene instance that a camera either became the main camera, or has stopped being main camera.

SetMainCameraRenderTarget

void SetMainCameraRenderTarget(const SPtr<RenderTarget> &renderTarget)

Sets the render target that the main camera in the scene (if any) will render its view to.

This generally means the main game window when running standalone, or the Game viewport when running in editor.

SetEditorSceneInstance

void SetEditorSceneInstance(const SPtr<IEditorSceneInstance> &scene)

Private

Methods

CreateRenderProxy

SPtr<render::RenderProxy> CreateRenderProxy() const override

Creates an object that contains render thread specific data and methods for this object.

Can be null if such object is not required.

OnMainRenderTargetResized

void OnMainRenderTargetResized()

Callback that is triggered when the main render target size is changed.

Fields

mName

String mName

mRoot

HSceneObject mRoot

mAssociatedResourceId

UUID mAssociatedResourceId

ID of the resource the scene was loaded from, if any.

mIsActive

bool mIsActive

mPhysicsScene

SPtr<PhysicsScene> mPhysicsScene

mRendererScene

SPtr<RendererScene> mRendererScene

mAnimationScene

SPtr<AnimationScene> mAnimationScene

mParticleScene

SPtr<ParticleScene> mParticleScene

mGameObjectCollection

SPtr<GameObjectCollection> mGameObjectCollection

mTime

SceneTime mTime

mCameras

UnorderedMap<UUID, HCamera> mCameras

mMainCameras

Vector<HCamera> mMainCameras

mPrimaryRenderTarget

SPtr<RenderTarget> mPrimaryRenderTarget

mMainRenderTargetResizedHandle

HEvent mMainRenderTargetResizedHandle

mEditorSceneInstance

WeakSPtr<IEditorSceneInstance> mEditorSceneInstance