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_VolumeCollider.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_VOLUMECOLLIDER_H__
21 #define __OPC_VOLUMECOLLIDER_H__
22 
24  {
27 
29  const BaseModel* Model;
30  };
31 
33  {
34  public:
35  // Constructor / Destructor
37  virtual ~VolumeCollider() = 0;
38 
39  // Collision report
40 
42 
48  inline_ udword GetNbTouchedPrimitives() const { return mTouchedPrimitives ? mTouchedPrimitives->GetNbEntries() : 0; }
50 
52 
58  inline_ const udword* GetTouchedPrimitives() const { return mTouchedPrimitives ? mTouchedPrimitives->GetEntries() : null; }
60 
61  // Stats
62 
64 
69  inline_ udword GetNbVolumeBVTests() const { return mNbVolumeBVTests; }
71 
73 
78  inline_ udword GetNbVolumePrimTests() const { return mNbVolumePrimTests; }
80 
81  // Settings
82 
84 
88  override(Collider) const char* ValidateSettings();
90 
91  protected:
92  // Touched primitives
94 
95  // Dequantization coeffs
98  // Stats
101  // Internal methods
102  void _Dump(const AABBCollisionNode* node);
103  void _Dump(const AABBNoLeafNode* node);
104  void _Dump(const AABBQuantizedNode* node);
105  void _Dump(const AABBQuantizedNoLeafNode* node);
106 
108 
111  override(Collider) inline_ void InitQuery()
113  {
114  // Reset stats & contact status
115  mNbVolumeBVTests = 0;
116  mNbVolumePrimTests = 0;
118  }
119 
121  {
122  // We're going to do a volume-vs-model query.
123  if(cache.Model!=mCurrentModel)
124  {
125  // Cached list was for another model so we can't keep it
126  // Keep track of new owner and reset cache
127  cache.Model = mCurrentModel;
128  return FALSE;
129  }
130  else
131  {
132  // Same models, no problem
133  return TRUE;
134  }
135  }
136  };
137 
138 #endif // __OPC_VOLUMECOLLIDER_H__