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::HybridPlanesCollider Class Reference

#include <Opcode.h>

Inheritance diagram for Opcode::HybridPlanesCollider:
Opcode::PlanesCollider Opcode::VolumeCollider Opcode::Collider

Public Member Functions

 HybridPlanesCollider ()
 
virtual ~HybridPlanesCollider ()
 
bool Collide (PlanesCache &cache, const Plane *planes, udword nb_planes, const HybridModel &model, const Matrix4x4 *worldm=null)
 
- Public Member Functions inherited from Opcode::PlanesCollider
 PlanesCollider ()
 
virtual ~PlanesCollider ()
 
bool Collide (PlanesCache &cache, const Plane *planes, udword nb_planes, const Model &model, const Matrix4x4 *worldm=null)
 
inline_ bool Collide (PlanesCache &cache, const OBB &box, const Model &model, const Matrix4x4 *worldb=null, const Matrix4x4 *worldm=null)
 
 override (Collider) const char *ValidateSettings()
 
- 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::PlanesCollider
udword mNbPlanes
 
PlanemPlanes
 
VertexPointers mVP
 
- 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::PlanesCollider
void _Collide (const AABBCollisionNode *node, udword clip_mask)
 
void _Collide (const AABBNoLeafNode *node, udword clip_mask)
 
void _Collide (const AABBQuantizedNode *node, udword clip_mask)
 
void _Collide (const AABBQuantizedNoLeafNode *node, udword clip_mask)
 
void _CollideNoPrimitiveTest (const AABBCollisionNode *node, udword clip_mask)
 
void _CollideNoPrimitiveTest (const AABBNoLeafNode *node, udword clip_mask)
 
void _CollideNoPrimitiveTest (const AABBQuantizedNode *node, udword clip_mask)
 
void _CollideNoPrimitiveTest (const AABBQuantizedNoLeafNode *node, udword clip_mask)
 
inline_ bool PlanesAABBOverlap (const Point &center, const Point &extents, udword &out_clip_mask, udword in_clip_mask)
 
inline_ bool PlanesTriOverlap (udword in_clip_mask)
 
bool InitQuery (PlanesCache &cache, const Plane *planes, udword nb_planes, const Matrix4x4 *worldm=null)
 

Detailed Description

Definition at line 110 of file Opcode.h.

Constructor & Destructor Documentation

HybridPlanesCollider::HybridPlanesCollider ( )

Constructor.

Definition at line 514 of file OPC_PlanesCollider.cpp.

515 {
516 }
HybridPlanesCollider::~HybridPlanesCollider ( )
virtual

Destructor.

Definition at line 523 of file OPC_PlanesCollider.cpp.

524 {
525 }

Member Function Documentation

bool HybridPlanesCollider::Collide ( PlanesCache cache,
const Plane planes,
udword  nb_planes,
const HybridModel model,
const Matrix4x4 worldm = null 
)

Definition at line 527 of file OPC_PlanesCollider.cpp.

References Opcode::PlanesCollider::_CollideNoPrimitiveTest(), 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::PlanesCollider::mNbPlanes, Opcode::VolumeCollider::mTouchedPrimitives, Opcode::OPC_CONTACT, Opcode::OPC_NO_PRIMITIVE_TESTS, PLANES_PRIM, Container::Reset(), Opcode::Collider::Setup(), and Opcode::VolumeCache::TouchedPrimitives.

528 {
529  // We don't want primitive tests here!
531 
532  // Checkings
533  if(!Setup(&model)) return false;
534 
535  // Init collision query
536  if(InitQuery(cache, planes, nb_planes, worldm)) return true;
537 
538  // Special case for 1-leaf trees
540  {
541  // Here we're supposed to perform a normal query, except our tree has a single node, i.e. just a few triangles
542  udword Nb = mIMesh->GetNbTriangles();
543 
544  // Loop through all triangles
545  udword clip_mask = (1<<mNbPlanes)-1;
546  for(udword i=0;i<Nb;i++)
547  {
549  }
550  return true;
551  }
552 
553  // Override destination array since we're only going to get leaf boxes here
556 
557  udword PlaneMask = (1<<nb_planes)-1;
558 
559  // Now, do the actual query against leaf boxes
560  if(!model.HasLeafNodes())
561  {
562  if(model.IsQuantized())
563  {
564  const AABBQuantizedNoLeafTree* Tree = (const AABBQuantizedNoLeafTree*)model.GetTree();
565 
566  // Setup dequantization coeffs
567  mCenterCoeff = Tree->mCenterCoeff;
569 
570  // Perform collision query - we don't want primitive tests here!
571  _CollideNoPrimitiveTest(Tree->GetNodes(), PlaneMask);
572  }
573  else
574  {
575  const AABBNoLeafTree* Tree = (const AABBNoLeafTree*)model.GetTree();
576 
577  // Perform collision query - we don't want primitive tests here!
578  _CollideNoPrimitiveTest(Tree->GetNodes(), PlaneMask);
579  }
580  }
581  else
582  {
583  if(model.IsQuantized())
584  {
585  const AABBQuantizedTree* Tree = (const AABBQuantizedTree*)model.GetTree();
586 
587  // Setup dequantization coeffs
588  mCenterCoeff = Tree->mCenterCoeff;
590 
591  // Perform collision query - we don't want primitive tests here!
592  _CollideNoPrimitiveTest(Tree->GetNodes(), PlaneMask);
593  }
594  else
595  {
596  const AABBCollisionTree* Tree = (const AABBCollisionTree*)model.GetTree();
597 
598  // Perform collision query - we don't want primitive tests here!
599  _CollideNoPrimitiveTest(Tree->GetNodes(), PlaneMask);
600  }
601  }
602 
603  // We only have a list of boxes so far
604  if(GetContactStatus())
605  {
606  // Reset contact status, since it currently only reflects collisions with leaf boxes
608 
609  // Change dest container so that we can use built-in overlap tests and get collided primitives
610  cache.TouchedPrimitives.Reset();
612 
613  // Read touched leaf boxes
615  const udword* Touched = mTouchedBoxes.GetEntries();
616 
617  const LeafTriangles* LT = model.GetLeafTriangles();
618  const udword* Indices = model.GetIndices();
619 
620  // Loop through touched leaves
621  udword clip_mask = (1<<mNbPlanes)-1;
622  while(Nb--)
623  {
624  const LeafTriangles& CurrentLeaf = LT[*Touched++];
625 
626  // Each leaf box has a set of triangles
627  udword NbTris = CurrentLeaf.GetNbTriangles();
628  if(Indices)
629  {
630  const udword* T = &Indices[CurrentLeaf.GetTriangleIndex()];
631 
632  // Loop through triangles and test each of them
633  while(NbTris--)
634  {
635  udword TriangleIndex = *T++;
636  PLANES_PRIM(TriangleIndex, OPC_CONTACT)
637  }
638  }
639  else
640  {
641  udword BaseIndex = CurrentLeaf.GetTriangleIndex();
642 
643  // Loop through triangles and test each of them
644  while(NbTris--)
645  {
646  udword TriangleIndex = BaseIndex++;
647  PLANES_PRIM(TriangleIndex, OPC_CONTACT)
648  }
649  }
650  }
651  }
652 
653  return true;
654 }

Member Data Documentation

Container Opcode::HybridPlanesCollider::mTouchedBoxes
protected

Definition at line 119 of file Opcode.h.


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