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
AABBCollider Class Reference

#include <OPC_AABBCollider.h>

Inheritance diagram for AABBCollider:
VolumeCollider Collider HybridAABBCollider

Public Member Functions

 AABBCollider ()
 
virtual ~AABBCollider ()
 
bool Collide (AABBCache &cache, const CollisionAABB &box, const Model &model)
 
bool Collide (AABBCache &cache, const CollisionAABB &box, const AABBTree *tree)
 
- Public Member Functions inherited from VolumeCollider
 VolumeCollider ()
 
virtual ~VolumeCollider ()=0
 
inline_ udword GetNbTouchedPrimitives () const
 
inline_ const udwordGetTouchedPrimitives () const
 
inline_ udword GetNbVolumeBVTests () const
 
inline_ udword GetNbVolumePrimTests () const
 
 override (Collider) const char *ValidateSettings()
 
- Public Member Functions inherited from Collider
 Collider ()
 
virtual ~Collider ()
 
inline_ BOOL GetContactStatus () const
 
inline_ BOOL FirstContactEnabled () const
 
inline_ BOOL TemporalCoherenceEnabled () const
 
inline_ BOOL ContactFound () const
 
inline_ BOOL TemporalHit () const
 
inline_ BOOL SkipPrimitiveTests () const
 
inline_ void SetFirstContact (bool flag)
 
inline_ void SetTemporalCoherence (bool flag)
 
inline_ void SetPrimitiveTests (bool flag)
 
virtual const char * ValidateSettings ()=0
 

Protected Member Functions

void _Collide (const AABBCollisionNode *node)
 
void _Collide (const AABBNoLeafNode *node)
 
void _Collide (const AABBQuantizedNode *node)
 
void _Collide (const AABBQuantizedNoLeafNode *node)
 
void _Collide (const AABBTreeNode *node)
 
void _CollideNoPrimitiveTest (const AABBCollisionNode *node)
 
void _CollideNoPrimitiveTest (const AABBNoLeafNode *node)
 
void _CollideNoPrimitiveTest (const AABBQuantizedNode *node)
 
void _CollideNoPrimitiveTest (const AABBQuantizedNoLeafNode *node)
 
inline_ bool AABBContainsBox (const Point &bc, const Point &be)
 
inline_ bool AABBAABBOverlap (const Point &b, const Point &Pb)
 A special version for 2 axis-aligned boxes. More...
 
inline_ bool TriBoxOverlap ()
 ...and another one, jeez More...
 
bool InitQuery (AABBCache &cache, const CollisionAABB &box)
 
- Protected Member Functions inherited from VolumeCollider
void _Dump (const AABBCollisionNode *node)
 
void _Dump (const AABBNoLeafNode *node)
 
void _Dump (const AABBQuantizedNode *node)
 
void _Dump (const AABBQuantizedNoLeafNode *node)
 
 override (Collider) inline_ void InitQuery()
 
inline_ BOOL IsCacheValid (VolumeCache &cache)
 
- Protected Member Functions inherited from Collider
inline_ BOOL Setup (const BaseModel *model)
 
virtual inline_ void InitQuery ()
 

Protected Attributes

CollisionAABB mBox
 Query box in (center, extents) form. More...
 
Point mMin
 Query box min point. More...
 
Point mMax
 Query box max point. More...
 
Point mLeafVerts [3]
 Triangle vertices. More...
 
- Protected Attributes inherited from VolumeCollider
ContainermTouchedPrimitives
 List of touched primitives. More...
 
Point mCenterCoeff
 
Point mExtentsCoeff
 
udword mNbVolumeBVTests
 Number of Volume-BV tests. More...
 
udword mNbVolumePrimTests
 Number of Volume-Primitive tests. More...
 
- Protected Attributes inherited from Collider
udword mFlags
 Bit flags. More...
 
const BaseModelmCurrentModel
 Current model for collision query (owner of touched faces) More...
 
const MeshInterfacemIMesh
 User-defined mesh interface. More...
 

Detailed Description

Contains an AABB-vs-tree collider.

Author
Pierre Terdiman
Version
1.3
Date
January, 1st, 2002

Definition at line 37 of file OPC_AABBCollider.h.

Constructor & Destructor Documentation

AABBCollider::AABBCollider ( )
virtual AABBCollider::~AABBCollider ( )
virtual

Member Function Documentation

void AABBCollider::_Collide ( const AABBCollisionNode node)
protected
void AABBCollider::_Collide ( const AABBNoLeafNode node)
protected
void AABBCollider::_Collide ( const AABBQuantizedNode node)
protected
void AABBCollider::_Collide ( const AABBQuantizedNoLeafNode node)
protected
void AABBCollider::_Collide ( const AABBTreeNode node)
protected
void AABBCollider::_CollideNoPrimitiveTest ( const AABBCollisionNode node)
protected
void AABBCollider::_CollideNoPrimitiveTest ( const AABBNoLeafNode node)
protected
void AABBCollider::_CollideNoPrimitiveTest ( const AABBQuantizedNode node)
protected
void AABBCollider::_CollideNoPrimitiveTest ( const AABBQuantizedNoLeafNode node)
protected
inline_ bool AABBCollider::AABBAABBOverlap ( const Point b,
const Point Pb 
)
protected

A special version for 2 axis-aligned boxes.

Definition at line 112 of file OPC_BoxBoxOverlap.h.

References FALSE, GREATER, mBox, CollisionAABB::mCenter, CollisionAABB::mExtents, VolumeCollider::mNbVolumeBVTests, TRUE, Point::x, Point::y, and Point::z.

113 {
114  // Stats
116 
117  float tx = mBox.mCenter.x - center.x; float ex = extents.x + mBox.mExtents.x; if(GREATER(tx, ex)) return FALSE;
118  float ty = mBox.mCenter.y - center.y; float ey = extents.y + mBox.mExtents.y; if(GREATER(ty, ey)) return FALSE;
119  float tz = mBox.mCenter.z - center.z; float ez = extents.z + mBox.mExtents.z; if(GREATER(tz, ez)) return FALSE;
120 
121  return TRUE;
122 }
inline_ bool AABBCollider::AABBContainsBox ( const Point bc,
const Point be 
)
protected
bool AABBCollider::Collide ( AABBCache cache,
const CollisionAABB box,
const Model model 
)

Generic collision query for generic OPCODE models. After the call, access the results:

Parameters
cache[in/out] a box cache
box[in] collision AABB in world space
model[in] Opcode model to collide with
Returns
true if success
Warning
SCALE NOT SUPPORTED. The matrices must contain rotation & translation parts only.
bool AABBCollider::Collide ( AABBCache cache,
const CollisionAABB box,
const AABBTree tree 
)
bool AABBCollider::InitQuery ( AABBCache cache,
const CollisionAABB box 
)
protected
inline_ bool AABBCollider::TriBoxOverlap ( )
protected

...and another one, jeez

Definition at line 259 of file OPC_TriBoxOverlap.h.

References center, d, FALSE, FINDMINMAX, IMPLEMENT_CLASS3_TESTS, max(), mBox, CollisionAABB::mCenter, CollisionAABB::mExtents, min(), mLeafVerts, VolumeCollider::mNbVolumePrimTests, planeBoxOverlap(), TRUE, Point::x, Point::y, and Point::z.

