My Project
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Static Protected Attributes | Friends | List of all members
ParaEngine::CBlockWorld Class Reference

base class for an instance of block world More...

#include <BlockWorld.h>

Inheritance diagram for ParaEngine::CBlockWorld:
ParaEngine::IAttributeFields ParaEngine::IObjectScriptingInterface ParaEngine::IObject ParaEngine::CRefCounted ParaEngine::BlockWorldClient

Classes

struct  BlockTemplateVisibleData
 

Public Types

enum  CallBackType {
  Type_LoadBlockRegion = 0, Type_UnLoadBlockRegion, Type_GeneratorScript, Type_SaveRegionCallbackScript,
  Type_BeforeLoadBlockRegion
}
 script call back type
 
- Public Types inherited from ParaEngine::IAttributeFields
typedef ParaEngine::weak_ptr< IObject, IAttributeFieldsWeakPtr_type
 
- Public Types inherited from ParaEngine::IObject
typedef ParaEngine::weak_ptr< IObjectWeakPtr_type
 

Public Member Functions

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 InstallFields (CAttributeClass *pClass, bool bOverride)
 this class should be implemented if one wants to add new attribute. More...
 
virtual IAttributeFieldsGetChildAttributeObject (const std::string &sName)
 get attribute by child object. More...
 
virtual int GetChildAttributeObjectCount (int nColumnIndex=0)
 get the number of child objects (row count) in the given column. More...
 
virtual int GetChildAttributeColumnCount ()
 we support multi-dimensional child object. More...
 
virtual IAttributeFieldsGetChildAttributeObject (int nRowIndex, int nColumnIndex=0)
 
 ATTRIBUTE_METHOD1 (CBlockWorld, GetBlockRenderMethod_s, int *)
 
 ATTRIBUTE_METHOD1 (CBlockWorld, SetBlockRenderMethod_s, int)
 
 ATTRIBUTE_METHOD (CBlockWorld, ResumeLightUpdate_s)
 
 ATTRIBUTE_METHOD (CBlockWorld, SuspendLightUpdate_s)
 
 ATTRIBUTE_METHOD (CBlockWorld, ResetAllLight_s)
 
 ATTRIBUTE_METHOD (CBlockWorld, LockWorld_s)
 
 ATTRIBUTE_METHOD (CBlockWorld, UnlockWorld_s)
 
 ATTRIBUTE_METHOD1 (CBlockWorld, IsLightUpdateSuspended_s, bool *)
 
 ATTRIBUTE_METHOD3 (CBlockWorld, SetChunkColumnTimeStamp_s, float)
 
 ATTRIBUTE_METHOD1 (CBlockWorld, GetRenderDist_s, int *)
 
 ATTRIBUTE_METHOD1 (CBlockWorld, SetRenderDist_s, int)
 
 ATTRIBUTE_METHOD1 (CBlockWorld, GetDirtyColumnCount_s, int *)
 
 ATTRIBUTE_METHOD1 (CBlockWorld, GetDirtyBlockCount_s, int *)
 
 ATTRIBUTE_METHOD1 (CBlockWorld, IsReadOnly_s, bool *)
 
 ATTRIBUTE_METHOD1 (CBlockWorld, SetReadOnly_s, bool)
 
 ATTRIBUTE_METHOD1 (CBlockWorld, IsRemote_s, bool *)
 
 ATTRIBUTE_METHOD1 (CBlockWorld, SetIsRemote_s, bool)
 
 ATTRIBUTE_METHOD1 (CBlockWorld, IsServerWorld_s, bool *)
 
 ATTRIBUTE_METHOD1 (CBlockWorld, SetIsServerWorld_s, bool)
 
 ATTRIBUTE_METHOD1 (CBlockWorld, IsSaveLightMap_s, bool *)
 
 ATTRIBUTE_METHOD1 (CBlockWorld, SetSaveLightMap_s, bool)
 
 ATTRIBUTE_METHOD1 (CBlockWorld, IsUseAsyncLoadWorld_s, bool *)
 
 ATTRIBUTE_METHOD1 (CBlockWorld, SetUseAsyncLoadWorld_s, bool)
 
 ATTRIBUTE_METHOD1 (CBlockWorld, GetLightCalculationStep_s, int *)
 
 ATTRIBUTE_METHOD1 (CBlockWorld, SetLightCalculationStep_s, int)
 
 ATTRIBUTE_METHOD1 (CBlockWorld, GetMaxCacheRegionCount_s, int *)
 
 ATTRIBUTE_METHOD1 (CBlockWorld, SetMaxCacheRegionCount_s, int)
 
 ATTRIBUTE_METHOD1 (CBlockWorld, GetNumOfLockedBlockRegion_s, int *)
 
 ATTRIBUTE_METHOD1 (CBlockWorld, GetNumOfBlockRegion_s, int *)
 
 ATTRIBUTE_METHOD1 (CBlockWorld, GetTotalNumOfLoadedChunksInLockedBlockRegion_s, int *)
 
 ATTRIBUTE_METHOD1 (CBlockWorld, IsRenderBlocks_s, bool *)
 
 ATTRIBUTE_METHOD1 (CBlockWorld, SetRenderBlocks_s, bool)
 
 ATTRIBUTE_METHOD1 (CBlockWorld, GetSunIntensity_s, float *)
 
 ATTRIBUTE_METHOD1 (CBlockWorld, SetSunIntensity_s, float)
 
 ATTRIBUTE_METHOD1 (CBlockWorld, GetMinWorldPos_s, Vector3 *)
 
 ATTRIBUTE_METHOD1 (CBlockWorld, SetMinWorldPos_s, Vector3)
 
 ATTRIBUTE_METHOD1 (CBlockWorld, GetMaxWorldPos_s, Vector3 *)
 
 ATTRIBUTE_METHOD1 (CBlockWorld, SetMaxWorldPos_s, Vector3)
 
 ATTRIBUTE_METHOD1 (CBlockWorld, GetTotalChunksInMemory_s, int *)
 
 ATTRIBUTE_METHOD1 (CBlockWorld, GetTotalRenderableChunksInMemory_s, int *)
 
 ATTRIBUTE_METHOD1 (CBlockWorld, UseLinearTorchBrightness_s, bool)
 
 DEFINE_SCRIPT_EVENT (CBlockWorld, BeforeLoadBlockRegion)
 
 DEFINE_SCRIPT_EVENT (CBlockWorld, LoadBlockRegion)
 
 DEFINE_SCRIPT_EVENT (CBlockWorld, UnLoadBlockRegion)
 
 DEFINE_SCRIPT_EVENT (CBlockWorld, SaveRegionCallbackScript)
 NPL script to be called when a given region is flushed to disk.
 
 DEFINE_SCRIPT_EVENT (CBlockWorld, GeneratorScript)
 
