BVB Source Codes

CRYENGINE Show NavRegion.h Source code

Return Download CRYENGINE: download NavRegion.h Source code - Download CRYENGINE Source code - Type:.h
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. #ifndef NAVREGION_H
  4. #define NAVREGION_H
  5.  
  6. #if _MSC_VER > 1000
  7.         #pragma once
  8. #endif
  9.  
  10. #include "Graph.h"
  11. #include "NavPath.h"
  12. #include <CryNetwork/SerializeFwd.h>
  13.  
  14. struct AgentMovementAbility;
  15.  
  16. /// Enforce a standard interface on the different types of navigation region
  17. class CNavRegion
  18. {
  19. public:
  20.         CNavRegion() {}
  21.         virtual ~CNavRegion() {}
  22.  
  23.         /// Beautify the path passed in, returning the result in outPath. This code
  24.         /// should assume that this is the whole path (at some point paths will transition
  25.         /// between regions, but then beautification will be hidden by the caller). start and end
  26.         /// directions should just be taken as hints.
  27.         virtual void BeautifyPath(
  28.           const VectorConstNodeIndices& inPath, TPathPoints& outPath,
  29.           const Vec3& startPos, const Vec3& startDir,
  30.           const Vec3& endPos, const Vec3& endDir,
  31.           float radius,
  32.           const AgentMovementAbility& movementAbility,
  33.           const NavigationBlockers& navigationBlockers) = 0;
  34.  
  35.         /// As BeautifyPath, but this should return the "raw", unbeautified path
  36.         virtual void UglifyPath(const VectorConstNodeIndices& inPath, TPathPoints& outPath,
  37.                                 const Vec3& startPos, const Vec3& startDir,
  38.                                 const Vec3& endPos, const Vec3& endDir) = 0;
  39.  
  40.         /// Should return the graph node containing pos, using pStart as a hint as to
  41.         /// where to start looking. If no node can be found then do an approximate search
  42.         /// by extending the internal area/volume representation by range, and return the
  43.         /// closest position that is valid for the returned graph node. If returnSuspect
  44.         /// then a node may be returned even if it may not be reachable.
  45.         /// If there are a number of nodes that could be returned, only nodes that have at least one
  46.         /// link with radius > passRadius will be returned. Range determines the search range for
  47.         /// the enclosing node: (range < 0) indicates a default search radius will be used
  48.         /// determined by the navigation type. (range >= 0) will be taken into account
  49.         /// depending on the navigation type.
  50.         virtual unsigned GetEnclosing(const Vec3& pos, float passRadius = 0.0f, unsigned startIndex = 0,
  51.                                       float range = -1.0f, Vec3* closestValid = 0, bool returnSuspect = false, const char* requesterName = "", bool omitWalkabilityTest = false) = 0;
  52.  
  53.         /// Should restore its original state
  54.         virtual void Clear() = 0;
  55.  
  56.         /// Gets called on enter/exit etc from game mode - i.e. opportunity to clear/reset any dynamic updating
  57.         /// data.
  58.         virtual void Reset(IAISystem::EResetReason reason) {};
  59.  
  60.         /// Serialise the _modifications_ since load-time
  61.         virtual void Serialize(TSerialize ser) = 0;
  62.  
  63.         /// Attempt a straight path up to a maximum cost of maxCost between start and end,
  64.         /// putting the result in pathOut. The estimated cost of the path is also returned,
  65.         /// the estimate being made using the heuristic. Returning < 0 or an empty pathOut
  66.         /// means no path could be found
  67.         virtual float AttemptStraightPath(TPathPoints& pathOut,
  68.                                           CAStarSolver* m_pAStarSolver,
  69.                                           const CHeuristic* pHeuristic,
  70.                                           const Vec3& start, const Vec3& end,
  71.                                           unsigned startHintIndex,
  72.                                           float maxCost,
  73.                                           const NavigationBlockers& navigationBlockers,
  74.                                           bool returnPartialPath)
  75.         {
  76.                 return -1.0f;
  77.         }
  78.  
  79.         /// Indicate if it's possible to go in a straight line from from to to according to the properties of the nav region.
  80.         /// The navigation blockers should be considered impassable.
  81.         virtual bool CheckPassability(const Vec3& from, const Vec3& to, float radius, const NavigationBlockers& navigationBlockers, IAISystem::tNavCapMask) const
  82.         {
  83.                 return true;
  84.         }
  85.  
  86.         /// Populates points with the path points needed to go from startPos to endPos, both of which fall within pNode and returns
  87.         /// true if possible. Default implementation uses CheckPassability
  88.         virtual bool GetSingleNodePath(const GraphNode* pNode, const Vec3& startPos, const Vec3& endPos, float radius,
  89.                                        const NavigationBlockers& navigationBlockers, std::vector<PathPointDescriptor>& points,
  90.                                        IAISystem::tNavCapMask navCaps) const
  91.         {
  92.                 points.push_back(PathPointDescriptor(pNode->navType, startPos));
  93.                 if (!CheckPassability(startPos, endPos, radius, navigationBlockers, navCaps))
  94.                         points.push_back(PathPointDescriptor(pNode->navType, pNode->GetPos()));
  95.                 points.push_back(PathPointDescriptor(pNode->navType, endPos));
  96.                 return true;
  97.         }
  98.  
  99.         /// Should return a position "near" to curPos that is suitable as a location to teleport
  100.         /// from curPos to.
  101.         /// if successful returns true and teleportPos, if not returns false and
  102.         /// teleportPos is set to ZERO
  103.         /// requesterName is just for debug
  104.         virtual bool GetTeleportPosition(const Vec3& curPos, Vec3& teleportPos, const char* requesterName) { return false; }
  105.  
  106.         /// Allow for some periodic updating
  107.         virtual void Update(class CCalculationStopper& stopper) {}
  108.  
  109.         /// Gets called when a node has been created (i.e. the region may choose to connect
  110.         /// the node somewhere automatically)
  111.         virtual void NodeCreated(unsigned nodeIndex) {}
  112.  
  113.         /// Called just after a node has been moved
  114.         virtual void NodeMoved(unsigned nodeIndex) {}
  115.  
  116.         /// This gets called just _before_ the node is going to be deleted. Don't delete/destroy it
  117.         /// during this call!!!
  118.         virtual void NodeAboutToBeDeleted(GraphNode* pNode) {}
  119.  
  120.         /// Will get called when the mission has finished loaded (so all nav regions etc are created)
  121.         virtual void OnMissionLoaded() {};
  122.  
  123.         /// Should return the memory usage in bytes
  124.         virtual size_t MemStats() = 0;
  125. };
  126.  
  127. #endif
  128.  
downloadNavRegion.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