Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OPC_SphereCollider.h
Go to the documentation of this file.
1 /*
3  * OPCODE - Optimized Collision Detection
4  * Copyright (C) 2001 Pierre Terdiman
5  * Homepage: http://www.codercorner.com/Opcode.htm
6  */
8 
10 
16 
19 // Include Guard
20 #ifndef __OPC_SPHERECOLLIDER_H__
21 #define __OPC_SPHERECOLLIDER_H__
22 
24  {
25  SphereCache() : Center(0.0f,0.0f,0.0f), FatRadius2(0.0f), FatCoeff(1.1f) {}
27 
28  // Cached faces signature
30  float FatRadius2;
31  // User settings
32  float FatCoeff;
33  };
34 
36  {
37  public:
38  // Constructor / Destructor
40  virtual ~SphereCollider();
41 
43 
57  bool Collide(SphereCache& cache, const Sphere& sphere, const Model& model, const Matrix4x4* worlds=null, const Matrix4x4* worldm=null);
59 
60  //
61  bool Collide(SphereCache& cache, const Sphere& sphere, const AABBTree* tree);
62  protected:
63  // Sphere in model space
65  float mRadius2;
66  // Internal methods
67  void _Collide(const AABBCollisionNode* node);
68  void _Collide(const AABBNoLeafNode* node);
69  void _Collide(const AABBQuantizedNode* node);
70  void _Collide(const AABBQuantizedNoLeafNode* node);
71  void _Collide(const AABBTreeNode* node);
72  void _CollideNoPrimitiveTest(const AABBCollisionNode* node);
73  void _CollideNoPrimitiveTest(const AABBNoLeafNode* node);
74  void _CollideNoPrimitiveTest(const AABBQuantizedNode* node);
75  void _CollideNoPrimitiveTest(const AABBQuantizedNoLeafNode* node);
76  // Overlap tests
77  inline_ bool SphereContainsBox(const Point& bc, const Point& be);
78  inline_ bool SphereAABBOverlap(const Point& center, const Point& extents);
79  bool SphereTriOverlap(const Point& vert0, const Point& vert1, const Point& vert2);
80  // Init methods
81  bool InitQuery(SphereCache& cache, const Sphere& sphere, const Matrix4x4* worlds=null, const Matrix4x4* worldm=null);
82  };
83 
85  {
86  public:
87  // Constructor / Destructor
89  virtual ~HybridSphereCollider();
90 
91  bool Collide(SphereCache& cache, const Sphere& sphere, const HybridModel& model, const Matrix4x4* worlds=null, const Matrix4x4* worldm=null);
92  protected:
94  };
95 
96 #endif // __OPC_SPHERECOLLIDER_H__