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.9 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: An axis aligned bounding box class.
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef BOUNDBOX_H
  8. #define BOUNDBOX_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "mathlib/vector.h"
  13. class BoundBox
  14. {
  15. public:
  16. BoundBox(void);
  17. BoundBox(const Vector &mins, const Vector &maxs);
  18. void ResetBounds(void);
  19. inline void SetBounds(const Vector &mins, const Vector &maxs);
  20. void UpdateBounds(const Vector& bmins, const Vector& bmaxs);
  21. void UpdateBounds(const Vector& pt);
  22. void UpdateBounds(const BoundBox *pBox);
  23. void GetBoundsCenter(Vector& ptdest);
  24. inline void GetBounds(Vector& Mins, Vector& Maxs) const;
  25. virtual bool IsIntersectingBox(const Vector& pfMins, const Vector& pfMaxs) const;
  26. bool IsInsideBox(const Vector& pfMins, const Vector& pfMaxs) const;
  27. bool ContainsPoint(const Vector& pt) const;
  28. bool IsValidBox(void) const;
  29. void GetBoundsSize(Vector& size);
  30. void SnapToGrid(int iGridSize);
  31. void Rotate90(int axis);
  32. Vector bmins;
  33. Vector bmaxs;
  34. };
  35. //-----------------------------------------------------------------------------
  36. // Purpose: Gets the bounding box as two vectors, a min and a max.
  37. // Input : Mins - Receives the box's minima.
  38. // Maxs - Receives the box's maxima.
  39. //-----------------------------------------------------------------------------
  40. void BoundBox::GetBounds(Vector &Mins, Vector &Maxs) const
  41. {
  42. Mins = bmins;
  43. Maxs = bmaxs;
  44. }
  45. //-----------------------------------------------------------------------------
  46. // Purpose: Sets the box outright, equivalent to ResetBounds + UpdateBounds.
  47. // Input : mins - Minima to set.
  48. // maxs - Maxima to set.
  49. //-----------------------------------------------------------------------------
  50. void BoundBox::SetBounds(const Vector &mins, const Vector &maxs)
  51. {
  52. bmins = mins;
  53. bmaxs = maxs;
  54. }
  55. #endif // BOUNDBOX_H