Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00008
00010
00016
00017
00019
00020 #ifndef __OPC_SPHERECOLLIDER_H__
00021 #define __OPC_SPHERECOLLIDER_H__
00022
00023 struct OPCODE_API SphereCache : VolumeCache
00024 {
00025 SphereCache() : Center(0.0f,0.0f,0.0f), FatRadius2(0.0f), FatCoeff(1.1f) {}
00026 ~SphereCache() {}
00027
00028
00029 Point Center;
00030 float FatRadius2;
00031
00032 float FatCoeff;
00033 };
00034
00035 class OPCODE_API SphereCollider : public VolumeCollider
00036 {
00037 public:
00038
00039 SphereCollider();
00040 virtual ~SphereCollider();
00041
00043
00057
00058 bool Collide(SphereCache& cache, const Sphere& sphere, const Model& model, const Matrix4x4* worlds=null, const Matrix4x4* worldm=null);
00059
00060
00061 bool Collide(SphereCache& cache, const Sphere& sphere, const AABBTree* tree);
00062 protected:
00063
00064 Point mCenter;
00065 float mRadius2;
00066
00067 void _Collide(const AABBCollisionNode* node);
00068 void _Collide(const AABBNoLeafNode* node);
00069 void _Collide(const AABBQuantizedNode* node);
00070 void _Collide(const AABBQuantizedNoLeafNode* node);
00071 void _Collide(const AABBTreeNode* node);
00072 void _CollideNoPrimitiveTest(const AABBCollisionNode* node);
00073 void _CollideNoPrimitiveTest(const AABBNoLeafNode* node);
00074 void _CollideNoPrimitiveTest(const AABBQuantizedNode* node);
00075 void _CollideNoPrimitiveTest(const AABBQuantizedNoLeafNode* node);
00076
00077 inline_ BOOL SphereContainsBox(const Point& bc, const Point& be);
00078 inline_ BOOL SphereAABBOverlap(const Point& center, const Point& extents);
00079 BOOL SphereTriOverlap(const Point& vert0, const Point& vert1, const Point& vert2);
00080
00081 BOOL InitQuery(SphereCache& cache, const Sphere& sphere, const Matrix4x4* worlds=null, const Matrix4x4* worldm=null);
00082 };
00083
00084 class OPCODE_API HybridSphereCollider : public SphereCollider
00085 {
00086 public:
00087
00088 HybridSphereCollider();
00089 virtual ~HybridSphereCollider();
00090
00091 bool Collide(SphereCache& cache, const Sphere& sphere, const HybridModel& model, const Matrix4x4* worlds=null, const Matrix4x4* worldm=null);
00092 protected:
00093 Container mTouchedBoxes;
00094 };
00095
00096 #endif // __OPC_SPHERECOLLIDER_H__