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_OBBCollider.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_OBBCOLLIDER_H__
21 #define __OPC_OBBCOLLIDER_H__
22 
24  {
25  OBBCache() : FatCoeff(1.1f)
26  {
27  FatBox.mCenter.Zero();
28  FatBox.mExtents.Zero();
29  FatBox.mRot.Identity();
30  }
31 
32  // Cached faces signature
34  // User settings
35  float FatCoeff;
36  };
37 
39  {
40  public:
41  // Constructor / Destructor
42  OBBCollider();
43  virtual ~OBBCollider();
44 
46 
60  bool Collide(OBBCache& cache, const OBB& box, const Model& model, const Matrix4x4* worldb=null, const Matrix4x4* worldm=null);
62 
63  // Settings
64 
66 
70  inline_ void SetFullBoxBoxTest(bool flag) { mFullBoxBoxTest = flag; }
72 
73  // Settings
74 
76 
80  override(Collider) const char* ValidateSettings();
82 
83  protected:
84  // Precomputed data
90 
94 
95  float mBBx1;
96  float mBBy1;
97  float mBBz1;
98 
99  float mBB_1;
100  float mBB_2;
101  float mBB_3;
102  float mBB_4;
103  float mBB_5;
104  float mBB_6;
105  float mBB_7;
106  float mBB_8;
107  float mBB_9;
108 
109  // Leaf description
110  Point mLeafVerts[3];
111  // Settings
113  // Internal methods
114  void _Collide(const AABBCollisionNode* node);
115  void _Collide(const AABBNoLeafNode* node);
116  void _Collide(const AABBQuantizedNode* node);
117  void _Collide(const AABBQuantizedNoLeafNode* node);
118  void _CollideNoPrimitiveTest(const AABBCollisionNode* node);
119  void _CollideNoPrimitiveTest(const AABBNoLeafNode* node);
120  void _CollideNoPrimitiveTest(const AABBQuantizedNode* node);
121  void _CollideNoPrimitiveTest(const AABBQuantizedNoLeafNode* node);
122  // Overlap tests
123  inline_ bool OBBContainsBox(const Point& bc, const Point& be);
124  inline_ bool BoxBoxOverlap(const Point& extents, const Point& center);
125  inline_ bool TriBoxOverlap();
126  // Init methods
127  bool InitQuery(OBBCache& cache, const OBB& box, const Matrix4x4* worldb=null, const Matrix4x4* worldm=null);
128  };
129 
131  {
132  public:
133  // Constructor / Destructor
135  virtual ~HybridOBBCollider();
136 
137  bool Collide(OBBCache& cache, const OBB& box, const HybridModel& model, const Matrix4x4* worldb=null, const Matrix4x4* worldm=null);
138  protected:
140  };
141 
142 #endif // __OPC_OBBCOLLIDER_H__