diff options
| author | Joe Ludwig <[email protected]> | 2013-06-26 15:22:04 -0700 |
|---|---|---|
| committer | Joe Ludwig <[email protected]> | 2013-06-26 15:22:04 -0700 |
| commit | 39ed87570bdb2f86969d4be821c94b722dc71179 (patch) | |
| tree | abc53757f75f40c80278e87650ea92808274aa59 /mp/src/utils/vbsp/boundbox.h | |
| download | source-sdk-2013-39ed87570bdb2f86969d4be821c94b722dc71179.tar.xz source-sdk-2013-39ed87570bdb2f86969d4be821c94b722dc71179.zip | |
First version of the SOurce SDK 2013
Diffstat (limited to 'mp/src/utils/vbsp/boundbox.h')
| -rw-r--r-- | mp/src/utils/vbsp/boundbox.h | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/mp/src/utils/vbsp/boundbox.h b/mp/src/utils/vbsp/boundbox.h new file mode 100644 index 00000000..c9838fe6 --- /dev/null +++ b/mp/src/utils/vbsp/boundbox.h @@ -0,0 +1,79 @@ +//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose: An axis aligned bounding box class.
+//
+// $NoKeywords: $
+//=============================================================================//
+
+#ifndef BOUNDBOX_H
+#define BOUNDBOX_H
+#ifdef _WIN32
+#pragma once
+#endif
+
+
+#include "mathlib/vector.h"
+
+#define COORD_NOTINIT ((float)(99999.0))
+
+enum
+{
+ AXIS_X = 0,
+ AXIS_Y,
+ AXIS_Z
+};
+
+class BoundBox
+{
+ public:
+
+ BoundBox(void);
+ BoundBox(const Vector &mins, const Vector &maxs);
+
+ void ResetBounds(void);
+ inline void SetBounds(const Vector &mins, const Vector &maxs);
+
+ void UpdateBounds(const Vector& bmins, const Vector& bmaxs);
+ void UpdateBounds(const Vector& pt);
+ void UpdateBounds(const BoundBox *pBox);
+ void GetBoundsCenter(Vector& ptdest);
+ inline void GetBounds(Vector& Mins, Vector& Maxs);
+
+ virtual bool IsIntersectingBox(const Vector& pfMins, const Vector& pfMaxs) const;
+ bool IsInsideBox(const Vector& pfMins, const Vector& pfMaxs) const;
+ bool ContainsPoint(const Vector& pt) const;
+ bool IsValidBox(void) const;
+ void GetBoundsSize(Vector& size);
+ void SnapToGrid(int iGridSize);
+ void Rotate90(int axis);
+
+ Vector bmins;
+ Vector bmaxs;
+};
+
+
+//-----------------------------------------------------------------------------
+// Purpose: Gets the bounding box as two vectors, a min and a max.
+// Input : Mins - Receives the box's minima.
+// Maxs - Receives the box's maxima.
+//-----------------------------------------------------------------------------
+void BoundBox::GetBounds(Vector &Mins, Vector &Maxs)
+{
+ Mins = bmins;
+ Maxs = bmaxs;
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose: Sets the box outright, equivalent to ResetBounds + UpdateBounds.
+// Input : mins - Minima to set.
+// maxs - Maxima to set.
+//-----------------------------------------------------------------------------
+void BoundBox::SetBounds(const Vector &mins, const Vector &maxs)
+{
+ bmins = mins;
+ bmaxs = maxs;
+}
+
+
+#endif // BOUNDBOX_H
|