diff options
| author | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
|---|---|---|
| committer | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
| commit | 3bf9df6b2785fa6d951086978a3e66f49427166a (patch) | |
| tree | 2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /game/server/ai_routedist.h | |
| download | archived-source-engine-2018-hl2-src-master.tar.xz archived-source-engine-2018-hl2-src-master.zip | |
Diffstat (limited to 'game/server/ai_routedist.h')
| -rw-r--r-- | game/server/ai_routedist.h | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/game/server/ai_routedist.h b/game/server/ai_routedist.h new file mode 100644 index 0000000..4820539 --- /dev/null +++ b/game/server/ai_routedist.h @@ -0,0 +1,61 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef AI_ROUTEDIST_H +#define AI_ROUTEDIST_H + +#include "ai_navtype.h" + +#if defined( _WIN32 ) +#pragma once +#endif + +// ---------------------------------------------------------------------------- +// Computes the route distance + route direction based on nav type +// FIXME: Where should this go? +// ---------------------------------------------------------------------------- +inline float ComputePathDistance( Navigation_t navType, const Vector &start, const Vector &end ) +{ + if (navType == NAV_GROUND) + { + return (end - start).Length2D(); + } + else + { + return (end - start).Length(); + } +} + +inline void ComputePathVector( Navigation_t navType, const Vector &start, const Vector &end, Vector *pDelta ) +{ + if (navType == NAV_GROUND) + { + Vector2DSubtract( end.AsVector2D(), start.AsVector2D(), pDelta->AsVector2D() ); + pDelta->z = 0.0f; + } + else + { + VectorSubtract( end, start, *pDelta ); + } +} + +inline float ComputePathDirection( Navigation_t navType, const Vector &start, const Vector &end, Vector *pDirection ) +{ + if (navType == NAV_GROUND) + { + VectorSubtract( end, start, *pDirection ); + pDirection->z = 0.0f; + return Vector2DNormalize( pDirection->AsVector2D() ); + } + else + { + VectorSubtract( end, start, *pDirection ); + return VectorNormalize( *pDirection ); + } +} + +#endif // AI_ROUTEDIST_H |