aboutsummaryrefslogtreecommitdiff
path: root/mp/src/game/server/ai_routedist.h
blob: 482053937237c44152f3d6c863342d29508e95d4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
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