summaryrefslogtreecommitdiffhomepage
path: root/Opcode/Ice/IceOBB.h
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2022-01-30 17:44:05 +0100
committerAki <please@ignore.pl>2022-01-30 17:44:05 +0100
commitc01469dddabe404506ef3a64542e8423f9e11f2c (patch)
tree740f6e0e0811227a6e40aac51ba48057f1166b41 /Opcode/Ice/IceOBB.h
parent51657e10769faa2617d546a06c42e4c62a19bb50 (diff)
downloadstarshatter-c01469dddabe404506ef3a64542e8423f9e11f2c.zip
starshatter-c01469dddabe404506ef3a64542e8423f9e11f2c.tar.gz
starshatter-c01469dddabe404506ef3a64542e8423f9e11f2c.tar.bz2
Converted Opcode and Ice into unix newlines format
Diffstat (limited to 'Opcode/Ice/IceOBB.h')
-rw-r--r--Opcode/Ice/IceOBB.h354
1 files changed, 177 insertions, 177 deletions
diff --git a/Opcode/Ice/IceOBB.h b/Opcode/Ice/IceOBB.h
index 9c1711d..c55c2d5 100644
--- a/Opcode/Ice/IceOBB.h
+++ b/Opcode/Ice/IceOBB.h
@@ -1,177 +1,177 @@
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-/**
- * Contains OBB-related code. (oriented bounding box)
- * \file IceOBB.h
- * \author Pierre Terdiman
- * \date January, 13, 2000
- */
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// Include Guard
-#ifndef __ICEOBB_H__
-#define __ICEOBB_H__
-
- // Forward declarations
- class LSS;
-
- class ICEMATHS_API OBB
- {
- public:
- //! Constructor
- inline_ OBB() {}
- //! Constructor
- inline_ OBB(const IcePoint& center, const IcePoint& extents, const Matrix3x3& rot) : mCenter(center), mExtents(extents), mRot(rot) {}
- //! Destructor
- inline_ ~OBB() {}
-
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- /**
- * Setups an empty OBB.
- */
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- void SetEmpty()
- {
- mCenter.Zero();
- mExtents.Set(MIN_FLOAT, MIN_FLOAT, MIN_FLOAT);
- mRot.Identity();
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- /**
- * Tests if a IcePoint is contained within the OBB.
- * \param p [in] the world IcePoint to test
- * \return true if inside the OBB
- */
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- bool ContainsPoint(const IcePoint& p) const;
-
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- /**
- * Builds an OBB from an AABB and a world transform.
- * \param aabb [in] the aabb
- * \param mat [in] the world transform
- */
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- void Create(const AABB& aabb, const Matrix4x4& mat);
-
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- /**
- * Recomputes the OBB after an arbitrary transform by a 4x4 matrix.
- * \param mtx [in] the transform matrix
- * \param obb [out] the transformed OBB
- */
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- inline_ void Rotate(const Matrix4x4& mtx, OBB& obb) const
- {
- // The extents remain constant
- obb.mExtents = mExtents;
- // The center gets x-formed
- obb.mCenter = mCenter * mtx;
- // Combine rotations
- obb.mRot = mRot * Matrix3x3(mtx);
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- /**
- * Checks the OBB is valid.
- * \return true if the box is valid
- */
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- inline_ BOOL IsValid() const
- {
- // Consistency condition for (Center, Extents) boxes: Extents >= 0.0f
- if(mExtents.x < 0.0f) return FALSE;
- if(mExtents.y < 0.0f) return FALSE;
- if(mExtents.z < 0.0f) return FALSE;
- return TRUE;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- /**
- * Computes the obb planes.
- * \param planes [out] 6 box planes
- * \return true if success
- */
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- bool ComputePlanes(IcePlane* planes) const;
-
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- /**
- * Computes the obb points.
- * \param pts [out] 8 box points
- * \return true if success
- */
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- bool ComputePoints(IcePoint* pts) const;
-
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- /**
- * Computes vertex normals.
- * \param pts [out] 8 box points
- * \return true if success
- */
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- bool ComputeVertexNormals(IcePoint* pts) const;
-
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- /**
- * Returns edges.
- * \return 24 indices (12 edges) indexing the list returned by ComputePoints()
- */
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- const udword* GetEdges() const;
-
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- /**
- * Returns local edge normals.
- * \return edge normals in local space
- */
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- const IcePoint* GetLocalEdgeNormals() const;
-
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- /**
- * Returns world edge normal
- * \param edge_index [in] 0 <= edge index < 12
- * \param world_normal [out] edge normal in world space
- */
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- void ComputeWorldEdgeNormal(udword edge_index, IcePoint& world_normal) const;
-
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- /**
- * Computes an LSS surrounding the OBB.
- * \param lss [out] the LSS
- */
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- void ComputeLSS(LSS& lss) const;
-
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- /**
- * Checks the OBB is inside another OBB.
- * \param box [in] the other OBB
- * \return TRUE if we're inside the other box
- */
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- BOOL IsInside(const OBB& box) const;
-
- inline_ const IcePoint& GetCenter() const { return mCenter; }
- inline_ const IcePoint& GetExtents() const { return mExtents; }
- inline_ const Matrix3x3& GetRot() const { return mRot; }
-
- inline_ void GetRotatedExtents(Matrix3x3& extents) const
- {
- extents = mRot;
- extents.Scale(mExtents);
- }
-
- IcePoint mCenter; //!< B for Box
- IcePoint mExtents; //!< B for Bounding
- Matrix3x3 mRot; //!< O for Oriented
-
- // Orientation is stored in row-major format,
- // i.e. rows = eigen vectors of the covariance matrix
- };
-
-#endif // __ICEOBB_H__
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+/**
+ * Contains OBB-related code. (oriented bounding box)
+ * \file IceOBB.h
+ * \author Pierre Terdiman
+ * \date January, 13, 2000
+ */
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Guard
+#ifndef __ICEOBB_H__
+#define __ICEOBB_H__
+
+ // Forward declarations
+ class LSS;
+
+ class ICEMATHS_API OBB
+ {
+ public:
+ //! Constructor
+ inline_ OBB() {}
+ //! Constructor
+ inline_ OBB(const IcePoint& center, const IcePoint& extents, const Matrix3x3& rot) : mCenter(center), mExtents(extents), mRot(rot) {}
+ //! Destructor
+ inline_ ~OBB() {}
+
+ ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ /**
+ * Setups an empty OBB.
+ */
+ ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ void SetEmpty()
+ {
+ mCenter.Zero();
+ mExtents.Set(MIN_FLOAT, MIN_FLOAT, MIN_FLOAT);
+ mRot.Identity();
+ }
+
+ ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ /**
+ * Tests if a IcePoint is contained within the OBB.
+ * \param p [in] the world IcePoint to test
+ * \return true if inside the OBB
+ */
+ ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ bool ContainsPoint(const IcePoint& p) const;
+
+ ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ /**
+ * Builds an OBB from an AABB and a world transform.
+ * \param aabb [in] the aabb
+ * \param mat [in] the world transform
+ */
+ ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ void Create(const AABB& aabb, const Matrix4x4& mat);
+
+ ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ /**
+ * Recomputes the OBB after an arbitrary transform by a 4x4 matrix.
+ * \param mtx [in] the transform matrix
+ * \param obb [out] the transformed OBB
+ */
+ ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ inline_ void Rotate(const Matrix4x4& mtx, OBB& obb) const
+ {
+ // The extents remain constant
+ obb.mExtents = mExtents;
+ // The center gets x-formed
+ obb.mCenter = mCenter * mtx;
+ // Combine rotations
+ obb.mRot = mRot * Matrix3x3(mtx);
+ }
+
+ ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ /**
+ * Checks the OBB is valid.
+ * \return true if the box is valid
+ */
+ ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ inline_ BOOL IsValid() const
+ {
+ // Consistency condition for (Center, Extents) boxes: Extents >= 0.0f
+ if(mExtents.x < 0.0f) return FALSE;
+ if(mExtents.y < 0.0f) return FALSE;
+ if(mExtents.z < 0.0f) return FALSE;
+ return TRUE;
+ }
+
+ ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ /**
+ * Computes the obb planes.
+ * \param planes [out] 6 box planes
+ * \return true if success
+ */
+ ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ bool ComputePlanes(IcePlane* planes) const;
+
+ ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ /**
+ * Computes the obb points.
+ * \param pts [out] 8 box points
+ * \return true if success
+ */
+ ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ bool ComputePoints(IcePoint* pts) const;
+
+ ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ /**
+ * Computes vertex normals.
+ * \param pts [out] 8 box points
+ * \return true if success
+ */
+ ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ bool ComputeVertexNormals(IcePoint* pts) const;
+
+ ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ /**
+ * Returns edges.
+ * \return 24 indices (12 edges) indexing the list returned by ComputePoints()
+ */
+ ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ const udword* GetEdges() const;
+
+ ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ /**
+ * Returns local edge normals.
+ * \return edge normals in local space
+ */
+ ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ const IcePoint* GetLocalEdgeNormals() const;
+
+ ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ /**
+ * Returns world edge normal
+ * \param edge_index [in] 0 <= edge index < 12
+ * \param world_normal [out] edge normal in world space
+ */
+ ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ void ComputeWorldEdgeNormal(udword edge_index, IcePoint& world_normal) const;
+
+ ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ /**
+ * Computes an LSS surrounding the OBB.
+ * \param lss [out] the LSS
+ */
+ ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ void ComputeLSS(LSS& lss) const;
+
+ ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ /**
+ * Checks the OBB is inside another OBB.
+ * \param box [in] the other OBB
+ * \return TRUE if we're inside the other box
+ */
+ ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ BOOL IsInside(const OBB& box) const;
+
+ inline_ const IcePoint& GetCenter() const { return mCenter; }
+ inline_ const IcePoint& GetExtents() const { return mExtents; }
+ inline_ const Matrix3x3& GetRot() const { return mRot; }
+
+ inline_ void GetRotatedExtents(Matrix3x3& extents) const
+ {
+ extents = mRot;
+ extents.Scale(mExtents);
+ }
+
+ IcePoint mCenter; //!< B for Box
+ IcePoint mExtents; //!< B for Bounding
+ Matrix3x3 mRot; //!< O for Oriented
+
+ // Orientation is stored in row-major format,
+ // i.e. rows = eigen vectors of the covariance matrix
+ };
+
+#endif // __ICEOBB_H__