int OnBeforeLoadBlockRegion (int x, int y)
 called before block region is about to be loaded. More...
 
int OnLoadBlockRegion (int x, int y)
 called when block region has just loaded. More...
 
int OnUnLoadBlockRegion (int x, int y)
 called when block region has just unloaded. More...
 
int OnSaveBlockRegion (int x, int y)
 called when block region has just saved. More...
 
CBlockLightGridBaseGetLightGrid ()
 get light grid
 
virtual const std::string & GetIdentifier ()
 
virtual void SetIdentifier (const std::string &sID)
 
virtual void EnterWorld (const string &sWorldDir, float x, float y, float z)
 
virtual void LeaveWorld ()
 
void ClearAllBlockTemplates ()
 
void SetActiveChunkRadius (int nActiveChunkRadius=12)
 how many chunk
 
void UpdateAllActiveChunks ()
 
const ParaEngine::Int32x3GetMinWorldPos () const
 minimum world position. More...
 
void SetMinWorldPos (const ParaEngine::Int32x3 &val)
 
const ParaEngine::Int32x3GetMaxWorldPos () const
 maximum world position. More...
 
void SetMaxWorldPos (const ParaEngine::Int32x3 &val)
 
uint16_t GetMaxCacheRegionCount () const
 
void SetMaxCacheRegionCount (uint16_t val)
 
virtual void SetLightCalculationStep (uint32 nTicks)
 how many lighting to calculate per tick for the lighting thread. More...
 
virtual uint32 GetLightCalculationStep ()
 
BlockRegionGetRegion (uint16_t x, uint16_t y, uint16_t z, uint16_t &rs_x, uint16_t &rs_y, uint16_t &rs_z)
 get region object More...
 
BlockRegionGetRegion (uint16_t region_x, uint16_t region_z)
 
int32_t GetActiveChunkDim ()
 
int32_t GetActiveChunkDimY ()
 
bool IsInBlockWorld ()
 
void SetRenderBlocks (bool bValue)
 whether it is readonly
 
bool IsRenderBlocks ()
 whether it is readonly
 
bool IsUseAsyncLoadWorld () const
 whether we will use async world loader. More...
 
void SetUseAsyncLoadWorld (bool val)
 
void SetReadOnly (bool bValue)
 whether it is readonly
 
bool IsReadOnly ()
 whether it is readonly
 
bool IsVisibleChunkDirty () const
 if true, it will check dirty bit for all active chunks in the next the render framemove
 
void SetVisibleChunkDirty (bool val)
 
void SetIsRemote (bool bValue)
 whether it is a remote world. More...
 
bool IsRemote ()
 whether it is a remote world
 
void SetIsServerWorld (bool bValue)
 whether it is a server world. More...
 
bool IsServerWorld ()
 whether it is server world
 
bool IsGroupByChunkBeforeTexture () const
 if true, when rendering blocks, always group by chunk first and then by texture. More...
 
void SetGroupByChunkBeforeTexture (bool val)
 
ParaEngine::mutexGetBlockWorldMutex ()
 when some thread is accessing the block world. More...
 
void LockWorld ()
 use scoped_lock where ever possible. More...
 
void UnlockWorld ()
 Unlock mutex.
 
BlockReadWriteLockGetReadWriteLock ()
 get read/write locker of this world
 
bool IsSaveLightMap () const
 whether to save light map to disk. More...
 
void SaveLightMap (bool val)
 
void SaveBlockTemplateData ()
 
void LoadBlockTemplateData ()
 
void SaveToFile (bool saveToTemp)
 
CWorldInfoGetWorldInfo ()
 return world info
 
BlockTemplateRegisterTemplate (uint16_t id, uint32_t attFlag, uint16_t category_id)
 
bool SetBlockVisible (uint16_t templateId, bool value, bool bRefreshWorld=true)
 return true if refresh world is required. More...
 
