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.

53 lines
1.7 KiB

  1. //========= Copyright � 1996-2009, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: 2d plane routines for Fog of War
  4. //
  5. // $NoKeywords: $
  6. //=====================================================================================//
  7. #ifndef FOW_2DPLANE_H
  8. #define FOW_2DPLANE_H
  9. #if defined( COMPILER_MSVC )
  10. #pragma once
  11. #endif
  12. #include "mathlib/vector.h"
  13. class CFOW_2DPlane
  14. {
  15. public:
  16. CFOW_2DPlane( void ) { }
  17. // construct the plane from the given line segment
  18. CFOW_2DPlane( float bx, float by, float ex, float ey );
  19. // construct the plane from the given point and normal
  20. CFOW_2DPlane( float x, float y, Vector2D &vNormal );
  21. CFOW_2DPlane( float flDistance, Vector2D &vNormal );
  22. // init routine to generate the plane from the given line segment
  23. void Init( float bx, float by, float ex, float ey );
  24. // init routine to generate the plane from the given point and normal
  25. void Init( float x, float y, Vector2D &vNormal );
  26. // returns the normal of the plane
  27. inline Vector2D &GetNormal( void ) { return m_vNormal; }
  28. //
  29. inline float GetDistance( ) { return m_flDistance; }
  30. // returns true if the point is in front of the plane
  31. bool PointInFront( float px, float py );
  32. // returns the distance the point is from the plane
  33. float DistanceFrom( float px, float py );
  34. // finds the fraction from the starting point towards the normal along the line formed with ending point
  35. float DistanceFromLineStart( float bx, float by, float ex, float ey );
  36. // finds the fraction from the starting point towards the normal along the line formed with ending point
  37. float DistanceFromRay( float bx, float by, float dx, float dy );
  38. private:
  39. Vector2D m_vNormal; // the normal of the plane
  40. float m_flDistance; // the plane distance
  41. };
  42. #endif // FOW_2DPLANE_H