Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
NavigationMap Class Reference

#include <CollisionMap.h>

Classes

struct  PathNode
 

Public Member Functions

void Initialize (int width, int height, GridProjectionType projection, float tileWidth, float tileHeight, int numLayers=1)
 
void SetActiveLayer (CollisionLayer layer)
 
CollisionLayer GetActiveLayer () const
 
void SetNavigable (int x, int y, bool isNavigable, float cost=1.0f)
 
bool IsNavigable (int x, int y) const
 
float GetTraversalCost (int x, int y) const
 
bool IsNavigable (int x, int y, CollisionLayer layer) const
 
float GetTraversalCost (int x, int y, CollisionLayer layer) const
 
void WorldToGrid (float worldX, float worldY, int &outGridX, int &outGridY) const
 
void GridToWorld (int gridX, int gridY, float &outWorldX, float &outWorldY) const
 
bool IsValidGridPosition (int x, int y) const
 
int GetWidth () const
 
int GetHeight () const
 
GridProjectionType GetProjection () const
 
bool FindPath (int startX, int startY, int goalX, int goalY, std::vector< Vector > &outPath, CollisionLayer layer=CollisionLayer::Ground, int maxIterations=10000)
 
bool GetRandomNavigablePoint (float centerX, float centerY, float radius, int maxAttempts, float &outX, float &outY, CollisionLayer layer=CollisionLayer::Ground) const
 
void Clear ()
 
 NavigationMap ()=default
 
 ~NavigationMap ()=default
 
 NavigationMap (const NavigationMap &)=delete
 
NavigationMapoperator= (const NavigationMap &)=delete
 
float Heuristic (int x1, int y1, int x2, int y2) const
 
void GetNeighbors (int x, int y, std::vector< std::pair< int, int > > &outNeighbors) const
 

Static Public Member Functions

static NavigationMapGet ()
 

Public Attributes

int m_width = 0
 
int m_height = 0
 
GridProjectionType m_projection = GridProjectionType::Ortho
 
float m_tileWidth = 32.0f
 
float m_tileHeight = 32.0f
 
CollisionLayer m_activeLayer = CollisionLayer::Ground
 
int m_numLayers = 1
 

Detailed Description

Definition at line 190 of file CollisionMap.h.

Constructor & Destructor Documentation

◆ NavigationMap() [1/2]

NavigationMap::NavigationMap ( )
default

◆ ~NavigationMap()

NavigationMap::~NavigationMap ( )
default

◆ NavigationMap() [2/2]

NavigationMap::NavigationMap ( const NavigationMap )
delete

Member Function Documentation

◆ Clear()

void NavigationMap::Clear ( )

Definition at line 663 of file CollisionMap.cpp.

References Ground, m_activeLayer, m_height, m_numLayers, and m_width.

◆ FindPath()

bool NavigationMap::FindPath ( int  startX,
int  startY,
int  goalX,
int  goalY,
std::vector< Vector > &  outPath,
CollisionLayer  layer = CollisionLayer::Ground,
int  maxIterations = 10000 
)

◆ Get()

static NavigationMap & NavigationMap::Get ( )
inlinestatic

Definition at line 193 of file CollisionMap.h.

References GetComponentTypeID_Static().

Referenced by ExecuteBTAction(), World::GenerateCollisionAndNavigationMaps(), and NavigationSystem::RequestPath().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetActiveLayer()

CollisionLayer NavigationMap::GetActiveLayer ( ) const
inline

Definition at line 205 of file CollisionMap.h.

References m_activeLayer.

◆ GetHeight()

int NavigationMap::GetHeight ( ) const
inline

Definition at line 225 of file CollisionMap.h.

References m_height.

◆ GetNeighbors()

void NavigationMap::GetNeighbors ( int  x,
int  y,
std::vector< std::pair< int, int > > &  outNeighbors 
) const

Definition at line 461 of file CollisionMap.cpp.

References GetComponentTypeID_Static(), HexAxial, Iso, m_projection, and Ortho.

Referenced by FindPath().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetProjection()

GridProjectionType NavigationMap::GetProjection ( ) const
inline

Definition at line 226 of file CollisionMap.h.

References m_projection.

◆ GetRandomNavigablePoint()

bool NavigationMap::GetRandomNavigablePoint ( float  centerX,
float  centerY,
float  radius,
int  maxAttempts,
float outX,
float outY,
CollisionLayer  layer = CollisionLayer::Ground 
) const

Definition at line 671 of file CollisionMap.cpp.

References GetComponentTypeID_Static(), IsNavigable(), IsValidGridPosition(), and WorldToGrid().

Referenced by ExecuteBTAction().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetTraversalCost() [1/2]

float NavigationMap::GetTraversalCost ( int  x,
int  y 
) const

Definition at line 394 of file CollisionMap.cpp.

References GetTraversalCost(), and m_activeLayer.

