Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
1.5 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef AI_ROUTEDIST_H
  8. #define AI_ROUTEDIST_H
  9. #include "ai_navtype.h"
  10. #if defined( _WIN32 )
  11. #pragma once
  12. #endif
  13. // ----------------------------------------------------------------------------
  14. // Computes the route distance + route direction based on nav type
  15. // FIXME: Where should this go?
  16. // ----------------------------------------------------------------------------
  17. inline float ComputePathDistance( Navigation_t navType, const Vector &start, const Vector &end )
  18. {
  19. if (navType == NAV_GROUND)
  20. {
  21. return (end - start).Length2D();
  22. }
  23. else
  24. {
  25. return (end - start).Length();
  26. }
  27. }
  28. inline void ComputePathVector( Navigation_t navType, const Vector &start, const Vector &end, Vector *pDelta )
  29. {
  30. if (navType == NAV_GROUND)
  31. {
  32. Vector2DSubtract( end.AsVector2D(), start.AsVector2D(), pDelta->AsVector2D() );
  33. pDelta->z = 0.0f;
  34. }
  35. else
  36. {
  37. VectorSubtract( end, start, *pDelta );
  38. }
  39. }
  40. inline float ComputePathDirection( Navigation_t navType, const Vector &start, const Vector &end, Vector *pDirection )
  41. {
  42. if (navType == NAV_GROUND || navType == NAV_CRAWL)
  43. {
  44. VectorSubtract( end, start, *pDirection );
  45. pDirection->z = 0.0f;
  46. return Vector2DNormalize( pDirection->AsVector2D() );
  47. }
  48. else
  49. {
  50. VectorSubtract( end, start, *pDirection );
  51. return VectorNormalize( *pDirection );
  52. }
  53. }
  54. #endif // AI_ROUTEDIST_H