BVB Source Codes

CRYENGINE Show SegmentNode.h Source code

Return Download CRYENGINE: download SegmentNode.h Source code - Download CRYENGINE Source code - Type:.h
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. // -------------------------------------------------------------------------
  4. //  File name:   SegmentNode.h
  5. //  Version:     v1.00
  6. //  Created:     18/04/2012 by Allen Chen
  7. //  Compilers:   Visual Studio.NET
  8. //  Description:
  9. // -------------------------------------------------------------------------
  10. //  History:
  11. //
  12. ////////////////////////////////////////////////////////////////////////////
  13.  
  14. #ifndef __Segment_Node_h__
  15. #define __Segment_Node_h__
  16.  
  17. #if _MSC_VER > 1000
  18.         #pragma once
  19. #endif
  20.  
  21. #include <CrySystem/IStreamEngine.h>
  22. #define USE_RELATIVE_COORD 1
  23.  
  24. struct SMemBlock : public CMultiThreadRefCount
  25. {
  26.         SMemBlock() { pData = 0; nDataSize = 0; }
  27.         explicit SMemBlock(int size) { pData = new uint8[size]; nDataSize = size; }
  28.         ~SMemBlock() { SAFE_DELETE_ARRAY(pData); }
  29.  
  30.         uint8* pData;
  31.         int    nDataSize;
  32. };
  33.  
  34. enum ESegmentStatus
  35. {
  36.         ESEG_IDLE,
  37.         ESEG_INIT,
  38.         ESEG_STREAM,
  39. };
  40.  
  41. enum ESegmentStreamingStatus
  42. {
  43.         ESSS_Streaming_TerrainData,
  44.         ESSS_Setting_TerrainData,
  45.         ESSS_Streaming_VisAreaData,
  46.         ESSS_Setting_VisAreaData,
  47.         ESSS_Streaming_EntityData,
  48.         ESSS_Setting_EntityData,
  49.         ESSS_Loaded,
  50.         ESSS_Warning,
  51. };
  52.  
  53. class CSegmentedWorld;
  54.  
  55. class CSegmentNode : public IStreamCallback
  56. {
  57.         friend class CSegmentedWorld;
  58. public:
  59.         CSegmentNode(CSegmentedWorld* pParent, int wx, int wy, int lx, int ly);
  60.         ~CSegmentNode();
  61.  
  62.         bool Init();
  63.         void Stream();
  64.         void Delete();
  65.         void Update();
  66.  
  67.         bool LoadTerrain(void* pData, int nDataSize, float maxMs);
  68.         bool LoadVisArea(void* pData, int nDataSize, float maxMs);
  69.         bool LoadEntities();
  70.         bool LoadNavigation();
  71.         bool LoadAreas();
  72.         bool ForceLoad(unsigned int flags);
  73.  
  74.         bool OffsetApplied(int lx, int ly) { return (m_lx == lx && m_ly == ly); }
  75.         void SetLocalCoords(int lx, int ly);
  76.         void SetStatus(ESegmentStatus val) { m_status = val; }
  77.         bool StreamingSucceeded()          { return m_streamingStatus == ESSS_Loaded; }
  78.         bool StreamingFinished()           { return m_streamingStatus >= ESSS_Loaded; }
  79.  
  80.         // IStreamCallback
  81.         virtual void StreamAsyncOnComplete(IReadStream* pStream, unsigned nError)
  82.         {
  83.                 if (nError == 0)
  84.                 {
  85.                         _smart_ptr<SMemBlock> pBlock = new SMemBlock(pStream->GetBytesRead());
  86.                         memcpy(pBlock->pData, pStream->GetBuffer(), pStream->GetBytesRead());
  87.  
  88.                         AUTO_LOCK(m_streamDatasLock);
  89.                         m_streamDatas[pStream] = pBlock;
  90.                 }
  91.         }
  92.         virtual void StreamOnComplete(IReadStream* pStream, unsigned nError) {}
  93.         // ~IStreamCallback
  94.  
  95.         std::vector<IEntity*> m_globalEntities;
  96.         std::vector<IEntity*> m_localEntities;
  97.  
  98. protected:
  99.         CSegmentedWorld*                              m_pSW;
  100.         int                                           m_nSID;
  101.         int                                           m_wx, m_wy;
  102.         int                                           m_lx, m_ly;
  103.         bool                                          m_inited;
  104.  
  105.         string                                        m_segGamePath;
  106.         string                                        m_segPackName;
  107.         std::vector<string>                           m_log;
  108.  
  109.         ESegmentStatus                                m_status;
  110.         ESegmentStreamingStatus                       m_streamingStatus;
  111.  
  112.         std::map<IReadStream*, _smart_ptr<SMemBlock>> m_streamDatas;
  113.         CryCriticalSection                            m_streamDatasLock;
  114.  
  115.         IReadStreamPtr                                m_pStreamTerrain;
  116.         IReadStreamPtr                                m_pStreamVisArea;
  117.         _smart_ptr<SMemBlock>                         m_pFileDataBlock;
  118. };
  119.  
  120. #endif // __Segment_Node_h__
  121.  
downloadSegmentNode.h Source code - Download CRYENGINE Source code
Related Source Codes/Software:
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top