summaryrefslogtreecommitdiff
path: root/hammer/boundbox.h
diff options
context:
space:
mode:
authorFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
committerFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
commit3bf9df6b2785fa6d951086978a3e66f49427166a (patch)
tree2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /hammer/boundbox.h
downloadarchived-source-engine-2018-hl2-src-master.tar.xz
archived-source-engine-2018-hl2-src-master.zip
Diffstat (limited to 'hammer/boundbox.h')
-rw-r--r--hammer/boundbox.h71
1 files changed, 71 insertions, 0 deletions
diff --git a/hammer/boundbox.h b/hammer/boundbox.h
new file mode 100644
index 0000000..81ae360
--- /dev/null
+++ b/hammer/boundbox.h
@@ -0,0 +1,71 @@
+//========= 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"
+
+
+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