diff options
| author | Joe Ludwig <[email protected]> | 2013-06-26 15:22:04 -0700 |
|---|---|---|
| committer | Joe Ludwig <[email protected]> | 2013-06-26 15:22:04 -0700 |
| commit | 39ed87570bdb2f86969d4be821c94b722dc71179 (patch) | |
| tree | abc53757f75f40c80278e87650ea92808274aa59 /mp/src/game/server/ai_routedist.h | |
| download | source-sdk-2013-39ed87570bdb2f86969d4be821c94b722dc71179.tar.xz source-sdk-2013-39ed87570bdb2f86969d4be821c94b722dc71179.zip | |
First version of the SOurce SDK 2013
Diffstat (limited to 'mp/src/game/server/ai_routedist.h')
| -rw-r--r-- | mp/src/game/server/ai_routedist.h | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/mp/src/game/server/ai_routedist.h b/mp/src/game/server/ai_routedist.h new file mode 100644 index 00000000..cf929858 --- /dev/null +++ b/mp/src/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
|