BVB Source Codes

CRYENGINE Show IslandConnections.h Source code

Return Download CRYENGINE: download IslandConnections.h Source code - Download CRYENGINE Source code - Type:.h
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. #ifndef __IslandConnections_h__
  4. #define __IslandConnections_h__
  5.  
  6. #pragma once
  7.  
  8. #include "MNM.h"
  9. #include "OpenList.h"
  10.  
  11. namespace MNM
  12. {
  13. struct OffMeshNavigation;
  14.  
  15. class IslandConnections
  16. {
  17. public:
  18.         typedef stl::STLPoolAllocator<MNM::GlobalIslandID, stl::PoolAllocatorSynchronizationSinglethreaded> TIslandsWayAllocator;
  19.         typedef std::list<MNM::GlobalIslandID, TIslandsWayAllocator>                                        TIslandsWay;
  20.  
  21.         struct Link
  22.         {
  23.                 Link(const MNM::TriangleID _toTriangleID, const MNM::OffMeshLinkID _offMeshLinkID, const MNM::GlobalIslandID _toIsland, uint32 _objectIDThatCreatesTheConnection)
  24.                         : toTriangleID(_toTriangleID)
  25.                         , offMeshLinkID(_offMeshLinkID)
  26.                         , toIsland(_toIsland)
  27.                         , objectIDThatCreatesTheConnection(_objectIDThatCreatesTheConnection)
  28.                 {
  29.                 }
  30.  
  31.                 inline bool operator==(const Link& rhs) const
  32.                 {
  33.                         return toIsland == rhs.toIsland && toTriangleID == rhs.toTriangleID && offMeshLinkID == rhs.offMeshLinkID &&
  34.                                objectIDThatCreatesTheConnection == rhs.objectIDThatCreatesTheConnection;
  35.                 }
  36.  
  37.                 MNM::TriangleID     toTriangleID;
  38.                 MNM::OffMeshLinkID  offMeshLinkID;
  39.                 MNM::GlobalIslandID toIsland;
  40.                 uint32              objectIDThatCreatesTheConnection;
  41.         };
  42.  
  43.         IslandConnections() {}
  44.  
  45.         void Reset();
  46.  
  47.         void SetOneWayConnectionBetweenIsland(const MNM::GlobalIslandID fromIsland, const Link& link);
  48.         void RemoveOneWayConnectionBetweenIsland(const MNM::GlobalIslandID fromIsland, const Link& link);
  49.         void RemoveAllIslandConnectionsForObject(const NavigationMeshID& meshID, const uint32 objectId);
  50.  
  51.         bool CanNavigateBetweenIslands(const IEntity* pEntityToTestOffGridLinks, const MNM::GlobalIslandID fromIsland, const MNM::GlobalIslandID toIsland, TIslandsWay& way) const;
  52.  
  53. #ifdef CRYAISYSTEM_DEBUG
  54.         void DebugDraw() const;
  55. #endif
  56.  
  57. private:
  58.  
  59.         struct IslandNode
  60.         {
  61.                 IslandNode()
  62.                         : id(MNM::Constants::eGlobalIsland_InvalidIslandID)
  63.                         , cost(.0f)
  64.                 {}
  65.  
  66.                 IslandNode(const MNM::GlobalIslandID _id, const float _cost)
  67.                         : id(_id)
  68.                         , cost(_cost)
  69.                 {}
  70.  
  71.                 IslandNode(const IslandNode& other)
  72.                         : id(other.id)
  73.                         , cost(other.cost)
  74.                 {}
  75.  
  76.                 ILINE void operator=(const IslandNode& other)
  77.                 {
  78.                         id = other.id;
  79.                         cost = other.cost;
  80.                 }
  81.  
  82.                 ILINE bool operator<(const IslandNode& other) const
  83.                 {
  84.                         return id < other.id;
  85.                 }
  86.  
  87.                 ILINE bool operator==(const IslandNode& other) const
  88.                 {
  89.                         return id == other.id;
  90.                 }
  91.  
  92.                 MNM::GlobalIslandID id;
  93.                 float               cost;
  94.         };
  95.  
  96.         struct IsNodeLessCostlyPredicate
  97.         {
  98.                 bool operator()(const IslandNode& firstNode, const IslandNode& secondNode) { return firstNode.cost < secondNode.cost; }
  99.         };
  100.  
  101.         typedef OpenList<IslandNode, IsNodeLessCostlyPredicate>                                    IslandOpenList;
  102.  
  103.         typedef stl::STLPoolAllocator<std::pair<const IslandNode, IslandNode>, stl::PoolAllocatorSynchronizationSinglethreaded> TCameFromMapAllocator;
  104.         typedef std::map<IslandNode, IslandNode, std::less<IslandNode>, TCameFromMapAllocator>     TCameFromMap;
  105.         typedef std::vector<MNM::GlobalIslandID>                                                   TIslandClosedSet;
  106.  
  107.         void ReconstructWay(const TCameFromMap& cameFromMap, const MNM::GlobalIslandID fromIsland, const MNM::GlobalIslandID toIsland, TIslandsWay& way) const;
  108.  
  109.         typedef std::vector<Link>                           TLinksVector;
  110.         typedef std::map<MNM::GlobalIslandID, TLinksVector> TIslandConnectionsMap;
  111.         TIslandConnectionsMap m_islandConnections;
  112. };
  113. }
  114.  
  115. #endif // __IslandConnectionsManager_h__
  116.  
downloadIslandConnections.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