From be1c7b0761c2de0362a47ecfff616a8931b54805 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?eray=20or=C3=A7unus?= Date: Sat, 10 Aug 2019 18:15:22 +0300 Subject: P.e.d.s. and fixes --- src/core/General.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/core/General.h') 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; } -- cgit v1.2.3