BVB Source Codes

CRYENGINE Show OffGridLinks.h Source code

Return Download CRYENGINE: download OffGridLinks.h Source code - Download CRYENGINE Source code - Type:.h
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. #ifndef __OFFMESH_LINKS_H__
  4. #define __OFFMESH_LINKS_H__
  5.  
  6. #pragma once
  7.  
  8. #include "../MNM/MNM.h"
  9.  
  10. struct NavigationMesh;
  11. struct IAIPathAgent;
  12.  
  13. namespace MNM
  14. {
  15. //////////////////////////////////////////////////////////////////////////
  16. /// One of this objects is bound to every Navigation Mesh
  17. /// Keeps track of off-mesh links per Tile
  18. /// Each tile can have up to 1024 Triangle links (limited by the Tile link structure within the mesh)
  19. ///
  20. /// Some triangles in the NavigationMesh will have a special link with an index
  21. /// which allows to access this off-mesh data
  22. struct OffMeshNavigation
  23. {
  24. private:
  25.  
  26.         //////////////////////////////////////////////////////////////////////////
  27.         //Note: This structure could hold any data for the link
  28.         //      For the time being it will store the necessary SO info to interface with the current SO system
  29.         struct TriangleLink
  30.         {
  31.                 TriangleID    startTriangleID;
  32.                 TriangleID    endTriangleID;
  33.                 OffMeshLinkID linkID;
  34.         };
  35.         //////////////////////////////////////////////////////////////////////////
  36.         //////////////////////////////////////////////////////////////////////////
  37.  
  38.         struct TileLinks
  39.         {
  40.                 TileLinks()
  41.                         : triangleLinks(NULL)
  42.                         , triangleLinkCount(0)
  43.                 {
  44.  
  45.                 }
  46.  
  47.                 ~TileLinks()
  48.                 {
  49.                         SAFE_DELETE_ARRAY(triangleLinks);
  50.                 }
  51.  
  52.                 void CopyLinks(TriangleLink* links, uint16 linkCount);
  53.  
  54.                 TriangleLink* triangleLinks;
  55.                 uint16        triangleLinkCount;
  56.         };
  57.  
  58. public:
  59.  
  60.         struct QueryLinksResult
  61.         {
  62.                 QueryLinksResult(const TriangleLink* _firstLink, uint16 _linkCount)
  63.                         : pFirstLink(_firstLink)
  64.                         , currentLink(0)
  65.                         , linkCount(_linkCount)
  66.                 {
  67.  
  68.                 }
  69.  
  70.                 WayTriangleData GetNextTriangle() const
  71.                 {
  72.                         if (currentLink < linkCount)
  73.                         {
  74.                                 currentLink++;
  75.                                 return WayTriangleData(pFirstLink[currentLink - 1].endTriangleID, pFirstLink[currentLink - 1].linkID);
  76.                         }
  77.  
  78.                         return WayTriangleData(0, 0);
  79.                 }
  80.  
  81.         private:
  82.                 const TriangleLink* pFirstLink;
  83.                 mutable uint16      currentLink;
  84.                 uint16              linkCount;
  85.         };
  86.  
  87. #if DEBUG_MNM_ENABLED
  88.         struct ProfileMemoryStats
  89.         {
  90.                 ProfileMemoryStats()
  91.                         : offMeshTileLinksMemory(0)
  92.                         , totalSize(0)
  93.                 {
  94.  
  95.                 }
  96.  
  97.                 size_t offMeshTileLinksMemory;
  98.                 size_t totalSize;
  99.         };
  100. #endif
  101.  
  102.         void             AddLink(NavigationMesh& navigationMesh, const TriangleID startTriangleID, const TriangleID endTriangleID, OffMeshLinkID& linkID);
  103.         void             RemoveLink(NavigationMesh& navigationMesh, const TriangleID boundTriangleID, const OffMeshLinkID linkID);
  104.         void             InvalidateLinks(const TileID tileID);
  105.  
  106.         QueryLinksResult GetLinksForTriangle(const TriangleID triangleID, const uint16 index) const;
  107.  
  108. #if DEBUG_MNM_ENABLED
  109.         ProfileMemoryStats GetMemoryStats(ICrySizer* pSizer) const;
  110. #endif
  111.  
  112. private:
  113.         typedef std::unordered_map<TileID, TileLinks, stl::hash_uint32> TTilesLinks;
  114.  
  115.         TTilesLinks          m_tilesLinks;
  116.  
  117.         static OffMeshLinkID s_linkIDGenerator;
  118. };
  119. }
  120.  
  121. #endif //__OFFMESH_LINKS_H__
  122.  
downloadOffGridLinks.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