void RefreshBlockTemplate (uint16_t templateId)
 refresh light and other attributes for all instances of given block template. More...
 
uint32_t SetBlockId (uint16_t x, uint16_t y, uint16_t z, uint32_t nBlockID)
 
uint32_t GetBlockId (uint16_t x, uint16_t y, uint16_t z)
 
uint32_t SetBlockData (uint16_t x, uint16_t y, uint16_t z, uint32_t nBlockData)
 
uint32_t GetBlockData (uint16_t x, uint16_t y, uint16_t z)
 
BlockTemplateGetBlockTemplate (uint16_t id)
 
BlockTemplateGetBlockTemplate (uint16_t x, uint16_t y, uint16_t z)
 
BlockTemplateGetBlockTemplate (Uint16x3 &blockId_ws)
 
bool MatchTemplateAttribute (uint16_t templateId, BlockTemplate::BlockAttrubiteFlag flag)
 
void SetTemplateTexture (uint16_t id, const char *textureName)
 
ChunkMaxHeightGetHighestBlock (uint16_t blockX_ws, uint16_t blockZ_ws)
 
virtual void GetMaxBlockHeightWatchingSky (uint16_t blockX_ws, uint16_t blockZ_ws, ChunkMaxHeight *pResult)
 
void RefreshAllLightsInColumn (uint16_t chunkX_ws, uint16_t chunkZ_ws)
 
void NotifyBlockHeightMapChanged (uint16_t blockIdX_ws, uint16_t blockIdZ_ws, ChunkMaxHeight &prevBlockHeight)
 
BlockIndex GetBlockIndex (uint16_t x, uint16_t y, uint16_t z, bool bCreateIfNotExist=true)
 return the BlockChunk and the block index inside the chunk. More...
 
BlockChunkGetChunk (uint16_t x, uint16_t y, uint16_t z, bool bCreateIfNotExist=true)
 get chunk by world coordinates
 
void SetBlockTemplateId (float x, float y, float z, uint16_t templateId)
 
void SetBlockTemplateIdByIdx (uint16_t x, uint16_t y, uint16_t z, uint16_t templateId)
 
uint16_t GetBlockTemplateId (float x, float y, float z)
 
uint16_t GetBlockTemplateIdByIdx (uint16_t x, uint16_t y, uint16_t z)
 
void SetBlockUserData (float x, float y, float z, uint32_t data)
 
void SetBlockUserDataByIdx (uint16_t x, uint16_t y, uint16_t z, uint32_t data)
 
uint32_t GetBlockUserData (float x, float y, float z)
 
uint32_t GetBlockUserDataByIdx (uint16_t x, uint16_t y, uint16_t z)
 
bool IsObstructionBlock (uint16_t x, uint16_t y, uint16_t z)
 
BlockGetBlock (uint16_t x, uint16_t y, uint16_t z)
 
BlockGetUnlockBlock (uint16_t x, uint16_t y, uint16_t z)
 
void SetChunkDirty (Uint16x3 &chunkId_ws, bool isDirty)
 
void SetChunkLightDirty (Uint16x3 &chunkId_ws)
 
void SetChunkColumnTimeStamp (uint16_t x, uint16_t z, uint16_t nTimeStamp)
 set chunk column time stamp. More...
 
int32_t GetChunkColumnTimeStamp (uint16_t x, uint16_t z)
 get the time stamp of for the given chunk column -1 means region not loaded yet, 0 means not available, 1 means loaded before
 
bool DoChunksNearChunkExist (uint16_t x, uint16_t y, uint16_t z, uint16_t radius)
 Checks if any of the chunks within radius blocks of the given block exist. More...
 
bool CheckChunkColumnsExist (int minX, int minY, int minZ, int maxX, int maxY, int maxZ)
 Checks between a min and max all the chunks in between actually exist. More...
 
bool ChunkColumnExists (uint16_t chunkX, uint16_t chunkZ)
 Returns whether a chunk exists at chunk coordinates x, y.
 
bool IsChunkLocked (uint32 worldX, uint32 worldZ)
 whether the chunk at the given world position is locked. More...
 
int32_t GetBlocksInRegion (Uint16x3 &startChunk_ws, Uint16x3 &endChunk_ws, uint32_t matchType, const luabind::adl::object &result, uint32_t verticalSectionFilter=0)
 
int GetDirtyColumnCount ()
 get number of dirty chunk columns for light calculations
 
int GetDirtyBlockCount ()
 get the number of remaining dirty blocks
 
bool IsCubeModePicking ()
 ignore sub-block level physics during Pick() function. More...
 
void SetCubeModePicking (bool bIsCubeModePicking)
 
bool Pick (const Vector3 &rayOrig, const Vector3 &dir, float length, PickResult &result, uint32_t filter=0xffffffff)
 picking in block world
 
int FindFirstBlock (uint16_t x, uint16_t y, uint16_t z, uint16_t nSide=4, uint32_t max_dist=32, uint32_t attrFilter=0xffffffff, int nCategoryID=-1)
 find a block in the side direction that matched filter from block(x,y,z) this function can be used to check for free space upward or download More...
 
int GetFirstBlock (uint16_t x, uint16_t y, uint16_t z, int nBlockId, uint16_t nSide=5, uint32_t max_dist=32)
 get the y pos of the first block of nBlockID, start searching from x, y, z in the side direction More...
 
