summaryrefslogtreecommitdiffhomepage
path: root/Opcode/OPC_SphereCollider.h
diff options
context:
space:
mode:
Diffstat (limited to 'Opcode/OPC_SphereCollider.h')
-rw-r--r--Opcode/OPC_SphereCollider.h192
1 files changed, 96 insertions, 96 deletions
diff --git a/Opcode/OPC_SphereCollider.h b/Opcode/OPC_SphereCollider.h
index ee7a278..095824a 100644
--- a/Opcode/OPC_SphereCollider.h
+++ b/Opcode/OPC_SphereCollider.h
@@ -1,96 +1,96 @@
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-/*
- * OPCODE - Optimized Collision Detection
- * Copyright (C) 2001 Pierre Terdiman
- * Homepage: http://www.codercorner.com/Opcode.htm
- */
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-/**
- * Contains code for a sphere collider.
- * \file OPC_SphereCollider.h
- * \author Pierre Terdiman
- * \date June, 2, 2001
- */
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// Include Guard
-#ifndef __OPC_SPHERECOLLIDER_H__
-#define __OPC_SPHERECOLLIDER_H__
-
- struct OPCODE_API SphereCache : VolumeCache
- {
- SphereCache() : Center(0.0f,0.0f,0.0f), FatRadius2(0.0f), FatCoeff(1.1f) {}
- ~SphereCache() {}
-
- // Cached faces signature
- IcePoint Center; //!< Sphere used when performing the query resulting in cached faces
- float FatRadius2; //!< Sphere used when performing the query resulting in cached faces
- // User settings
- float FatCoeff; //!< mRadius2 multiplier used to create a fat sphere
- };
-
- class OPCODE_API SphereCollider : public VolumeCollider
- {
- public:
- // Constructor / Destructor
- SphereCollider();
- virtual ~SphereCollider();
-
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- /**
- * Generic collision query for generic OPCODE models. After the call, access the results:
- * - with GetContactStatus()
- * - with GetNbTouchedPrimitives()
- * - with GetTouchedPrimitives()
- *
- * \param cache [in/out] a sphere cache
- * \param sphere [in] collision sphere in local space
- * \param model [in] Opcode model to collide with
- * \param worlds [in] sphere's world matrix, or null
- * \param worldm [in] model's world matrix, or null
- * \return true if success
- * \warning SCALE NOT SUPPORTED. The matrices must contain rotation & translation parts only.
- */
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- bool Collide(SphereCache& cache, const Sphere& sphere, const Model& model, const Matrix4x4* worlds=null, const Matrix4x4* worldm=null);
-
- //
- bool Collide(SphereCache& cache, const Sphere& sphere, const AABBTree* tree);
- protected:
- // Sphere in model space
- IcePoint mCenter; //!< Sphere center
- float mRadius2; //!< Sphere radius squared
- // Internal methods
- void _Collide(const AABBCollisionNode* node);
- void _Collide(const AABBNoLeafNode* node);
- void _Collide(const AABBQuantizedNode* node);
- void _Collide(const AABBQuantizedNoLeafNode* node);
- void _Collide(const AABBTreeNode* node);
- void _CollideNoPrimitiveTest(const AABBCollisionNode* node);
- void _CollideNoPrimitiveTest(const AABBNoLeafNode* node);
- void _CollideNoPrimitiveTest(const AABBQuantizedNode* node);
- void _CollideNoPrimitiveTest(const AABBQuantizedNoLeafNode* node);
- // Overlap tests
- inline_ BOOL SphereContainsBox(const IcePoint& bc, const IcePoint& be);
- inline_ BOOL SphereAABBOverlap(const IcePoint& center, const IcePoint& extents);
- BOOL SphereTriOverlap(const IcePoint& vert0, const IcePoint& vert1, const IcePoint& vert2);
- // Init methods
- BOOL InitQuery(SphereCache& cache, const Sphere& sphere, const Matrix4x4* worlds=null, const Matrix4x4* worldm=null);
- };
-
- class OPCODE_API HybridSphereCollider : public SphereCollider
- {
- public:
- // Constructor / Destructor
- HybridSphereCollider();
- virtual ~HybridSphereCollider();
-
- bool Collide(SphereCache& cache, const Sphere& sphere, const HybridModel& model, const Matrix4x4* worlds=null, const Matrix4x4* worldm=null);
- protected:
- Container mTouchedBoxes;
- };
-
-#endif // __OPC_SPHERECOLLIDER_H__
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+/*
+ * OPCODE - Optimized Collision Detection
+ * Copyright (C) 2001 Pierre Terdiman
+ * Homepage: http://www.codercorner.com/Opcode.htm
+ */
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+/**
+ * Contains code for a sphere collider.
+ * \file OPC_SphereCollider.h
+ * \author Pierre Terdiman
+ * \date June, 2, 2001
+ */
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Guard
+#ifndef __OPC_SPHERECOLLIDER_H__
+#define __OPC_SPHERECOLLIDER_H__
+
+ struct OPCODE_API SphereCache : VolumeCache
+ {
+ SphereCache() : Center(0.0f,0.0f,0.0f), FatRadius2(0.0f), FatCoeff(1.1f) {}
+ ~SphereCache() {}
+
+ // Cached faces signature
+ IcePoint Center; //!< Sphere used when performing the query resulting in cached faces
+ float FatRadius2; //!< Sphere used when performing the query resulting in cached faces
+ // User settings
+ float FatCoeff; //!< mRadius2 multiplier used to create a fat sphere
+ };
+
+ class OPCODE_API SphereCollider : public VolumeCollider
+ {
+ public:
+ // Constructor / Destructor
+ SphereCollider();
+ virtual ~SphereCollider();
+
+ ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ /**
+ * Generic collision query for generic OPCODE models. After the call, access the results:
+ * - with GetContactStatus()
+ * - with GetNbTouchedPrimitives()
+ * - with GetTouchedPrimitives()
+ *
+ * \param cache [in/out] a sphere cache
+ * \param sphere [in] collision sphere in local space
+ * \param model [in] Opcode model to collide with
+ * \param worlds [in] sphere's world matrix, or null
+ * \param worldm [in] model's world matrix, or null
+ * \return true if success
+ * \warning SCALE NOT SUPPORTED. The matrices must contain rotation & translation parts only.
+ */
+ ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ bool Collide(SphereCache& cache, const Sphere& sphere, const Model& model, const Matrix4x4* worlds=null, const Matrix4x4* worldm=null);
+
+ //
+ bool Collide(SphereCache& cache, const Sphere& sphere, const AABBTree* tree);
+ protected:
+ // Sphere in model space
+ IcePoint mCenter; //!< Sphere center
+ float mRadius2; //!< Sphere radius squared
+ // Internal methods
+ void _Collide(const AABBCollisionNode* node);
+ void _Collide(const AABBNoLeafNode* node);
+ void _Collide(const AABBQuantizedNode* node);
+ void _Collide(const AABBQuantizedNoLeafNode* node);
+ void _Collide(const AABBTreeNode* node);
+ void _CollideNoPrimitiveTest(const AABBCollisionNode* node);
+ void _CollideNoPrimitiveTest(const AABBNoLeafNode* node);
+ void _CollideNoPrimitiveTest(const AABBQuantizedNode* node);
+ void _CollideNoPrimitiveTest(const AABBQuantizedNoLeafNode* node);
+ // Overlap tests
+ inline_ BOOL SphereContainsBox(const IcePoint& bc, const IcePoint& be);
+ inline_ BOOL SphereAABBOverlap(const IcePoint& center, const IcePoint& extents);
+ BOOL SphereTriOverlap(const IcePoint& vert0, const IcePoint& vert1, const IcePoint& vert2);
+ // Init methods
+ BOOL InitQuery(SphereCache& cache, const Sphere& sphere, const Matrix4x4* worlds=null, const Matrix4x4* worldm=null);
+ };
+
+ class OPCODE_API HybridSphereCollider : public SphereCollider
+ {
+ public:
+ // Constructor / Destructor
+ HybridSphereCollider();
+ virtual ~HybridSphereCollider();
+
+ bool Collide(SphereCache& cache, const Sphere& sphere, const HybridModel& model, const Matrix4x4* worlds=null, const Matrix4x4* worldm=null);
+ protected:
+ Container mTouchedBoxes;
+ };
+
+#endif // __OPC_SPHERECOLLIDER_H__