summaryrefslogtreecommitdiff
path: root/src/core/General.h
diff options
context:
space:
mode:
authoraap <aap@papnet.eu>2019-08-11 22:14:25 +0200
committerGitHub <noreply@github.com>2019-08-11 22:14:25 +0200
commitc17bbc62f592270b6a1cac323223689603a6120f (patch)
tree2f0c6d7eac06333b4f04eb3002700e4c3d067f34 /src/core/General.h
parent0bd681abc514d5a3627edea40b24347696ac8908 (diff)
parentbe1c7b0761c2de0362a47ecfff616a8931b54805 (diff)
Merge pull request #185 from erorcun/erorcun
P.e.d.s. and fixes
Diffstat (limited to 'src/core/General.h')
-rw-r--r--src/core/General.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/core/General.h b/src/core/General.h
index fe277689..12f781d4 100644
--- a/src/core/General.h
+++ b/src/core/General.h
@@ -96,6 +96,21 @@ public:
}
}
+ // should return direction in 0-8 range. fits perfectly to peds' path directions.
+ static int CGeneral::GetNodeHeadingFromVector(float x, float y)
+ {
+ float angle = CGeneral::GetRadianAngleBetweenPoints(x, y, 0.0f, 0.0f);
+ if (angle < 0.0f)
+ angle += TWOPI;
+
+ angle = DEGTORAD(22.5f) + TWOPI - angle;
+
+ if (angle >= TWOPI)
+ angle -= TWOPI;
+
+ return (int)floorf(angle / DEGTORAD(45.0f));
+ }
+
// not too sure about all these...
static uint16 GetRandomNumber(void)
{ return myrand() & MYRAND_MAX; }