Referenced by FindPath(), and GetTraversalCost().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetTraversalCost() [2/2]

float NavigationMap::GetTraversalCost ( int  x,
int  y,
CollisionLayer  layer 
) const

Definition at line 410 of file CollisionMap.cpp.

References CollisionMap::Get(), GetComponentTypeID_Static(), and TileProperties::traversalCost.

+ Here is the call graph for this function:

◆ GetWidth()

int NavigationMap::GetWidth ( ) const
inline

Definition at line 224 of file CollisionMap.h.

References m_width.

◆ GridToWorld()

void NavigationMap::GridToWorld ( int  gridX,
int  gridY,
float outWorldX,
float outWorldY 
) const

Definition at line 426 of file CollisionMap.cpp.

References CollisionMap::Get(), GetComponentTypeID_Static(), and CollisionMap::GridToWorld().

Referenced by FindPath().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Heuristic()

float NavigationMap::Heuristic ( int  x1,
int  y1,
int  x2,
int  y2 
) const

Definition at line 436 of file CollisionMap.cpp.

References GetComponentTypeID_Static(), HexAxial, Iso, m_projection, and Ortho.

Referenced by FindPath().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Initialize()

void NavigationMap::Initialize ( int  width,
int  height,
GridProjectionType  projection,
float  tileWidth,
float  tileHeight,
int  numLayers = 1 
)

Definition at line 350 of file CollisionMap.cpp.

References GetComponentTypeID_Static(), Ground, m_activeLayer, m_height, m_numLayers, m_projection, m_tileHeight, m_tileWidth, m_width, and SYSTEM_LOG.

+ Here is the call graph for this function:

◆ IsNavigable() [1/2]

bool NavigationMap::IsNavigable ( int  x,
int  y 
) const

Definition at line 389 of file CollisionMap.cpp.

References IsNavigable(), and m_activeLayer.

Referenced by FindPath(), GetRandomNavigablePoint(), and IsNavigable().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IsNavigable() [2/2]

bool NavigationMap::IsNavigable ( int  x,
int  y,
CollisionLayer  layer 
) const

Definition at line 399 of file CollisionMap.cpp.

References CollisionMap::Get(), GetComponentTypeID_Static(), and TileProperties::isNavigable.

+ Here is the call graph for this function:

◆ IsValidGridPosition()

bool NavigationMap::IsValidGridPosition ( int  x,
int  y 
) const

Definition at line 431 of file CollisionMap.cpp.

References GetComponentTypeID_Static(), and m_height.

Referenced by FindPath(), and GetRandomNavigablePoint().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator=()

NavigationMap & NavigationMap::operator= ( const NavigationMap )
delete

◆ SetActiveLayer()

void NavigationMap::SetActiveLayer ( CollisionLayer  layer)

Definition at line 369 of file CollisionMap.cpp.

References m_activeLayer, and m_numLayers.

◆ SetNavigable()

void NavigationMap::SetNavigable ( int  x,
int  y,
bool  isNavigable,
float  cost = 1.0f 
)

Definition at line 377 of file CollisionMap.cpp.

References CollisionMap::Get(), GetComponentTypeID_Static(), TileProperties::isNavigable, and m_activeLayer.

+ Here is the call graph for this function:

◆ WorldToGrid()

void NavigationMap::WorldToGrid ( float  worldX,
float  worldY,
int outGridX,
int outGridY 
) const

Definition at line 421 of file CollisionMap.cpp.

References CollisionMap::Get(), GetComponentTypeID_Static(), and CollisionMap::WorldToGrid().

Referenced by GetRandomNavigablePoint().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_activeLayer

CollisionLayer NavigationMap::m_activeLayer = CollisionLayer::Ground

◆ m_height

int NavigationMap::m_height = 0

Definition at line 262 of file CollisionMap.h.

Referenced by Clear(), GetHeight(), Initialize(), and IsValidGridPosition().

◆ m_numLayers

int NavigationMap::m_numLayers = 1

Definition at line 267 of file CollisionMap.h.

Referenced by Clear(), Initialize(), and SetActiveLayer().

◆ m_projection

GridProjectionType NavigationMap::m_projection = GridProjectionType::Ortho

Definition at line 263 of file CollisionMap.h.

Referenced by GetNeighbors(), GetProjection(), Heuristic(), and Initialize().

◆ m_tileHeight

float NavigationMap::m_tileHeight = 32.0f

Definition at line 265 of file CollisionMap.h.

Referenced by Initialize().

◆ m_tileWidth

float NavigationMap::m_tileWidth = 32.0f

Definition at line 264 of file CollisionMap.h.

Referenced by Initialize().

◆ m_width

int NavigationMap::m_width = 0

Definition at line 261 of file CollisionMap.h.

Referenced by Clear(), FindPath(), GetWidth(), and Initialize().


The documentation for this class was generated from the following files: