summaryrefslogtreecommitdiffhomepage
path: root/third-party/Opcode/Ice/IceLSS.h
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2024-03-12 22:07:03 +0100
committerAki <please@ignore.pl>2024-03-12 22:07:36 +0100
commit81bb6873f1c0291fecbf6e429ad15ac3db66a4c0 (patch)
treefd7552ecabeeffb45a1fbe3730ab62bc7a64dd85 /third-party/Opcode/Ice/IceLSS.h
parentf43d32d6d2cc7ecd04f4f06f20d5a6fc2c87c9ae (diff)
downloadstarshatter-81bb6873f1c0291fecbf6e429ad15ac3db66a4c0.zip
starshatter-81bb6873f1c0291fecbf6e429ad15ac3db66a4c0.tar.gz
starshatter-81bb6873f1c0291fecbf6e429ad15ac3db66a4c0.tar.bz2
Legal notices updated
Rename contrib -> third-party intendes to express the origin and purpose of that part of the code better. I plan to readd contrib/ again but with more in-project things like bash-completions, dev workflow scripts etc.
Diffstat (limited to 'third-party/Opcode/Ice/IceLSS.h')
-rw-r--r--third-party/Opcode/Ice/IceLSS.h75
1 files changed, 75 insertions, 0 deletions
diff --git a/third-party/Opcode/Ice/IceLSS.h b/third-party/Opcode/Ice/IceLSS.h
new file mode 100644
index 0000000..e4c9ef8
--- /dev/null
+++ b/third-party/Opcode/Ice/IceLSS.h
@@ -0,0 +1,75 @@
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+/**
+ * Contains code for line-swept spheres.
+ * \file IceLSS.h
+ * \author Pierre Terdiman
+ * \date April, 4, 2000
+ */
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Guard
+#ifndef __ICELSS_H__
+#define __ICELSS_H__
+
+ class ICEMATHS_API LSS : public IceSegment
+ {
+ public:
+ //! Constructor
+ inline_ LSS() {}
+ //! Constructor
+ inline_ LSS(const IceSegment& seg, float radius) : IceSegment(seg), mRadius(radius) {}
+ //! Destructor
+ inline_ ~LSS() {}
+
+ ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ /**
+ * Computes an OBB surrounding the LSS.
+ * \param box [out] the OBB
+ */
+ ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ void ComputeOBB(OBB& box);
+
+ ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ /**
+ * Tests if a IcePoint is contained within the LSS.
+ * \param pt [in] the IcePoint to test
+ * \return true if inside the LSS
+ * \warning IcePoint and LSS must be in same space
+ */
+ ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ inline_ bool Contains(const IcePoint& pt) const { return SquareDistance(pt) <= mRadius*mRadius; }
+
+ ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ /**
+ * Tests if a sphere is contained within the LSS.
+ * \param sphere [in] the sphere to test
+ * \return true if inside the LSS
+ * \warning sphere and LSS must be in same space
+ */
+ ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ inline_ bool Contains(const Sphere& sphere)
+ {
+ float d = mRadius - sphere.mRadius;
+ if(d>=0.0f) return SquareDistance(sphere.mCenter) <= d*d;
+ else return false;
+ }
+
+ ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ /**
+ * Tests if an LSS is contained within the LSS.
+ * \param lss [in] the LSS to test
+ * \return true if inside the LSS
+ * \warning both LSS must be in same space
+ */
+ ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ inline_ bool Contains(const LSS& lss)
+ {
+ // We check the LSS contains the two spheres at the start and end of the sweep
+ return Contains(Sphere(lss.mP0, lss.mRadius)) && Contains(Sphere(lss.mP0, lss.mRadius));
+ }
+
+ float mRadius; //!< Sphere radius
+ };
+
+#endif // __ICELSS_H__