class CoreObject

Provides a standardized way to initialize/destroy objects, a unique runtime ID for each object, and a way to specify dependant CoreObjects.

Optionally it may also be used to create render proxy objects for use by the render thread.

Public

Methods

Destroy

virtual void Destroy()

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.

Initialize

virtual void Initialize()

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.

IsInitialized

bool IsInitialized() const

Returns true if the object has been initialized.

Non-initialized object should not be used.

IsDestroyed

bool IsDestroyed() const

Returns true if the object has been destroyed.

Destroyed object should not be used.

BlockUntilRenderProxyInitialized

void BlockUntilRenderProxyInitialized() const

Blocks the current thread until the render proxy is fully initialized on the render thread.

GetInternalId

u64 GetInternalId() const

Returns an unique identifier for this object.

GetShared

SPtr<CoreObject> GetShared() const

Returns a shared_ptr version of "this" pointer.

GetRenderProxy

SPtr<render::RenderProxy> GetRenderProxy() const

Returns an object that contains render thread specific implementation of this CoreObject.

Null is a valid return value in case object requires no render thread implementation.

SyncToRenderProxy

void SyncToRenderProxy()

Ensures all dirty syncable data is send to the render proxy (if any).

Internal

Methods

SetShared

void SetShared(SPtr<CoreObject> ptrThis)

Sets a shared this pointer to this object.

This must be called immediately after construction, but before Initialize().

Protected

Constructors

CoreObject

CoreObject(bool createRenderProxy = true)

Constructs a new core object.

createRenderProxy
Set to true if the object requires a RenderProxy counter-part. Render proxies allow the object to be used from the render thread, using data syncing from the main thread object to keep up to date. If true, you class should override CreateRenderProxy() to create the proxy, and CreateRenderProxySyncPacket() to provide the data for synchronization between the objects. MarkRenderProxyDataDirty() should be used to notify the system data is dirty and render proxy needs updating.

Methods

~CoreObject

virtual ~CoreObject() noexcept

CreateRenderProxy

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

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

Can be null if such object is not required.

MarkRenderProxyDataDirty

void MarkRenderProxyDataDirty(u32 flags = 4294967295U)

Marks the render proxy data as dirty.

This causes the SyncToRenderProxy() method to trigger the next time objects are synced to the render thread.

flags
Flags in case you want to signal that only part of the internal data is dirty. SyncToRenderProxy() will be called regardless and it's up to the implementation to read the flags value if needed.

MarkRenderProxyDataUpToDate

void MarkRenderProxyDataUpToDate()

Marks the render proxy data as up to date.

Normally called right after new data has been synced to the render thread.

MarkDependenciesDirty

void MarkDependenciesDirty()

Notifies the core object manager that this object is dependant on some other CoreObject(s), and the dependencies changed since the last call to this method.

This will trigger a call to GetCoreDependencies() to collect the new dependencies.

IsRenderProxyDataOutOfDate

bool IsRenderProxyDataOutOfDate() const

Returns true if the render proxy has out of date data and required a new data sync to be up to date.

GetRenderProxyDirtyFlags

u32 GetRenderProxyDirtyFlags() const

Returns flags that specify which portion of the render proxy is out of date with this object.

CreateRenderProxySyncPacket

virtual RenderProxySyncPacket *CreateRenderProxySyncPacket(FrameAllocator &allocator, u32 flags)

Creates a data packet that will be used for syncing the core object with it's render proxy.

Caller must free the retrieved packet using the provided allocator when done using it.

GetCoreDependencies

virtual void GetCoreDependencies(Vector<CoreObject *> &dependencies)

Populates the provided array with all core objects that this core object depends upon.

Dependencies are required for syncing to the render thread, so the system can be aware to update the dependant objects if a dependency is marked as dirty (for example updating a camera's viewport should also trigger an update on camera so it has a chance to potentially update its data).

OnDependencyDirty

virtual void OnDependencyDirty(CoreObject *dependency, u32 dirtyFlags)

Gets called on an object when one of the dependencies (as returned from GetCoreDependencies()) is marked as dirty.

It gives the dependant object a chance to determine should it mark itself as dirty due to the dependency change. Dirty flags of the dependency object can be examined for more information on what part of the dependency was modified.

Fields

mRenderProxy

SPtr<render::RenderProxy> mRenderProxy

Private

Fields

mFlags

CoreObjectFlags mFlags

mRenderProxyDirtyFlags

u32 mRenderProxyDirtyFlags

mInternalID

u64 mInternalID

mThis

std::weak_ptr<CoreObject> mThis