BVB Source Codes

CRYENGINE Show GraphNodeManager.h Source code

Return Download CRYENGINE: download GraphNodeManager.h Source code - Download CRYENGINE Source code - Type:.h
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. #ifndef __GRAPHNODEMANAGER_H__
  4. #define __GRAPHNODEMANAGER_H__
  5.  
  6. #include "GraphStructures.h"
  7.  
  8. class CGraphNodeManager
  9. {
  10.         enum {BUCKET_SIZE_SHIFT = 7};
  11.         enum {BUCKET_SIZE = 128};
  12.  
  13. public:
  14.         CGraphNodeManager();
  15.         ~CGraphNodeManager();
  16.  
  17.         // NOTE Oct 20, 2009: <pvl> only called from Graph::Clear() and own destructor
  18.         void       Clear(IAISystem::tNavCapMask typeMask);
  19.  
  20.         unsigned   CreateNode(IAISystem::tNavCapMask type, const Vec3& pos, unsigned ID);
  21.         void       DestroyNode(unsigned index);
  22.  
  23.         GraphNode* GetNode(unsigned index)
  24.         {
  25.                 if (!index)
  26.                         return 0;
  27.                 int bucket = (index - 1) >> BUCKET_SIZE_SHIFT;
  28.                 if (!m_buckets[bucket])
  29.                 {
  30.                         CRY_ASSERT_MESSAGE(0, "CGraphNodeManager::GetNode: figure out why the caller is requesting a node that doesn't exist (maybe he deleted it and now tries to access it?)");
  31.                         return 0;
  32.                 }
  33.                 return reinterpret_cast<GraphNode*>(m_buckets[bucket]->nodes +
  34.                                                     (((index - 1) & (BUCKET_SIZE - 1)) * m_buckets[bucket]->GetNodeSize()));
  35.         }
  36.  
  37.         const GraphNode* GetNode(unsigned index) const
  38.         {
  39.                 if (!index)
  40.                         return 0;
  41.                 int bucket = (index - 1) >> BUCKET_SIZE_SHIFT;
  42.                 if (!m_buckets[bucket])
  43.                 {
  44.                         CRY_ASSERT_MESSAGE(0, "CGraphNodeManager::GetNode: figure out why the caller is requesting a node that doesn't exist (maybe he deleted it and now tries to access it?)");
  45.                         return 0;
  46.                 }
  47.                 return reinterpret_cast<GraphNode*>(m_buckets[bucket]->nodes +
  48.                                                     (((index - 1) & (BUCKET_SIZE - 1)) * m_buckets[bucket]->GetNodeSize()));
  49.         }
  50.  
  51.         size_t NodeMemorySize() const;
  52.         void   GetMemoryStatistics(ICrySizer* pSizer);
  53.  
  54. private:
  55.         class BucketHeader
  56.         {
  57.         public:
  58.                 enum { InvalidNextFreeBucketIdx = 0xffff };
  59.                 enum { InvalidNextAvailableIdx = 0xff };
  60.  
  61.         public:
  62.                 unsigned type;
  63.                 uint16   nextFreeBucketIdx;
  64.                 uint8    nodeSizeS2;
  65.                 uint8    nextAvailable;
  66.                 uint8*   nodes;
  67.  
  68.                 ILINE size_t GetNodeSize() const    { return (size_t)nodeSizeS2 << 2; }
  69.                 ILINE void   SetNodeSize(size_t sz) { nodeSizeS2 = static_cast<uint8>(sz >> 2); }
  70.         };
  71.  
  72.         int TypeSizeFromTypeIndex(unsigned typeIndex) const;
  73.  
  74.         std::vector<BucketHeader*> m_buckets;
  75.         std::vector<uint16>        m_freeBuckets;
  76.         int                        m_typeSizes[IAISystem::NAV_TYPE_COUNT];
  77. };
  78.  
  79. #endif //__GRAPHNODEMANAGER_H__
  80.  
downloadGraphNodeManager.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