260 {
261  // Stats
263 
264  // Hook
265  const Point& center = mBox.mCenter;
266  const Point& extents = mBox.mExtents;
267 
268  // use separating axis theorem to test overlap between triangle and box
269  // need to test for overlap in these directions:
270  // 1) the {x,y,z}-directions (actually, since we use the AABB of the triangle
271  // we do not even need to test these)
272  // 2) normal of the triangle
273  // 3) crossproduct(edge from tri, {x,y,z}-directin)
274  // this gives 3x3=9 more tests
275 
276  // move everything so that the boxcenter is in (0,0,0)
277  Point v0, v1, v2;
278  v0.x = mLeafVerts[0].x - center.x;
279  v1.x = mLeafVerts[1].x - center.x;
280  v2.x = mLeafVerts[2].x - center.x;
281 
282  // First, test overlap in the {x,y,z}-directions
283 #ifdef OPC_USE_FCOMI
284  // find min, max of the triangle in x-direction, and test for overlap in X
285  if(FCMin3(v0.x, v1.x, v2.x)>extents.x) return FALSE;
286  if(FCMax3(v0.x, v1.x, v2.x)<-extents.x) return FALSE;
287 
288  // same for Y
289  v0.y = mLeafVerts[0].y - center.y;
290  v1.y = mLeafVerts[1].y - center.y;
291  v2.y = mLeafVerts[2].y - center.y;
292 
293  if(FCMin3(v0.y, v1.y, v2.y)>extents.y) return FALSE;
294  if(FCMax3(v0.y, v1.y, v2.y)<-extents.y) return FALSE;
295 
296  // same for Z
297  v0.z = mLeafVerts[0].z - center.z;
298  v1.z = mLeafVerts[1].z - center.z;
299  v2.z = mLeafVerts[2].z - center.z;
300 
301  if(FCMin3(v0.z, v1.z, v2.z)>extents.z) return FALSE;
302  if(FCMax3(v0.z, v1.z, v2.z)<-extents.z) return FALSE;
303 #else
304  float min,max;
305  // Find min, max of the triangle in x-direction, and test for overlap in X
306  FINDMINMAX(v0.x, v1.x, v2.x, min, max);
307  if(min>extents.x || max<-extents.x) return FALSE;
308 
309  // Same for Y
310  v0.y = mLeafVerts[0].y - center.y;
311  v1.y = mLeafVerts[1].y - center.y;
312  v2.y = mLeafVerts[2].y - center.y;
313 
314  FINDMINMAX(v0.y, v1.y, v2.y, min, max);
315  if(min>extents.y || max<-extents.y) return FALSE;
316 
317  // Same for Z
318  v0.z = mLeafVerts[0].z - center.z;
319  v1.z = mLeafVerts[1].z - center.z;
320  v2.z = mLeafVerts[2].z - center.z;
321 
322  FINDMINMAX(v0.z, v1.z, v2.z, min, max);
323  if(min>extents.z || max<-extents.z) return FALSE;
324 #endif
325  // 2) Test if the box intersects the plane of the triangle
326  // compute plane equation of triangle: normal*x+d=0
327  // ### could be precomputed since we use the same leaf triangle several times
328  const Point e0 = v1 - v0;
329  const Point e1 = v2 - v1;
330  const Point normal = e0 ^ e1;
331  const float d = -normal|v0;
332  if(!planeBoxOverlap(normal, d, extents)) return FALSE;
333 
334  // 3) "Class III" tests - here we always do full tests since the box is a primitive (not a BV)
335  {
337  }
338  return TRUE;
339 }

Member Data Documentation

CollisionAABB AABBCollider::mBox
protected

Query box in (center, extents) form.

Definition at line 62 of file OPC_AABBCollider.h.

Referenced by AABBAABBOverlap(), and TriBoxOverlap().

Point AABBCollider::mLeafVerts[3]
protected

Triangle vertices.

Definition at line 66 of file OPC_AABBCollider.h.

Referenced by TriBoxOverlap().

Point AABBCollider::mMax
protected

Query box max point.

Definition at line 64 of file OPC_AABBCollider.h.

Point AABBCollider::mMin
protected

Query box min point.

Definition at line 63 of file OPC_AABBCollider.h.


The documentation for this class was generated from the following files: