22#ifndef AGS_ROUTE_FINDER_JPS_H
23#define AGS_ROUTE_FINDER_JPS_H
25#include "common/std/queue.h"
26#include "common/std/vector.h"
27#include "common/std/algorithm.h"
28#include "common/std/functional.h"
29#include "common/std/xutility.h"
33#define INFINITY ((float)(1e+300 * 1e+300))
47 void Resize(
int width,
int height);
60 NavResult NavigateRefined(
int sx,
int sy,
int ex,
int ey,
std::vector<int> &opath,
65 bool TraceLine(
int srcx,
int srcy,
int targx,
int targy,
int &lastValidX,
int &lastValidY)
const;
66 bool TraceLine(
int srcx,
int srcy,
int targx,
int targy,
std::vector<int> *rpath =
nullptr)
const;
68 inline void SetMapRow(
int y,
const unsigned char *row) {
72 static int PackSquare(
int x,
int y);
73 static void UnpackSquare(
int sq,
int &x,
int &y);
83 inline Entry(
float ncost,
int nindex)
88 inline bool operator <(
const Entry &b)
const {
92 inline bool operator >(
const Entry &b)
const {
101 typedef unsigned short tFrameId;
119 static const float DIST_SCALE_PACK;
120 static const float DIST_SCALE_UNPACK;
144 inline bool Outside(
int x,
int y)
const;
146 bool Passable(
int x,
int y)
const;
148 inline bool Walkable(
int x,
int y)
const;
150 void AddPruned(
int *buf,
int &bcount,
int x,
int y)
const;
151 bool HasForcedNeighbor(
int x,
int y,
int dx,
int dy)
const;
152 int FindJump(
int x,
int y,
int dx,
int dy,
int ex,
int ey);
153 int FindOrthoJump(
int x,
int y,
int dx,
int dy,
int ex,
int ey);
156 bool Reachable(
int x0,
int y0,
int x1,
int y1)
const;
158 static inline int sign(
int n) {
159 return n < 0 ? -1 : (n > 0 ? 1 : 0);
162 static inline int iabs(
int n) {
163 return n < 0 ? -n : n;
166 static inline int iclamp(
int v,
int min,
int max) {
167 return v < min ? min : (v > max ? max : v);
170 static inline int ClosestDist(
int dx,
int dy) {
171 return dx * dx + dy * dy;
177inline int Navigation::PackSquare(
int x,
int y) {
178 return (y << 16) + x;
181inline void Navigation::UnpackSquare(
int sq,
int &x,
int &y) {
183 x = sq & ((1 << 16) - 1);
186inline bool Navigation::Outside(
int x,
int y)
const {
188 (
unsigned)x >= (unsigned)mapWidth ||
189 (
unsigned)y >= (unsigned)mapHeight;
192inline bool Navigation::Walkable(
int x,
int y)
const {
194 return map[y][x] != 0;
Definition: route_finder_jps.h:43