54 return (a_coord.
x == b_coord.
x) && (a_coord.
y == b_coord.
y) && sameLayer;
59 while (ticksleft > 0) {
65 delete prioritySession;
71 const int32_t sessionId = prioritySession->
getSessionId();
76 delete prioritySession;
80 const int32_t sessionId = prioritySession->
getSessionId();
82 delete prioritySession;
103 if((*i) == sessionId) {
113 if((*i) == sessionId) {
150 if (!startCache || !endCache) {
161 bool multilayer = startCache != endCache;
165 if (startZone != endZone) {
169 const std::vector<Cell*>& neighbors = endCell->
getNeighbors();
170 for (std::vector<Cell*>::const_iterator it = neighbors.begin();
171 it != neighbors.end(); ++it) {
172 Zone* tmpZone = (*it)->getZone();
175 if (tmpZone == startZone) {
182 const std::vector<Cell*>& neighbors = startCell->
getNeighbors();
183 for (std::vector<Cell*>::const_iterator it = neighbors.begin();
184 it != neighbors.end(); ++it) {
185 Zone* tmpZone = (*it)->getZone();
187 if (tmpZone == startZone) {
200 if (startZone != endZone) {
208 bool sameAreas =
false;
210 std::list<std::string>::const_iterator area_it = areas.begin();
211 for (; area_it != areas.end(); ++area_it) {
218 const std::vector<Cell*>& neighbors = endCell->
getNeighbors();
219 if (neighbors.empty()) {
222 area_it = areas.begin();
223 for (; area_it != areas.end(); ++area_it) {
224 std::vector<Cell*>::const_iterator neigh_it = neighbors.begin();
225 for (; neigh_it != neighbors.end(); ++neigh_it) {
239 if (sessionId == -1) {
279 bool nextBlocker =
false;
296 std::vector<ModelCoordinate>::const_iterator nco_it = newCoords.begin();
297 for (; nco_it != newCoords.end(); ++nco_it) {
300 std::vector<ModelCoordinate>::const_iterator oco_it = oldCoords.begin();
301 for (; oco_it != oldCoords.end(); ++oco_it) {
302 if (*oco_it == *nco_it) {
339 double dx = (targetPos.
x - instancePos.
x) * nodeGrid->
getXScale();
340 double dy = (targetPos.
y - instancePos.
y) * nodeGrid->
getYScale();
350 if (speed > distance) {
363 double cell_dz = (targetPos.
z - prevPos.
z);
365 double cell_dx = (targetPos.
x - prevPos.
x);
366 double cell_dy = (targetPos.
y - prevPos.
y);
367 double cell_distance =
Mathd::Sqrt(cell_dx * cell_dx + cell_dy * cell_dy);
370 instancePos.
z = targetPos.
z;
372 instancePos.
z = prevPos.
z + cell_dz - 4*(0.5-distance/cell_distance)*(0.5-distance/cell_distance) * cell_dz;
374 }
else if (cell_dz < 0) {
376 instancePos.
z = prevPos.
z + 4*(0.5-distance/cell_distance)*(0.5-distance/cell_distance) * cell_dz;
380 instancePos.
x += (dx /
distance) * speed;
381 instancePos.
y += (dy /
distance) * speed;
418 if (cw && !multiCell &&
442 return "RoutePather";
int32_t m_nextFreeSessionId
The next free session id.
int32_t getAngleBetween(const Location &loc1, const Location &loc2)
Gets angle of vector defined by given locations.
void setLayerCoordinates(const ModelCoordinate &coordinates)
Sets "cell precise" layer coordinates to this location.
Layer * m_layer
target layer
bool locationsEqual(const Location &a, const Location &b)
Are two locations equivalent from the perspective of pathing (same layer coordinates and layer)...
Route * getRoute()
Returns the associated route for this search.
bool m_difflayer
is target on another layer
const Location & getPreviousNode()
Returns previous location.
const Location & getStartNode()
Returns the start location.
Layer * getLayer()
Returns the current layer.
bool walkToNextNode(int32_t step=1)
Changes the position on the path.
bool isCellInArea(const std::string &id, Cell *cell)
Returns true if cell is part of the area, otherwise false.
void setRouteStatus(RouteStatusInfo status)
Sets route status.
void setLayer(Layer *layer)
Sets layer where this location is pointing to.
A CellCache is an abstract depiction of one or a few layers and contains additional information...
bool solveRoute(Route *route, int32_t priority=MEDIUM_PRIORITY, bool immediate=false)
Solves the route to create a path.
void setMapCoordinates(const ExactModelCoordinate &coordinates)
Sets map coordinates to this location.
int32_t getSearchStatus() const
A small function which returns the current status of the search.
CellCache * getCellCache()
Returns the CellCache of this layer.
std::list< Location > Path
A path is a list with locations. Each location holds the coordinate for one cell. ...
const Location & getEndNode()
Returns the target location.
bool sessionIdValid(const int32_t sessionId)
Determines if the given session Id is valid.
void pushElement(const value_type &element)
Pushes a new element onto the queue.
bool invalidateSessionId(const int32_t sessionId)
Removes a session id from the session map.
MultiLayerSearch using A*.
SingleLayerSearch using A*.
Layer * getLayer() const
Gets the layer where this location is pointing to.
ModelCoordinate getLayerCoordinates() const
Gets cell precision layer coordinates set to this location.
const value_type getPriorityElement(void) const
Retrieves the element with the highest priority.
bool followRoute(const Location ¤t, Route *route, double speed, Location &nextLocation)
Follows the path of the route.
const double getZShift() const
Get the cellgrid z shift.
const std::list< std::string > getLimitedAreas()
int32_t makeSessionId()
Makes a new session id.
const double getYScale() const
Get the cellgrid y-scaling.
std::string getName() const
Returns name of the pathfinder.
void setRotation(int32_t rotation)
Sets the current rotation.
Simple class to hold the data for transistions.
static bool Equal(T _val1, T _val2)
bool isInCellCache(const Location &location) const
Checks whether the location is in CellCache range.
double getDefaultSpeedMultiplier()
Gets default speed for this CellCache.
Cell * getCell(const ModelCoordinate &mc)
Returns cell on this coordinate.
int32_t m_maxTicks
The maximum number of ticks allowed.
bool isZoneProtected()
Returns whether the zone on this cell is protected.
int32_t getSessionId() const
Retrieves the session id.
int32_t getSessionId()
Returns the session identifier.
const double getXScale() const
Get the cellgrid x-scaling.
void setCostId(const std::string &cost)
Sets cost identifier which should be used for pathfinding.
Point doublePt2intPt(DoublePoint pt)
Convert from 2D double point to 2D int32_t point.
virtual void calcPath()=0
Calculates final path.
virtual void updateSearch()=0
Updates the search.
RouteStatusInfo getRouteStatus()
Returns route status.
const std::vector< Cell * > & getNeighbors()
Returns the layer coordinates of this cell.
A basic cell on a CellCache.
std::pair< RoutePatherSearch *, int32_t > value_type
std::iterator_traits< octet_iterator >::difference_type distance(octet_iterator first, octet_iterator last)
CellGrid * getCellGrid() const
Get the Cellgrid.
bool getCellSpeedMultiplier(const ModelCoordinate &cell, double &multiplier)
Returns speed value from cell.
Route * createRoute(const Location &start, const Location &end, bool immediate=false, const std::string &costId="")
Creates a route between the start and end location that needs be solved.
bool cancelSession(const int32_t sessionId)
Cancels a session.
const ModelCoordinate getLayerCoordinates() const
Returns the layer coordinates of this cell.
Zone * getZone()
Returns zone.
Path getPath()
Returns the path.
void addSessionId(const int32_t sessionId)
Adds a session id to the session map.
void popElement(void)
Pops the element with the highest priority from the queue.
SessionList m_registeredSessionIds
A list of session ids that have been registered.
RoutePatherSearch using A*.
std::vector< ModelCoordinate > getOccupiedCells(int32_t rotation)
Returns relative coordinates for multi cell object based on rotation.
bool cellContainsBlockingInstance(const ModelCoordinate &cellCoordinate)
Determines if a given cell on the layer contains a blocking instance.
const Location & getCurrentNode()
Returns current location.
bool isMultiCell()
Gets if path is for a multi cell object.
int32_t getMaxTicks()
Returns maximal ticks (update steps) to solve routes.
void setEndNode(const Location &node)
Sets the target location.
int32_t getRotation()
Returns the current rotation.
TransitionInfo * getTransition()
Returns the transition.
SessionQueue m_sessions
A map of currently running sessions (searches).
bool empty(void) const
Determines whether the queue is currently empty.
void update()
Updates the route pather.
ExactModelCoordinate getExactLayerCoordinates() const
Gets exact layer coordinates set to this location.
virtual bool isAccessible(const ModelCoordinate &curpos, const ModelCoordinate &target)=0
Tells if given target point is accessible from curpos only cells adjacent to curpos are considered in...
bool m_immediate
use immediate
ExactModelCoordinate getMapCoordinates() const
Gets map coordinates set to this location.
void setMaxTicks(int32_t ticks)
Sets maximal ticks (update steps) to solve routes.
A Zone is an abstract depiction of a CellCache or of a part of it.
ModelCoordinate m_mc
target coordinates
void setSessionId(int32_t id)
Sets the session identifier.