bool RefreshChunkColumn (int16_t curChunkWX, int16_t curChunkWZ)
 this function is called, when the entire column is loaded
 
bool IsChunkColumnInActiveRange (int16_t curChunkWX, int16_t curChunkWZ)
 is the chunk column in active chunk region. More...
 
bool GetBlockBrightness (Uint16x3 &blockId_ws, uint8_t *brightness, int nSize=27, int nLightType=-1)
 get light brightness of current and 26 nearby block More...
 
bool GetBlockMeshBrightness (Uint16x3 &blockId_ws, uint8_t *brightness, int nLightType=2)
 if the block in not solid, we will simply return the block's brightness. More...
 
float GetBlockBrightnessReal (const Vector3 &vPos, float *pBrightness=NULL)
 get the interpolated block brightness at the given position. More...
 
float GetBlockBrightnessReal (Uint16x3 &blockId_ws, float *pBrightness=NULL)
 
void SetSunIntensity (float intensity)
 
float GetSunIntensity ()
 
void SetLightBlockDirty (Uint16x3 &blockId_ws, bool isSunLight)
 
LightDataGetLightData (uint16_t x, uint16_t y, uint16_t z, bool bCreateIfNotExist=true)
 get block light data by world coordinates
 
void SuspendLightUpdate ()
 
int GetNumOfLockedBlockRegion ()
 get the total number of locked bock regions. More...
 
int GetTotalNumOfLoadedChunksInLockedBlockRegion ()
 
int GetNumOfBlockRegion ()
 
void ResumeLightUpdate ()
 
bool IsLightUpdateSuspended ()
 
float GetLightBrightnessFloat (uint8_t brightness)
 
uint8_t GetLightBrightnessInt (uint8_t brightness)
 
float GetLightBrightnessLinearFloat (uint8_t brightness)
 
void GenerateLightBrightnessTable (bool bUseLinearBrightness=false)
 Creates the light to brightness table.
 
void OnViewCenterMove (float viewCenterX, float viewCenterY, float viewCenterZ)
 
void SetRenderDist (int nValue)
 max number of blocks to render from eye to farthest one
 
int GetRenderDist ()
 
BlockRenderMethod GetBlockRenderMethod ()
 get how blocks are preferred to be rendered. More...
 
virtual void SetBlockRenderMethod (BlockRenderMethod method)
 how blocks are preferred to be rendered. More...
 
void GetCurrentCenterChunkId (Int16x3 &oResult)
 
const Uint16x3GetEyeBlockId ()
 
void SetEyeBlockId (const Uint16x3 &eyePos)
 
const Uint16x3GetEyeChunkId ()
 
const Int16x3 GetMinActiveChunkId ()
 
void OnGenerateTerrain (int nRegionX, int nRegionY, int nChunkX=-1, int nChunkZ=-1)
 this function is called when region does not have matching disk file. More...
 
void SelectBlock (uint16_t x, uint16_t y, uint16_t z, int nGroupID=0)
 hight light select block More...
 
void DeselectBlock (uint16_t x, uint16_t y, uint16_t z, int nGroupID=0)
 
virtual void AddRenderTask (BlockRenderTask *pRenderTask)
 
void DeselectAllBlock (int nGroupID=-1)
 
BlockRegionCreateGetRegion (uint16_t block_x, uint16_t block_y, uint16_t block_z)
 load region at the given position. More...
 
BlockRegionCreateGetRegion (uint16_t region_x, uint16_t region_z)
 
virtual void ClearBlockRenderCache ()
 clear block render cache
 
virtual void OnFrameMove ()
 
RenderableChunkGetRenderableChunk (const Int16x3 &chunkPos)
 
bool UnloadRegion (uint16_t block_x, uint16_t block_y, uint16_t block_z, bool bAutoSave=true)
 unload region from memory. More...
 
void ResetAllLight ()
 
- Public Member Functions inherited from ParaEngine::IAttributeFields
 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 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 CDynamicAttributeFieldGetDynamicField (const std::string &sName)
 Get a dynamic field with a given name. More...
 
