Nameless Engine
Loading...
Searching...
No Matches
ne::ShaderLightArraySlot Class Reference

#include <ShaderLightArray.h>

Public Member Functions

 ShaderLightArraySlot (const ShaderLightArraySlot &)=delete
 
ShaderLightArraySlotoperator= (const ShaderLightArraySlot &)=delete
 
void markAsNeedsUpdate ()
 
size_t getCurrentIndexIntoArray () const
 

Private Member Functions

 ShaderLightArraySlot (ShaderLightArray *pArray, Node *pSpawnedOwnerLightNode, size_t iIndexIntoArray, const std::function< void *()> &startUpdateCallback, const std::function< void()> &finishUpdateCallback)
 

Private Attributes

ShaderLightArraypArray = nullptr
 
Node *const pSpawnedOwnerLightNode = nullptr
 
const std::function< void *()> startUpdateCallback
 
const std::function< void()> finishUpdateCallback
 
size_t iIndexIntoArray = 0
 

Friends

class ShaderLightArray
 

Detailed Description

RAII-like object that frees the slot (marks it as unused) in its destructor and stores all information needed to update the slot's data.

Constructor & Destructor Documentation

◆ ShaderLightArraySlot()

ne::ShaderLightArraySlot::ShaderLightArraySlot ( ShaderLightArray pArray,
Node pSpawnedOwnerLightNode,
size_t  iIndexIntoArray,
const std::function< void *()> &  startUpdateCallback,
const std::function< void()> &  finishUpdateCallback 
)
private

Creates a new slot.

Parameters
pArrayArray that allocated space for this slot.
pSpawnedOwnerLightNodeSpawned light node that requested the slot.
iIndexIntoArrayIndex into array.
startUpdateCallbackCallback that will be called by array to start copying new data to the GPU.
finishUpdateCallbackCallback that will be called by array to finish copying new data to the GPU.

Member Function Documentation

◆ getCurrentIndexIntoArray()

size_t ne::ShaderLightArraySlot::getCurrentIndexIntoArray ( ) const
inline

Returns the current index (because it may change later) into the array.

Returns
Index.

◆ markAsNeedsUpdate()

void ne::ShaderLightArraySlot::markAsNeedsUpdate ( )

Marks resources as "needs update", the resource will not be updated immediately but only when it will be safe to modify the underlying GPU resource of the array that this slot is referencing.

Remarks
Causes update callbacks to be called multiple times later.

Member Data Documentation

◆ finishUpdateCallback

const std::function<void()> ne::ShaderLightArraySlot::finishUpdateCallback
private

Callback that will be called by array to finish copying new data to the GPU.

◆ iIndexIntoArray

size_t ne::ShaderLightArraySlot::iIndexIntoArray = 0
private

Index into pArray.

◆ pArray

ShaderLightArray* ne::ShaderLightArraySlot::pArray = nullptr
private

Array that allocated space for this slot.

◆ pSpawnedOwnerLightNode

Node* const ne::ShaderLightArraySlot::pSpawnedOwnerLightNode = nullptr
private

Spawned light node (point/spot/directional/etc) that requested this slot.

Remarks
Do not delete (free) this pointer. It's safe to store a raw pointer here because when a light node despawns it destroys this slot object so this pointer is always valid.

◆ startUpdateCallback

const std::function<void*()> ne::ShaderLightArraySlot::startUpdateCallback
private

Callback that will be called by array to start copying new data to the GPU.


The documentation for this class was generated from the following files: