BVB Source Codes

CRYENGINE Show CustomNavRegion.cpp Source code

Return Download CRYENGINE: download CustomNavRegion.cpp Source code - Download CRYENGINE Source code - Type:.cpp
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. #include "StdAfx.h"
  4.  
  5. #include "Navigation/CustomNavRegion.h"
  6. #include "Graph.h"
  7.  
  8. void CCustomNavRegion::Clear()
  9. {
  10.         // remove all smart object nodes
  11.         m_pGraph->DeleteGraph(IAISystem::NAV_CUSTOM_NAVIGATION);
  12. }
  13.  
  14. size_t CCustomNavRegion::MemStats()
  15. {
  16.         size_t size = sizeof(*this);
  17.         if (m_pGraph)
  18.                 size += m_pGraph->NodeMemStats(IAISystem::NAV_CUSTOM_NAVIGATION);
  19.         return size;
  20. }
  21.  
  22. void CCustomNavRegion::UglifyPath(
  23.   const VectorConstNodeIndices& inPath, TPathPoints& outPath,
  24.   const Vec3& startPos, const Vec3& startDir,
  25.   const Vec3& endPos, const Vec3& endDir)
  26. {
  27.         // markus: TODO: at least add all of the points. ideally use a callback for beautification
  28.         if (inPath.size() == 1)
  29.                 return;
  30.  
  31.         //AIAssert( inPath.size() == 2 );
  32.         const uint32 size = inPath.size();
  33.         for (uint32 i = 0; i < size; ++i)
  34.         {
  35.                 const GraphNode_CustomNav* node1 = static_cast<const GraphNode_CustomNav*>(m_pGraph->GetNodeManager().GetNode(inPath[i]));
  36.                 PathPointDescriptor pathPoint1(IAISystem::NAV_CUSTOM_NAVIGATION, node1->GetPos());
  37.                 outPath.push_back(pathPoint1);
  38.                 outPath.back().navTypeCustomId = node1->GetCustomId();
  39.         }
  40.         /*
  41.            const GraphNode_CustomNav *node1 = static_cast<const GraphNode_CustomNav*>(m_pGraph->GetNodeManager().GetNode(inPath[0]));
  42.            const GraphNode_CustomNav *node2 = static_cast<const GraphNode_CustomNav*>(m_pGraph->GetNodeManager().GetNode(inPath[1]));
  43.  
  44.            PathPointDescriptor pathPoint1( IAISystem::NAV_CUSTOM_NAVIGATION, node1->GetPos() );
  45.            outPath.push_back( pathPoint1 );
  46.            outPath.back().navTypeCustomId = node1->GetCustomId();
  47.            PathPointDescriptor pathPoint2( IAISystem::NAV_CUSTOM_NAVIGATION, node2->GetPos() );
  48.            outPath.push_back( pathPoint2 );
  49.            outPath.back().navTypeCustomId = node2->GetCustomId();
  50.          */
  51. }
  52.  
  53. float CCustomNavRegion::GetCustomLinkCostFactor(const GraphNode* nodes[2], const PathfindingHeuristicProperties& pathFindProperties) const
  54. {
  55.         float ret = 0.0f;
  56.  
  57.         if (nodes[0] && nodes[1])
  58.         {
  59.                 const GraphNode_CustomNav* node1 = static_cast<const GraphNode_CustomNav*>(nodes[0]);
  60.                 const GraphNode_CustomNav* node2 = static_cast<const GraphNode_CustomNav*>(nodes[1]);
  61.  
  62.                 ret = node1->CustomLinkCostFactor(node1->GetCustomData(), node2->GetCustomData(), pathFindProperties);
  63.         }
  64.  
  65.         return ret;
  66. }
  67.  
  68. uint32 CCustomNavRegion::CreateCustomNode(const Vec3& pos, void* customData, uint16 customId, SCustomNavData::CostFunction pCostFunction, bool linkWithEnclosing)
  69. {
  70.         uint32 nodeIndex = m_pGraph->CreateNewNode(IAISystem::NAV_CUSTOM_NAVIGATION, pos);
  71.         GraphNode* node = m_pGraph->GetNodeManager().GetNode(nodeIndex);
  72.  
  73.         GraphNode_CustomNav* pCustomNode = static_cast<GraphNode_CustomNav*>(node);
  74.  
  75.         pCustomNode->SetCustomId(customId);
  76.         pCustomNode->SetCustomData(customData);
  77.         pCustomNode->SetCostFunction(pCostFunction);
  78.  
  79.         return nodeIndex;
  80. }
  81.  
  82. void CCustomNavRegion::RemoveNode(uint32 nodeIndex)
  83. {
  84.         assert(m_pGraph->GetNode(nodeIndex)->navType == IAISystem::NAV_CUSTOM_NAVIGATION);
  85.         m_pGraph->Disconnect(nodeIndex, true);
  86. };
  87.  
  88. void CCustomNavRegion::LinkCustomNodes(uint32 node1Index, uint32 node2Index, float radius1To2, float radius2To1)
  89. {
  90.         m_pGraph->Connect(node1Index, node2Index, radius1To2, radius2To1);
  91. }
  92.  
downloadCustomNavRegion.cpp 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