My Project
|
block grid on client side. More...
#include <BlockLightGridClient.h>
Public Types | |
typedef FixedSizedAllocator< std::pair< const uint64_t, Light > > | DL_Allocator_BlockLight |
![]() | |
enum | CellType { cp_empty, cp_light, cp_obstructure } |
![]() | |
typedef ParaEngine::weak_ptr< IObject, IAttributeFields > | WeakPtr_type |
![]() | |
typedef ParaEngine::weak_ptr< IObject > | WeakPtr_type |
Public Member Functions | |
CBlockLightGridClient (int32_t chunkCacheDim, CBlockWorld *pBlockWorld) | |
virtual void | OnEnterWorld () |
virtual void | OnLeaveWorld () |
virtual void | OnWorldMove (uint16_t centerChunkX, uint16_t centerChunkZ) |
virtual void | UpdateLighting () |
virtual bool | GetBrightness (Uint16x3 &blockId, uint8_t *brightness, int nSize=27, int nLightType=-1) |
virtual void | SetLightDirty (Uint16x3 &blockId_ws, bool isSunLight, int8 nUpdateRange=0) |
only call this function from main thread when you have a write lock on block world to ensure thread safety. More... | |
virtual void | NotifyBlockHeightChanged (uint16_t blockIdX_ws, uint16_t blockIdZ_ws, ChunkMaxHeight &prevBlockHeight) |
thread safe: | |
virtual void | AddDirtyColumn (uint16_t chunkX_ws, uint16_t chunkZ_ws) |
thread safe: update all blocks in the given chunk column. More... | |
virtual int | GetDirtyColumnCount () |
thread safe: get the number of remaining dirty column | |
virtual int | GetDirtyBlockCount () |
get the number of remaining dirty blocks | |
virtual void | SetColumnPreloaded (uint16_t chunkX_ws, uint16_t chunkZ_ws) |
thread safe: set the given column loaded. More... | |
virtual void | SetColumnUnloaded (uint16_t chunkX_ws, uint16_t chunkZ_ws) |
this is called when chunk column is loaded possibly due to region unload. More... | |
virtual void | SetLightGridSize (int nSize) |
Set the light grid chunk size. | |
virtual int | ForceAddChunkColumn (int nChunkWX, int nChunkWZ) |
function to refresh the a given chunk column. More... | |
virtual int | GetForcedChunkColumnCount () |
get the number of forced column still in the queue. More... | |
bool | IsAsyncLightCalculation () const |
whether to calculate light in a separate thread. More... | |
void | SetAsyncLightCalculation (bool val) |
bool | IsChunkColumnLoadedWorldPos (int nWorldX, int nWorldY, int nWorldZ) |
thread safe: check to see if the block pos's light is already or being calculated. More... | |
bool | IsChunkColumnLoaded (int nChunkX, int nChunkZ) |
thread safe: | |
bool | IsLightDirty (Uint16x3 &blockId_ws) |
![]() | |
CBlockLightGridBase (CBlockWorld *pBlockWorld) | |
ATTRIBUTE_DEFINE_CLASS (CBlockLightGridBase) | |
virtual int | InstallFields (CAttributeClass *pClass, bool bOverride) |
this class should be implemented if one wants to add new attribute. More... | |
ATTRIBUTE_METHOD1 (CBlockLightGridBase, GetDirtyColumnCount_s, int *) | |
ATTRIBUTE_METHOD1 (CBlockLightGridBase, GetDirtyBlockCount_s, int *) | |
ATTRIBUTE_METHOD1 (CBlockLightGridBase, GetLightGridSize_s, int *) | |
ATTRIBUTE_METHOD1 (CBlockLightGridBase, GetLightCalculationStep_s, int *) | |
ATTRIBUTE_METHOD1 (CBlockLightGridBase, SetLightCalculationStep_s, int) | |
virtual int | GetLightGridSize () |
get the light grid chunk size | |
virtual void | SetLightCalculationStep (uint32 nTicks) |
how many lighting to calculate per tick for the lighting thread. More... | |
virtual uint32 | GetLightCalculationStep () const |
void | SuspendLightUpdate () |
void | ResumeLightUpdate () |
bool | IsLightUpdateSuspended () |
![]() | |
virtual int | GetAttributeClassID () |
attribute class ID should be identical, unless one knows how overriding rules work. More... | |
virtual const char * | GetAttributeClassName () |
a static string, describing the attribute class object's name | |
virtual const char * | GetAttributeClassDescription () |
a static string, describing the attribute class object | |
virtual int | GetChildAttributeColumnCount () |
we support multi-dimensional child object. More... | |
virtual int | GetChildAttributeObjectCount (int nColumnIndex=0) |
get the number of child objects (row count) in the given column. More... | |
virtual IAttributeFields * | GetChildAttributeObject (int nRowIndex, int nColumnIndex=0) |
virtual IAttributeFields * | GetChildAttributeObject (const std::string &sName) |
get attribute by child object. More... | |
ATTRIBUTE_METHOD1 (IAttributeFields, GetName_s, const char **) | |
ATTRIBUTE_METHOD1 (IAttributeFields, SetName_s, const char *) | |
ATTRIBUTE_METHOD (IAttributeFields, PrintObject_s) | |
ATTRIBUTE_METHOD (IAttributeFields, AddRef_s) | |
ATTRIBUTE_METHOD1 (IAttributeFields, GetRefCount_s, int *) | |
ATTRIBUTE_METHOD1 (IAttributeFields, SetTime_s, int) | |
ATTRIBUTE_METHOD1 (IAttributeFields, GetTime_s, int *) | |
ATTRIBUTE_METHOD (IAttributeFields, Release_s) | |
virtual const std::string & | GetIdentifier () |
virtual void | SetIdentifier (const std::string &sID) |
virtual bool | IsModified () |
whether some of the fields are modified.It is up to the implementation class to provide this functionality if necessary. More... | |
virtual void | SetModified (bool bModified) |
set whether any field has been modified. More... | |
virtual bool | ValidateFields () |
validate all fields and return true if validation passed. More... | |
virtual string | GetValidationMessage () |
get the recent validation message due to the most recent call to ValidateFields() | |
virtual bool | ResetField (int nFieldID) |
Reset the field to its initial or default value. More... | |
virtual bool | InvokeEditor (int nFieldID, const std::string &sParameters) |
Invoke an (external) editor for a given field. More... | |
virtual bool | AddChildAttributeObject (IAttributeFields *pChild, int nRowIndex=-1, int nColumnIndex=0) |
add child object. More... | |
virtual void * | QueryObjectByName (const std::string &sObjectType) |
convert to object of a given type. More... | |
virtual void * | QueryObject (int nObjectType) |
convert to object of a given type. More... | |
virtual int | GetTime () |
get the current local time in case it is animated in milli seconds frames. More... | |
virtual void | SetTime (int nTime) |
virtual CDynamicAttributeField * | GetDynamicField (const std::string &sName) |
Get a dynamic field with a given name. More... | |
virtual CDynamicAttributeField * | GetDynamicField (int nIndex) |
Get a dynamic field with a given index. More... | |
virtual const char * | GetDynamicFieldNameByIndex (int nIndex) |
get field name by index | |
virtual int | GetDynamicFieldCount () |
how many dynamic field this object currently have. More... | |
virtual int | SetDynamicField (const std::string &sName, const CVariable &value) |
set a dynamic field with a given name. More... | |
virtual int | AddDynamicField (const std::string &sName, ATTRIBUTE_FIELDTYPE dwType) |
add dynamic field and return field index | |
virtual void | RemoveAllDynamicFields () |
remove all dynamic fields | |
virtual int | SaveDynamicFieldsToString (std::string &output) |
save only text dynamic fields to fieldname = value text strings. More... | |
virtual int | LoadDynamicFieldsFromString (const std::string &input) |
load only text dynamic fields from string More... | |
CAttributeClass * | GetAttributeClass () |
get the main attribute class object. More... | |
void | PrintObject () |
print the content of this object to a text file at temp/doc/[ClassName].txt. More... | |
![]() | |
virtual void | Clone (IObject *obj) const |
Clone the object's contains to a pointer. More... | |
virtual IObject * | Clone () const |
Clone the object's contains and return a pointer to the newly created object. More... | |
virtual bool | Equals (const IObject *obj) const |
Compare the object with another object. More... | |
virtual const IType * | GetType () const |
virtual std::string | ToString () const |
WeakPtr_type & | GetWeakReference () |
get weak reference object. More... | |
virtual int | ProcessObjectEvent (const ObjectEvent &event) |
this function is only used to backward compatibility of ParaObject:AddEvent() function. More... | |
![]() | |
void | addref () const |
add reference count of the object. More... | |
bool | delref () const |
decrease reference count of the object. More... | |
int | GetRefCount () const |
get the reference count | |
virtual int | Release () |
CRefCounted * | AddToAutoReleasePool () |
addref and releases the ownership sometime soon automatically (usually at the end of the current frame). More... | |
Public Attributes | |
int | m_max_cells_per_frame |
max number of cells(blocks) to calculate per frame. More... | |
int | m_max_cells_left_per_frame |
max number of cells(blocks) to left un-calculated per frame. More... | |
Additional Inherited Members | |
![]() | |
static HRESULT | GetAttributeClassID_s (IAttributeFields *cls, int *p1) |
static HRESULT | GetAttributeClassName_s (IAttributeFields *cls, const char **p1) |
static bool | OpenWithDefaultEditor (const char *sFilename, bool bWaitOnReturn=false) |
Open a given file with the default registered editor in the game engine. More... | |
![]() | |
BlockIndex | CalcLightDataIndex (const Uint16x3 &blockId, bool bCreateIfNotExist=true) |
LightData * | GetLightData (const BlockIndex &index) |
LightData * | GetLightData (uint16_t x, uint16_t y, uint16_t z, bool bCreateIfNotExist=true) |
BlockChunk * | GetChunk (uint16_t x, uint16_t y, uint16_t z, bool bCreateIfNotExist=true) |
![]() | |
virtual CAttributeClass * | CreateAttributeClass () |
initialize fields | |
virtual CDynamicAttributesSet * | GetDynamicAttributes (bool bCreateIfNotExist=false) |
![]() | |
bool | m_suspendLightUpdate |
CBlockWorld * | m_pBlockWorld |
int32 | m_nLightGridChunkSize |
uint32 | m_nLightCalculationStep |
![]() | |
WeakPtr_type | m_weak_reference |
![]() | |
int | m_refcount |
block grid on client side.
it will only cache around a radius around the current camera eye position to keep memory low.
|
virtual |
thread safe: update all blocks in the given chunk column.
A chunk column is all chunks with same x,z
Reimplemented from ParaEngine::CBlockLightGridBase.
|
virtual |
function to refresh the a given chunk column.
if the chunk column is not calculated, it will force adding it to the queue. normally this function is only used to calculate light in far away places for offline usage. this function is not used during real time rendering.
nChunkWX,nChunkWZ | world chunk position. |
Reimplemented from ParaEngine::CBlockLightGridBase.
|
virtual |
get the number of forced column still in the queue.
Reimplemented from ParaEngine::CBlockLightGridBase.
bool ParaEngine::CBlockLightGridClient::IsAsyncLightCalculation | ( | ) | const |
whether to calculate light in a separate thread.
bool ParaEngine::CBlockLightGridClient::IsChunkColumnLoadedWorldPos | ( | int | nWorldX, |
int | nWorldY, | ||
int | nWorldZ | ||
) |
thread safe: check to see if the block pos's light is already or being calculated.
|
virtual |
thread safe: set the given column loaded.
this function is called, if light data is pre-calculated when loading the world
Reimplemented from ParaEngine::CBlockLightGridBase.
|
virtual |
this is called when chunk column is loaded possibly due to region unload.
Reimplemented from ParaEngine::CBlockLightGridBase.
|
virtual |
only call this function from main thread when you have a write lock on block world to ensure thread safety.
nUpdateMethod | 0 means normal refresh, 1 means force update neighbor within 1 blocks. -1 to disable |
Reimplemented from ParaEngine::CBlockLightGridBase.
int ParaEngine::CBlockLightGridClient::m_max_cells_left_per_frame |
max number of cells(blocks) to left un-calculated per frame.
When a scene is first loaded, there can be large number of blocks to calculate. and it is better finish loading them at start up time, instead of spreading into many frames. So this value is usually some big value.
int ParaEngine::CBlockLightGridClient::m_max_cells_per_frame |
max number of cells(blocks) to calculate per frame.
Smaller value gives better frame rate during frame load time.