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.

71 lines
1.6 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #include "cbase.h"
  8. #include "game.h"
  9. #include "cplane.h"
  10. // memdbgon must be the last include file in a .cpp file!!!
  11. #include "tier0/memdbgon.h"
  12. //=========================================================
  13. // Plane
  14. //=========================================================
  15. CPlane::CPlane ( void )
  16. {
  17. m_fInitialized = FALSE;
  18. }
  19. //=========================================================
  20. // InitializePlane - Takes a normal for the plane and a
  21. // point on the plane and
  22. //=========================================================
  23. void CPlane::InitializePlane ( const Vector &vecNormal, const Vector &vecPoint )
  24. {
  25. m_vecNormal = vecNormal;
  26. m_flDist = DotProduct ( m_vecNormal, vecPoint );
  27. m_fInitialized = TRUE;
  28. }
  29. //=========================================================
  30. // PointInFront - determines whether the given vector is
  31. // in front of the plane.
  32. //=========================================================
  33. bool CPlane::PointInFront ( const Vector &vecPoint )
  34. {
  35. float flFace;
  36. if ( !m_fInitialized )
  37. {
  38. return FALSE;
  39. }
  40. flFace = DotProduct ( m_vecNormal, vecPoint ) - m_flDist;
  41. if ( flFace >= 0 )
  42. {
  43. return TRUE;
  44. }
  45. return FALSE;
  46. }
  47. //=========================================================
  48. //=========================================================
  49. float CPlane::PointDist ( const Vector &vecPoint )
  50. {
  51. float flDist;
  52. if ( !m_fInitialized )
  53. {
  54. return FALSE;
  55. }
  56. flDist = DotProduct ( m_vecNormal, vecPoint ) - m_flDist;
  57. return flDist;
  58. }