OPC_TreeCollider.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_TREECOLLIDER_H__
21 #define __OPC_TREECOLLIDER_H__
22 
23 #include"../config.h"
31  {
34  {
35  ResetCache();
36  ResetCountDown();
37  }
38 
39  void ResetCache()
40  {
41  Model0 = null;
42  Model1 = null;
43  id0 = 0;
44  id1 = 1;
45 #ifdef __MESHMERIZER_H__ // Collision hulls only supported within ICE !
46  HullTest = true;
47  SepVector.pid = 0;
48  SepVector.qid = 0;
49  SepVector.SV = Point(1.0f, 0.0f, 0.0f);
50 #endif // __MESHMERIZER_H__
51  }
52 
54  {
55 #ifdef __MESHMERIZER_H__ // Collision hulls only supported within ICE !
56  CountDown = 50;
57 #endif // __MESHMERIZER_H__
58  }
59 
60  const Model* Model0;
61  const Model* Model1;
62 
63 #ifdef __MESHMERIZER_H__ // Collision hulls only supported within ICE !
64  SVCache SepVector;
65  udword CountDown;
66  bool HullTest;
67 #endif // __MESHMERIZER_H__
68  };
69 
71  {
72  public:
73  // Constructor / Destructor
75  virtual ~AABBTreeCollider();
76 
77  inline void setCollisionPairInserter(hrp::CollisionPairInserterBase* collisionPairInserter) {
78  this->collisionPairInserter = collisionPairInserter;
79  }
80 
81 
82  // Generic collision query
83 
85 
97  bool Collide(BVTCache& cache, const Matrix4x4* world0=null, const Matrix4x4* world1=null);
99 
100  // Collision queries
101  bool Collide(const AABBCollisionTree* tree0, const AABBCollisionTree* tree1, const Matrix4x4* world0=null, const Matrix4x4* world1=null, Pair* cache=null);
102  bool Collide(const AABBNoLeafTree* tree0, const AABBNoLeafTree* tree1, const Matrix4x4* world0=null, const Matrix4x4* world1=null, Pair* cache=null);
103  bool Collide(const AABBQuantizedTree* tree0, const AABBQuantizedTree* tree1, const Matrix4x4* world0=null, const Matrix4x4* world1=null, Pair* cache=null);
104  bool Collide(const AABBQuantizedNoLeafTree* tree0, const AABBQuantizedNoLeafTree* tree1, const Matrix4x4* world0=null, const Matrix4x4* world1=null, Pair* cache=null);
105  // Settings
106 
108 
113  inline_ void SetFullBoxBoxTest(bool flag) { mFullBoxBoxTest = flag; }
115 
117 
122  inline_ void SetFullPrimBoxTest(bool flag) { mFullPrimBoxTest = flag; }
124 
125  // Stats
126 
128 
134  inline_ udword GetNbBVBVTests() const { return mNbBVBVTests; }
136 
138 
144  inline_ udword GetNbPrimPrimTests() const { return mNbPrimPrimTests; }
146 
148 
154  inline_ udword GetNbBVPrimTests() const { return mNbBVPrimTests; }
156 
157  // Data access
158 
160 
166  inline_ udword GetNbPairs() const { return mPairs.GetNbEntries()>>1; }
168 
170 
176  inline_ const Pair* GetPairs() const { return (const Pair*)mPairs.GetEntries(); }
178 
180 
184  override(Collider) HRP_COLLISION_EXPORT const char* ValidateSettings();
186 
187  protected:
188  // Colliding pairs
190  // User mesh interfaces
193  // Stats
197  // Precomputed data
203  // Dequantization coeffs
208  // Modified!!
209  // For normal vector detection
214  // Leaf description
215  Point mLeafVerts[3];
217  // Settings
221  // Internal methods
222 
223  // Standard AABB trees
224  void _Collide(const AABBCollisionNode* b0, const AABBCollisionNode* b1);
225  // Quantized AABB trees
226  void _Collide(const AABBQuantizedNode* b0, const AABBQuantizedNode* b1, const Point& a, const Point& Pa, const Point& b, const Point& Pb);
227  // No-leaf AABB trees
228  void _CollideTriBox(const AABBNoLeafNode* b);
229  void _CollideBoxTri(const AABBNoLeafNode* b);
230  void _Collide(const AABBNoLeafNode* a, const AABBNoLeafNode* b);
231  // Quantized no-leaf AABB trees
232  void _CollideTriBox(const AABBQuantizedNoLeafNode* b);
233  void _CollideBoxTri(const AABBQuantizedNoLeafNode* b);
234  void _Collide(const AABBQuantizedNoLeafNode* a, const AABBQuantizedNoLeafNode* b);
235  // Overlap tests
236  void PrimTest(udword id0, udword id1);
237  inline_ void PrimTestTriIndex(udword id1);
238  inline_ void PrimTestIndexTri(udword id0);
239 
240  inline_ BOOL BoxBoxOverlap(const Point& ea, const Point& ca, const Point& eb, const Point& cb);
241  inline_ BOOL TriBoxOverlap(const Point& center, const Point& extents);
242  BOOL TriTriOverlap(const Point& V0, const Point& V1, const Point& V2, const Point& U0, const Point& U1, const Point& U2);
243  // Init methods
244  HRP_COLLISION_EXPORT void InitQuery(const Matrix4x4* world0=null, const Matrix4x4* world1=null);
245  bool CheckTemporalCoherence(Pair* cache);
246 
247  inline_ BOOL Setup(const MeshInterface* mi0, const MeshInterface* mi1)
248  {
249  mIMesh0 = mi0;
250  mIMesh1 = mi1;
251 
252  if(!mIMesh0 || !mIMesh1) return FALSE;
253 
254  return TRUE;
255  }
256  };
257 
258 #endif // __OPC_TREECOLLIDER_H__
Pair
A generic couple structure.
Definition: IcePairs.h:16
AABBTreeCollider::mId1
udword mId1
Definition: OPC_TreeCollider.h:211
AABBTreeCollider::mNowNode1
const AABBCollisionNode * mNowNode1
Definition: OPC_TreeCollider.h:213
AABBCollisionTree
Definition: OPC_OptimizedTree.h:192
Matrix4x4
Definition: IceMatrix4x4.h:21
AABBTreeCollider::mNbBVPrimTests
udword mNbBVPrimTests
Number of BV-Primitive tests.
Definition: OPC_TreeCollider.h:196
AABBTreeCollider::mId0
udword mId0
Definition: OPC_TreeCollider.h:210
AABBTreeCollider::mR0to1
Matrix3x3 mR0to1
Rotation from object0 to object1.
Definition: OPC_TreeCollider.h:199
Container
Definition: IceContainer.h:25
Collider::InitQuery
virtual inline_ void InitQuery()
Definition: OPC_Collider.h:173
AABBTreeCollider::mT1to0
Point mT1to0
Translation from object1 to object0.
Definition: OPC_TreeCollider.h:202
AABBTreeCollider::mCenterCoeff0
Point mCenterCoeff0
Definition: OPC_TreeCollider.h:204
udword
unsigned int udword
sizeof(udword) must be 4
Definition: IceTypes.h:65
BOOL
int BOOL
Another boolean type.
Definition: IceTypes.h:102
swingTest.f
f
Definition: swingTest.py:6
b
long b
Definition: jpegint.h:371
Collider::ValidateSettings
virtual const char * ValidateSettings()=0
AABBTreeCollider::mR1to0
Matrix3x3 mR1to0
Rotation from object1 to object0.
Definition: OPC_TreeCollider.h:200
Collider::Collider
Collider()
Definition: OPC_Collider.cpp:40
AABBTreeCollider::Setup
inline_ BOOL Setup(const MeshInterface *mi0, const MeshInterface *mi1)
Definition: OPC_TreeCollider.h:247
AABBCollisionNode
Definition: OPC_OptimizedTree.h:76
AABBTreeCollider::mIMesh1
const MeshInterface * mIMesh1
User-defined mesh interface for object1.
Definition: OPC_TreeCollider.h:192
AABBNoLeafNode
Definition: OPC_OptimizedTree.h:116
BVTCache::ResetCountDown
inline_ void ResetCountDown()
Definition: OPC_TreeCollider.h:53
AABBTreeCollider::setCollisionPairInserter
void setCollisionPairInserter(hrp::CollisionPairInserterBase *collisionPairInserter)
Definition: OPC_TreeCollider.h:77
AABBTreeCollider::mNowNode0
const AABBCollisionNode * mNowNode0
Definition: OPC_TreeCollider.h:212
Collider
Definition: OPC_Collider.h:37
AABBQuantizedNoLeafNode
Definition: OPC_OptimizedTree.h:121
AABBQuantizedTree
Definition: OPC_OptimizedTree.h:202
AABBTreeCollider::mExtentsCoeff0
Point mExtentsCoeff0
Definition: OPC_TreeCollider.h:205
HRP_COLLISION_EXPORT
#define HRP_COLLISION_EXPORT
Definition: hrplib/hrpCollision/config.h:26
TRUE
#define TRUE
Definition: OPC_IceHook.h:13
AABBTreeCollider::mNbPrimPrimTests
udword mNbPrimPrimTests
Number of Primitive-Primitive tests.
Definition: OPC_TreeCollider.h:195
AABBTreeCollider::mNbBVBVTests
udword mNbBVBVTests
Number of BV-BV tests.
Definition: OPC_TreeCollider.h:194
BVTCache::Model0
const Model * Model0
Model for first object.
Definition: OPC_TreeCollider.h:60
AABBTreeCollider::mFullBoxBoxTest
bool mFullBoxBoxTest
Perform full BV-BV tests (true) or SAT-lite tests (false)
Definition: OPC_TreeCollider.h:218
Model
Definition: OPC_Model.h:23
FALSE
#define FALSE
Definition: OPC_IceHook.h:9
OPCODE_API
#define OPCODE_API
Definition: Opcode.h:68
AABBQuantizedNoLeafTree
Definition: OPC_OptimizedTree.h:211
AABBTreeCollider::mFullPrimBoxTest
bool mFullPrimBoxTest
Perform full Primitive-BV tests (true) or SAT-lite tests (false)
Definition: OPC_TreeCollider.h:219
BVTCache::ResetCache
void ResetCache()
Definition: OPC_TreeCollider.h:39
AABBTreeCollider::collisionPairInserter
hrp::CollisionPairInserterBase * collisionPairInserter
Definition: OPC_TreeCollider.h:220
AABBTreeCollider::mCenterCoeff1
Point mCenterCoeff1
Definition: OPC_TreeCollider.h:206
Point
Definition: IcePoint.h:25
AABBQuantizedNode
Definition: OPC_OptimizedTree.h:100
MeshInterface
Definition: OPC_MeshInterface.h:53
test.a
int a
Definition: test.py:1
AABBTreeCollider
Definition: OPC_TreeCollider.h:70
BVTCache
Definition: OPC_TreeCollider.h:30
Matrix3x3
Definition: IceMatrix3x3.h:20
AABBTreeCollider::mExtentsCoeff1
Point mExtentsCoeff1
Definition: OPC_TreeCollider.h:207
hrp::CollisionPairInserterBase
Definition: CollisionPairInserterBase.h:27
AABBTreeCollider::mPairs
Container mPairs
Pairs of colliding primitives.
Definition: OPC_TreeCollider.h:189
AABBTreeCollider::mAR
Matrix3x3 mAR
Absolute rotation matrix.
Definition: OPC_TreeCollider.h:198
AABBTreeCollider::mIMesh0
const MeshInterface * mIMesh0
User-defined mesh interface for object0.
Definition: OPC_TreeCollider.h:191
AABBTreeCollider::mT0to1
Point mT0to1
Translation from object0 to object1.
Definition: OPC_TreeCollider.h:201
flag
png_infop png_uint_32 flag
Definition: png.h:2156
inline_
#define inline_
Definition: IcePreprocessor.h:103
AABBTreeCollider::mLeafIndex
udword mLeafIndex
Triangle index.
Definition: OPC_TreeCollider.h:216
AABBNoLeafTree
Definition: OPC_OptimizedTree.h:197
BVTCache::Model1
const Model * Model1
Model for second object.
Definition: OPC_TreeCollider.h:61
BVTCache::BVTCache
inline_ BVTCache()
Constructor.
Definition: OPC_TreeCollider.h:33


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Wed Sep 7 2022 02:51:04