virtual CDynamicAttributeFieldGetDynamicField (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...
 
CAttributeClassGetAttributeClass ()
 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...
 
- Public Member Functions inherited from ParaEngine::IObject
virtual void Clone (IObject *obj) const
 Clone the object's contains to a pointer. More...
 
virtual IObjectClone () 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 ITypeGetType () const
 
virtual std::string ToString () const
 
WeakPtr_typeGetWeakReference ()
 get weak reference object. More...
 
virtual int ProcessObjectEvent (const ObjectEvent &event)
 this function is only used to backward compatibility of ParaObject:AddEvent() function. More...
 
- Public Member Functions inherited from ParaEngine::CRefCounted
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 ()
 
CRefCountedAddToAutoReleasePool ()
 addref and releases the ownership sometime soon automatically (usually at the end of the current frame). More...
 

Static Public Member Functions

static float GetVerticalOffset ()
 
static void SetVerticalOffset (float offset)
 
- Static Public Member Functions inherited from ParaEngine::IAttributeFields
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...
 

Protected Types

typedef BlockRegionBlockRegionPtr
 array of 64*64 regions. More...
 

Protected Member Functions

void UnloadRegion (BlockRegion *pRegion, bool bAutoSave=true)
 removed given region from memory. More...
 
RenderableChunkGetActiveChunk (uint16_t curChunkWX, uint16_t curChunkWY, uint16_t curChunkWZ)
 : world chunk coordinates
 
bool ReuseActiveChunk (int16_t curChunkWX, int16_t curChunkWY, int16_t curChunkWZ, BlockRegion *pRegion)
 force reusing active chunk
 
virtual void UpdateVisibleChunks (bool bIsShadowPass=false)
 
virtual void UpdateRegionCache ()
 
virtual void UpdateActiveChunk ()
 
virtual void ClearOutOfRangeActiveChunkData ()
 
- Protected Member Functions inherited from ParaEngine::IAttributeFields
virtual CAttributeClassCreateAttributeClass ()
 initialize fields
 
virtual CDynamicAttributesSetGetDynamicAttributes (bool bCreateIfNotExist=false)
 

Protected Attributes

std::string m_sName
 
int32_t m_activeChunkDim
 
int32_t m_activeChunkDimY
 
bool m_isInWorld
 whether this world is active
 
bool m_bReadOnlyWorld
 if true, no auto world saving is done when user moving out of the region cache. More...
 
bool m_bIsRemote
 a remote world connected to server. More...
 
bool m_bIsServerWorld
 a server world. More...
 
bool m_bSaveLightMap
 whether to save light map to disk. More...
 
bool m_bCubeModePicking
 ignore sub-block level physics during Pick() function. More...
 
bool m_isVisibleChunkDirty
 if true, it will check dirty bit for all active chunks in the next the render framemove
 
bool m_bRenderBlocks
 whether to render blocks
 
bool m_bUseAsyncLoadWorld
 whether we will use async world loader. More...
 
bool m_group_by_chunk_before_texture
 if true, when rendering blocks, always group by chunk first and then by texture. More...
 
bool m_is_linear_torch_brightness
 if true, light value in block shader is linear. More...
 
std::vector< RenderableChunk * > m_activeChunks
 
Int16x3 m_minActiveChunkId_ws
 
ParaEngine::mutex m_blockworld_mutex
 when some thread is accessing the block world. More...
 
int16_t m_curRegionIdX
 
int16_t m_curRegionIdZ
 
Int16x3 m_curChunkIdW
 
Int16x3 m_lastChunkIdW
 
Int16x3 m_lastChunkIdW_RegionCache
 
Uint16x3 m_lastViewCheckIdW
 
Uint16x3 m_curCenterBlockId
 
Uint16x3 m_curCamBlockId
 
Uint16x3 m_curCamChunkId
 
Uint16x3 m_selectBlockIdW
 
Int32x3 m_minWorldPos
 minimum world position. More...
 
Int32x3 m_maxWorldPos
 maximum world position. More...
 
int m_minRegionX
 
int m_minRegionZ
 
int m_maxRegionX
 
int m_maxRegionZ
 
int m_nRenderDistance
 max number of blocks to render from eye to farthest one
 
BlockRenderMethod m_dwBlockRenderMethod
 the current block rendering method. More...
 
float m_sunIntensity
 
CBlockLightGridBasem_pLightGrid
 
std::vector< RenderableChunk * > m_visibleChunks
 
std::vector< RenderableChunk * > m_tempDirtyChunks
 
uint16_t m_maxCacheRegionCount
 
BlockRegionPtrm_pRegions
 
std::map< int, BlockRegion * > m_regionCache
 
std::map< uint16_t, BlockTemplate * > m_blockTemplates
 
std::vector< BlockTemplate * > m_blockTemplatesArray
 
std::map< uint16_t, BlockTemplateVisibleDatam_blockTemplateVisibleDatas
 
CWorldInfo m_worldInfo
 
float m_lightBrightnessTableFloat [17]
 Light to brightness conversion table. More...
 
uint8_t m_lightBrightnessTableInt [17]
 Light to brightness conversion table. More...
 
float m_lightBrightnessLinearTableFloat [17]
 
std::vector< CBlockSelectGroupm_selectedBlockMap
 
BlockReadWriteLock m_readWriteLock
 read-write lock. More...
 
- Protected Attributes inherited from ParaEngine::IObject
WeakPtr_type m_weak_reference
 
- Protected Attributes inherited from ParaEngine::CRefCounted
int m_refcount
 

Static Protected Attributes

static float g_verticalOffset = 0
 

Friends

class CMultiFrameBlockWorldRenderer
 

Detailed Description

base class for an instance of block world

Member Typedef Documentation

§ BlockRegionPtr

array of 64*64 regions.

Member Function Documentation

§ CheckChunkColumnsExist()

bool ParaEngine::CBlockWorld::CheckChunkColumnsExist ( int  minX,
int  minY,
int  minZ,
int  maxX,
int  maxY,
int  maxZ 
)

Checks between a min and max all the chunks in between actually exist.

Parameters
allinput in block position.

§ CreateGetRegion()

BlockRegion * ParaEngine::CBlockWorld::CreateGetRegion ( uint16_t  block_x,
uint16_t  block_y,
uint16_t  block_z 
)

load region at the given position.

this function is usually called only on server side. for client side, region is automatically loaded when camera moves.

§ DeselectAllBlock()

void CBlockWorld::DeselectAllBlock ( int  nGroupID = -1)
Parameters
nGroupID0 for animated selection, 1 for wire frame selection. if negative. [0, -nGroupID] are cleared

§ DoChunksNearChunkExist()

bool ParaEngine::CBlockWorld::DoChunksNearChunkExist ( uint16_t  x,
uint16_t  y,
uint16_t  z,
uint16_t  radius 
)

Checks if any of the chunks within radius blocks of the given block exist.

Parameters
x,y,zcenter world block position
radiusradius

§ EnterWorld()

void ParaEngine::CBlockWorld::EnterWorld ( const string &  sWorldDir,
float  x,
float  y,
float  z 
)
virtual

only cache 4 region for networked world

§ FindFirstBlock()

int CBlockWorld::FindFirstBlock ( uint16_t  x,
uint16_t  y,
uint16_t  z,
uint16_t  nSide = 4,
uint32_t  max_dist = 32,
uint32_t  attrFilter = 0xffffffff,
int  nCategoryID = -1 
)

find a block in the side direction that matched filter from block(x,y,z) this function can be used to check for free space upward or download

Parameters
side4 is top. 5 is bottom.
attrFilterattribute to match. 0 means air. default to any block
nCategoryID-1 means any category_id. default to -1
Returns
-1 if not found. otherwise distance to the first block that match in the side direction is returned.

§ GetAttributeClassID()

virtual int ParaEngine::CBlockWorld::GetAttributeClassID ( )
inlinevirtual

attribute class ID should be identical, unless one knows how overriding rules work.

Reimplemented from ParaEngine::IAttributeFields.

Reimplemented in ParaEngine::BlockWorldClient.

§ GetBlockBrightness()

bool CBlockWorld::GetBlockBrightness ( Uint16x3 blockId_ws,
uint8_t *  brightness,
int  nSize = 27,
int  nLightType = -1 
)

get light brightness of current and 26 nearby block

Parameters
brightnesspointer to uint8_t blockBrightness[27];
nSizeif 1, it will only get the center block. it is usually 27.
nLightType-1 means Max light. 0 means emissive block light, 1 means sun light. 2 means both. where brightness[i] is block light and brightness[i+nSize] is sunlight

§ GetBlockBrightnessReal()

float CBlockWorld::GetBlockBrightnessReal ( const Vector3 vPos,
float *  pBrightness = NULL 
)

get the interpolated block brightness at the given position.

This function ensures smooth light intensity when vPos moves in real world.

Parameters
vPosreal world position.
pBrightnessoutput light value
Returns
: light in [0,1] range

§ GetBlockIndex()

BlockIndex CBlockWorld::GetBlockIndex ( uint16_t  x,
uint16_t  y,
uint16_t  z,
bool  bCreateIfNotExist = true 
)

return the BlockChunk and the block index inside the chunk.

§ GetBlockMeshBrightness()

bool CBlockWorld::GetBlockMeshBrightness ( Uint16x3 blockId_ws,
uint8_t *  brightness,
int  nLightType = 2 
)

if the block in not solid, we will simply return the block's brightness.

if the block is solid, we will return the max brightness of the block's 6 neighbors.

§ GetBlockRenderMethod()

ParaEngine::BlockRenderMethod ParaEngine::CBlockWorld::GetBlockRenderMethod ( )

get how blocks are preferred to be rendered.

§ GetBlocksInRegion()

int32_t CBlockWorld::GetBlocksInRegion ( Uint16x3 startChunk_ws,
Uint16x3 endChunk_ws,
uint32_t  matchType,
const luabind::adl::object result,
uint32_t  verticalSectionFilter = 0 
)
Parameters
verticalSectionFilterif not 0, we will ignore y value in startChunk_ws and endChunk_ws, but use this as a bitwise filter to y

§ GetBlockWorldMutex()

ParaEngine::mutex & ParaEngine::CBlockWorld::GetBlockWorldMutex ( )

when some thread is accessing the block world.

It generally need to acquire this lock. On client, the main thread will acquire the lock at beginning of scene/block animation/rendering and release it at the end. So the main thread is occupied this block for a relative long time. Any other worker thread such as light calculation and terrain generation should wait for this lock, and even it does successfully required the lock, they must ensure it is released immediately to not affecting the main rendering thread.

§ GetChildAttributeColumnCount()

virtual int ParaEngine::CBlockWorld::GetChildAttributeColumnCount ( )
inlinevirtual

we support multi-dimensional child object.

by default objects have only one column.

Reimplemented from ParaEngine::IAttributeFields.

Reimplemented in ParaEngine::BlockWorldClient.

§ GetChildAttributeObject()

IAttributeFields * ParaEngine::CBlockWorld::GetChildAttributeObject ( const std::string &  sName)
virtual

get attribute by child object.

used to iterate across the attribute field hierarchy.

Reimplemented from ParaEngine::IAttributeFields.

Reimplemented in ParaEngine::BlockWorldClient.

§ GetChildAttributeObjectCount()

int ParaEngine::CBlockWorld::GetChildAttributeObjectCount ( int  nColumnIndex = 0)
virtual

get the number of child objects (row count) in the given column.

please note different columns can have different row count.

Reimplemented from ParaEngine::IAttributeFields.

Reimplemented in ParaEngine::BlockWorldClient.

§ GetFirstBlock()

int CBlockWorld::GetFirstBlock ( uint16_t  x,
uint16_t  y,
uint16_t  z,
int  nBlockId,
uint16_t  nSide = 5,
uint32_t  max_dist = 32 
)

get the y pos of the first block of nBlockID, start searching from x, y, z in the side direction

Parameters
side4 is top. 5 is bottom. default to 5, which uses heightmap for first block(can be a little faster. )

§ GetLightBrightnessFloat()

float ParaEngine::CBlockWorld::GetLightBrightnessFloat ( uint8_t  brightness)
Parameters
brightnessmust be in the range of [0,15]

§ GetLightBrightnessInt()

uint8_t ParaEngine::CBlockWorld::GetLightBrightnessInt ( uint8_t  brightness)
Parameters
brightnessmust be in the range of [0,15]

§ GetLightBrightnessLinearFloat()

float ParaEngine::CBlockWorld::GetLightBrightnessLinearFloat ( uint8_t  brightness)
Parameters
brightnessmust be in the range of [0,15]

§ GetMaxWorldPos()

const ParaEngine::Int32x3 & ParaEngine::CBlockWorld::GetMaxWorldPos ( ) const

maximum world position.

mostly set to prevent running out of memory. default to 0xffff,0xffff,0xffff.

§ GetMinWorldPos()

const ParaEngine::Int32x3 & ParaEngine::CBlockWorld::GetMinWorldPos ( ) const

minimum world position.

mostly set to prevent running out of memory. default to 0,0,0.

§ GetNumOfLockedBlockRegion()

int ParaEngine::CBlockWorld::GetNumOfLockedBlockRegion ( )

get the total number of locked bock regions.

If this is not 0, it means that the world loading is still going on in background thread.

§ GetRegion()

BlockRegion * CBlockWorld::GetRegion ( uint16_t  x,
uint16_t  y,
uint16_t  z,
uint16_t &  rs_x,
uint16_t &  rs_y,
uint16_t &  rs_z 
)

get region object

Parameters
x,y,zin world space
rs_x,rs_y,rs_zout: converted to region space.

§ InstallFields()

int ParaEngine::CBlockWorld::InstallFields ( CAttributeClass pClass,
bool  bOverride 
)
virtual

this class should be implemented if one wants to add new attribute.

This function is always called internally.

Reimplemented from ParaEngine::IAttributeFields.

Reimplemented in ParaEngine::BlockWorldClient.

§ IsChunkColumnInActiveRange()

bool ParaEngine::CBlockWorld::IsChunkColumnInActiveRange ( int16_t  curChunkWX,
int16_t  curChunkWZ 
)

is the chunk column in active chunk region.

§ IsChunkLocked()

bool ParaEngine::CBlockWorld::IsChunkLocked ( uint32  worldX,
uint32  worldZ 
)

whether the chunk at the given world position is locked.

a locked chunk is not loaded or being loaded or saved. when chunk is locked, all block set/get calls will take no effect.

§ IsCubeModePicking()

bool CBlockWorld::IsCubeModePicking ( )

ignore sub-block level physics during Pick() function.

this is mostly used by camera collision

§ IsGroupByChunkBeforeTexture()

bool ParaEngine::CBlockWorld::IsGroupByChunkBeforeTexture ( ) const

if true, when rendering blocks, always group by chunk first and then by texture.

if not we will group by texture first from all chunks.

§ IsSaveLightMap()

bool ParaEngine::CBlockWorld::IsSaveLightMap ( ) const

whether to save light map to disk.

Light map usually double the disk space, but increases map loading time, without the occasionally black blocks.

§ IsUseAsyncLoadWorld()

bool ParaEngine::CBlockWorld::IsUseAsyncLoadWorld ( ) const

whether we will use async world loader.

default to false. this is only true when region is first loaded.

§ LockWorld()

void ParaEngine::CBlockWorld::LockWorld ( )

use scoped_lock where ever possible.

this function is only called from scripting interface, where scoped_lock is not possible. however script using this function must be very short and careful to call unlockworld in pairs;otherwise there will be dead lock. Nested calls to this function in the same thread will not block but must be in pairs.

§ OnBeforeLoadBlockRegion()

int ParaEngine::CBlockWorld::OnBeforeLoadBlockRegion ( int  x,
int  y 
)

called before block region is about to be loaded.

If the function does not return 0, we will skip loading the block region.

§ OnGenerateTerrain()

void CBlockWorld::OnGenerateTerrain ( int  nRegionX,
int  nRegionY,
int  nChunkX = -1,
int  nChunkZ = -1 
)

this function is called when region does not have matching disk file.

§ OnLoadBlockRegion()

int CBlockWorld::OnLoadBlockRegion ( int  x,
int  y 
)

called when block region has just loaded.

it will invoke the scripting interface if any.

§ OnSaveBlockRegion()

int ParaEngine::CBlockWorld::OnSaveBlockRegion ( int  x,
int  y 
)

called when block region has just saved.

it will invoke the scripting interface if any.

§ OnUnLoadBlockRegion()

int CBlockWorld::OnUnLoadBlockRegion ( int  x,
int  y 
)

called when block region has just unloaded.

it will invoke the scripting interface if any.

§ RefreshBlockTemplate()

void ParaEngine::CBlockWorld::RefreshBlockTemplate ( uint16_t  templateId)

refresh light and other attributes for all instances of given block template.

§ SelectBlock()

void CBlockWorld::SelectBlock ( uint16_t  x,
uint16_t  y,
uint16_t  z,
int  nGroupID = 0 
)

hight light select block

Parameters
nGroupID0 for animated selection, 1 for wire frame selection.

§ SetBlockRenderMethod()

void ParaEngine::CBlockWorld::SetBlockRenderMethod ( BlockRenderMethod  method)
virtual

how blocks are preferred to be rendered.

Reimplemented in ParaEngine::BlockWorldClient.

§ SetBlockVisible()

bool CBlockWorld::SetBlockVisible ( uint16_t  templateId,
bool  value,
bool  bRefreshWorld = true 
)

return true if refresh world is required.

§ SetChunkColumnTimeStamp()

void CBlockWorld::SetChunkColumnTimeStamp ( uint16_t  x,
uint16_t  z,
uint16_t  nTimeStamp 
)

set chunk column time stamp.

usually 0 for non-generated. 1 for generated. this is usually called by world generators, so that we will not generate again next time we load the world.

§ SetIsRemote()

void ParaEngine::CBlockWorld::SetIsRemote ( bool  bValue)

whether it is a remote world.

in such cases, we will stop loading from file.

§ SetIsServerWorld()

void ParaEngine::CBlockWorld::SetIsServerWorld ( bool  bValue)

whether it is a server world.

in such cases, we will not unload region file.

§ SetLightCalculationStep()

void ParaEngine::CBlockWorld::SetLightCalculationStep ( uint32  nTicks)
virtual

how many lighting to calculate per tick for the lighting thread.

Parameters
nTicksdefault to 0. it will stop light calculation when some predefined lighting tasks is finished. Otherwise, it will only stop either all tasks are finished or nTicks milliseconds have passed since it begins.

§ UnloadRegion() [1/2]

bool ParaEngine::CBlockWorld::UnloadRegion ( uint16_t  block_x,
uint16_t  block_y,
uint16_t  block_z,
bool  bAutoSave = true 
)

unload region from memory.

return true if unloaded.

§ UnloadRegion() [2/2]

void CBlockWorld::UnloadRegion ( BlockRegion pRegion,
bool  bAutoSave = true 
)
protected

removed given region from memory.

Member Data Documentation

§ m_bCubeModePicking

bool ParaEngine::CBlockWorld::m_bCubeModePicking
protected

ignore sub-block level physics during Pick() function.

this is mostly used by camera collision

§ m_bIsRemote

bool ParaEngine::CBlockWorld::m_bIsRemote
protected

a remote world connected to server.

§ m_bIsServerWorld

bool ParaEngine::CBlockWorld::m_bIsServerWorld
protected

a server world.

§ m_blockworld_mutex

ParaEngine::mutex ParaEngine::CBlockWorld::m_blockworld_mutex
protected

when some thread is accessing the block world.

It generally need to acquire this lock. On client, the main thread will acquire the lock at beginning of scene/block animation/rendering and release it at the end. So the main thread is occupied this block for a relative long time. Any other worker thread such as light calculation and terrain generation should wait for this lock, and even it does successfully required the lock, they must ensure it is released immediately to not affecting the main rendering thread.

§ m_bReadOnlyWorld

bool ParaEngine::CBlockWorld::m_bReadOnlyWorld
protected

if true, no auto world saving is done when user moving out of the region cache.

§ m_bSaveLightMap

bool ParaEngine::CBlockWorld::m_bSaveLightMap
protected

whether to save light map to disk.

Light map usually double the disk space, but increases map loading time, without the occasionally black blocks.

§ m_bUseAsyncLoadWorld

bool ParaEngine::CBlockWorld::m_bUseAsyncLoadWorld
protected

whether we will use async world loader.

default to false. this is only true when region is first loaded.

§ m_dwBlockRenderMethod

BlockRenderMethod ParaEngine::CBlockWorld::m_dwBlockRenderMethod
protected

the current block rendering method.

§ m_group_by_chunk_before_texture

bool ParaEngine::CBlockWorld::m_group_by_chunk_before_texture
protected

if true, when rendering blocks, always group by chunk first and then by texture.

if not we will group by texture first from all chunks.

§ m_is_linear_torch_brightness

bool ParaEngine::CBlockWorld::m_is_linear_torch_brightness
protected

if true, light value in block shader is linear.

if false, it is pre-calculated to have a falloff curve.

§ m_lightBrightnessTableFloat

float ParaEngine::CBlockWorld::m_lightBrightnessTableFloat[17]
protected

Light to brightness conversion table.

[0,1] float

§ m_lightBrightnessTableInt

uint8_t ParaEngine::CBlockWorld::m_lightBrightnessTableInt[17]
protected

Light to brightness conversion table.

[0, 255] int

§ m_maxWorldPos

Int32x3 ParaEngine::CBlockWorld::m_maxWorldPos
protected

maximum world position.

mostly set to prevent running out of memory. default to 0xffff,0xffff,0xffff.

§ m_minWorldPos

Int32x3 ParaEngine::CBlockWorld::m_minWorldPos
protected

minimum world position.

mostly set to prevent running out of memory. default to 0,0,0.

§ m_readWriteLock

BlockReadWriteLock ParaEngine::CBlockWorld::m_readWriteLock
protected

read-write lock.


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