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
Opcode::HybridAABBCollider Class Reference

#include <Opcode.h>

Inheritance diagram for Opcode::HybridAABBCollider:
Opcode::AABBCollider Opcode::VolumeCollider Opcode::Collider

Public Member Functions

 HybridAABBCollider ()
 
virtual ~HybridAABBCollider ()
 
bool Collide (AABBCache &cache, const CollisionAABB &box, const HybridModel &model)
 
- Public Member Functions inherited from Opcode::AABBCollider
 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 Opcode::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 Opcode::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 Attributes

Container mTouchedBoxes
 
- Protected Attributes inherited from Opcode::AABBCollider
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 Opcode::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 Opcode::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...
 

Additional Inherited Members

- Protected Member Functions inherited from Opcode::AABBCollider
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)
 
inline_ bool TriBoxOverlap ()
 
bool InitQuery (AABBCache &cache, const CollisionAABB &box)
 

Detailed Description

Definition at line 86 of file Opcode.h.

Constructor & Destructor Documentation

HybridAABBCollider::HybridAABBCollider ( )

Constructor.

Definition at line 561 of file OPC_AABBCollider.cpp.

562 {
563 }
HybridAABBCollider::~HybridAABBCollider ( )
virtual

Destructor.

Definition at line 570 of file OPC_AABBCollider.cpp.

571 {
572 }

Member Function Documentation

bool HybridAABBCollider::Collide ( AABBCache cache,
const CollisionAABB box,
const HybridModel model 
)

Definition at line 574 of file OPC_AABBCollider.cpp.

References Opcode::AABBCollider::_CollideNoPrimitiveTest(), AABB_PRIM, Opcode::Collider::GetContactStatus(), Opcode::HybridModel::GetIndices(), Opcode::HybridModel::GetLeafTriangles(), Container::GetNbEntries(), Opcode::LeafTriangles::GetNbTriangles(), Opcode::MeshInterface::GetNbTriangles(), Opcode::BaseModel::GetTree(), Opcode::LeafTriangles::GetTriangleIndex(), Opcode::BaseModel::HasLeafNodes(), Opcode::BaseModel::HasSingleNode(), i, Opcode::Collider::InitQuery(), Opcode::BaseModel::IsQuantized(), Opcode::VolumeCollider::mCenterCoeff, Opcode::AABBQuantizedTree::mCenterCoeff, Opcode::AABBQuantizedNoLeafTree::mCenterCoeff, Opcode::Collider::mCurrentModel, Opcode::VolumeCollider::mExtentsCoeff, Opcode::AABBQuantizedTree::mExtentsCoeff, Opcode::AABBQuantizedNoLeafTree::mExtentsCoeff, Opcode::Collider::mFlags, Opcode::Collider::mIMesh, Opcode::VolumeCollider::mTouchedPrimitives, Opcode::OPC_CONTACT, Opcode::OPC_NO_PRIMITIVE_TESTS, Container::Reset(), Opcode::Collider::Setup(), and Opcode::VolumeCache::TouchedPrimitives.

575 {
576  // We don't want primitive tests here!
578 
579  // Checkings
580  if(!Setup(&model)) return false;
581 
582  // Init collision query
583  if(InitQuery(cache, box)) return true;
584 
585  // Special case for 1-leaf trees
587  {
588  // Here we're supposed to perform a normal query, except our tree has a single node, i.e. just a few triangles
589  udword Nb = mIMesh->GetNbTriangles();
590 
591  // Loop through all triangles
592  for(udword i=0;i<Nb;i++)
593  {
595  }
596  return true;
597  }
598 
599  // Override destination array since we're only going to get leaf boxes here
602 
603  // Now, do the actual query against leaf boxes
604  if(!model.HasLeafNodes())
605  {
606  if(model.IsQuantized())
607  {
608  const AABBQuantizedNoLeafTree* Tree = (const AABBQuantizedNoLeafTree*)model.GetTree();
609 
610  // Setup dequantization coeffs
611  mCenterCoeff = Tree->mCenterCoeff;
613 
614  // Perform collision query - we don't want primitive tests here!
615  _CollideNoPrimitiveTest(Tree->GetNodes());
616  }
617  else
618  {
619  const AABBNoLeafTree* Tree = (const AABBNoLeafTree*)model.GetTree();
620 
621  // Perform collision query - we don't want primitive tests here!
622  _CollideNoPrimitiveTest(Tree->GetNodes());
623  }
624  }
625  else
626  {
627  if(model.IsQuantized())
628  {
629  const AABBQuantizedTree* Tree = (const AABBQuantizedTree*)model.GetTree();
630 
631  // Setup dequantization coeffs
632  mCenterCoeff = Tree->mCenterCoeff;
634 
635  // Perform collision query - we don't want primitive tests here!
636  _CollideNoPrimitiveTest(Tree->GetNodes());
637  }
638  else
639  {
640  const AABBCollisionTree* Tree = (const AABBCollisionTree*)model.GetTree();
641 
642  // Perform collision query - we don't want primitive tests here!
643  _CollideNoPrimitiveTest(Tree->GetNodes());
644  }
645  }
646 
647  // We only have a list of boxes so far
648  if(GetContactStatus())
649  {
650  // Reset contact status, since it currently only reflects collisions with leaf boxes
652 
653  // Change dest container so that we can use built-in overlap tests and get collided primitives
654  cache.TouchedPrimitives.Reset();
656 
657  // Read touched leaf boxes
659  const udword* Touched = mTouchedBoxes.GetEntries();
660 
661  const LeafTriangles* LT = model.GetLeafTriangles();
662  const udword* Indices = model.GetIndices();
663 
664  // Loop through touched leaves
665  while(Nb--)
666  {
667  const LeafTriangles& CurrentLeaf = LT[*Touched++];
668 
669  // Each leaf box has a set of triangles
670  udword NbTris = CurrentLeaf.GetNbTriangles();
671  if(Indices)
672  {
673  const udword* T = &Indices[CurrentLeaf.GetTriangleIndex()];
674 
675  // Loop through triangles and test each of them
676  while(NbTris--)
677  {
678  udword TriangleIndex = *T++;
679  AABB_PRIM(TriangleIndex, OPC_CONTACT)
680  }
681  }
682  else
683  {
684  udword BaseIndex = CurrentLeaf.GetTriangleIndex();
685 
686  // Loop through triangles and test each of them
687  while(NbTris--)
688  {
689  udword TriangleIndex = BaseIndex++;
690  AABB_PRIM(TriangleIndex, OPC_CONTACT)
691  }
692  }
693  }
694  }
695 
696  return true;
697 }

Member Data Documentation

Container Opcode::HybridAABBCollider::mTouchedBoxes
protected

Definition at line 95 of file Opcode.h.


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