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

#include <Opcode.h>

Inheritance diagram for Opcode::HybridLSSCollider:
Opcode::LSSCollider Opcode::VolumeCollider Opcode::Collider

Public Member Functions

 HybridLSSCollider ()
 
virtual ~HybridLSSCollider ()
 
bool Collide (LSSCache &cache, const LSS &lss, const HybridModel &model, const Matrix4x4 *worldl=null, const Matrix4x4 *worldm=null)
 
- Public Member Functions inherited from Opcode::LSSCollider
 LSSCollider ()
 
virtual ~LSSCollider ()
 
bool Collide (LSSCache &cache, const LSS &lss, const Model &model, const Matrix4x4 *worldl=null, const Matrix4x4 *worldm=null)
 
bool Collide (LSSCache &cache, const LSS &lss, 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::LSSCollider
Segment mSeg
 Segment. More...
 
float mRadius2
 LSS radius squared. 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::LSSCollider
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 LSSContainsBox (const Point &bc, const Point &be)
 
inline_ bool LSSAABBOverlap (const Point &center, const Point &extents)
 
inline_ bool LSSTriOverlap (const Point &vert0, const Point &vert1, const Point &vert2)
 
bool InitQuery (LSSCache &cache, const LSS &lss, const Matrix4x4 *worldl=null, const Matrix4x4 *worldm=null)
 

Detailed Description

Definition at line 88 of file Opcode.h.

Constructor & Destructor Documentation

HybridLSSCollider::HybridLSSCollider ( )

Constructor.

Definition at line 590 of file OPC_LSSCollider.cpp.

591 {
592 }
HybridLSSCollider::~HybridLSSCollider ( )
virtual

Destructor.

Definition at line 599 of file OPC_LSSCollider.cpp.

600 {
601 }

Member Function Documentation

bool HybridLSSCollider::Collide ( LSSCache cache,
const LSS lss,
const HybridModel model,
const Matrix4x4 worldl = null,
const Matrix4x4 worldm = null 
)

Definition at line 603 of file OPC_LSSCollider.cpp.

References Opcode::LSSCollider::_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(), LSS_PRIM, 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.

604 {
605  // We don't want primitive tests here!
607 
608  // Checkings
609  if(!Setup(&model)) return false;
610 
611  // Init collision query
612  if(InitQuery(cache, lss, worldl, worldm)) return true;
613 
614  // Special case for 1-leaf trees
616  {
617  // Here we're supposed to perform a normal query, except our tree has a single node, i.e. just a few triangles
618  udword Nb = mIMesh->GetNbTriangles();
619 
620  // Loop through all triangles
621  for(udword i=0;i<Nb;i++)
622  {
624  }
625  return true;
626  }
627 
628  // Override destination array since we're only going to get leaf boxes here
631 
632  // Now, do the actual query against leaf boxes
633  if(!model.HasLeafNodes())
634  {
635  if(model.IsQuantized())
636  {
637  const AABBQuantizedNoLeafTree* Tree = (const AABBQuantizedNoLeafTree*)model.GetTree();
638 
639  // Setup dequantization coeffs
640  mCenterCoeff = Tree->mCenterCoeff;
642 
643  // Perform collision query - we don't want primitive tests here!
644  _CollideNoPrimitiveTest(Tree->GetNodes());
645  }
646  else
647  {
648  const AABBNoLeafTree* Tree = (const AABBNoLeafTree*)model.GetTree();
649 
650  // Perform collision query - we don't want primitive tests here!
651  _CollideNoPrimitiveTest(Tree->GetNodes());
652  }
653  }
654  else
655  {
656  if(model.IsQuantized())
657  {
658  const AABBQuantizedTree* Tree = (const AABBQuantizedTree*)model.GetTree();
659 
660  // Setup dequantization coeffs
661  mCenterCoeff = Tree->mCenterCoeff;
663 
664  // Perform collision query - we don't want primitive tests here!
665  _CollideNoPrimitiveTest(Tree->GetNodes());
666  }
667  else
668  {
669  const AABBCollisionTree* Tree = (const AABBCollisionTree*)model.GetTree();
670 
671  // Perform collision query - we don't want primitive tests here!
672  _CollideNoPrimitiveTest(Tree->GetNodes());
673  }
674  }
675 
676  // We only have a list of boxes so far
677  if(GetContactStatus())
678  {
679  // Reset contact status, since it currently only reflects collisions with leaf boxes
681 
682  // Change dest container so that we can use built-in overlap tests and get collided primitives
683  cache.TouchedPrimitives.Reset();
685 
686  // Read touched leaf boxes
688  const udword* Touched = mTouchedBoxes.GetEntries();
689 
690  const LeafTriangles* LT = model.GetLeafTriangles();
691  const udword* Indices = model.GetIndices();
692 
693  // Loop through touched leaves
694  while(Nb--)
695  {
696  const LeafTriangles& CurrentLeaf = LT[*Touched++];
697 
698  // Each leaf box has a set of triangles
699  udword NbTris = CurrentLeaf.GetNbTriangles();
700  if(Indices)
701  {
702  const udword* T = &Indices[CurrentLeaf.GetTriangleIndex()];
703 
704  // Loop through triangles and test each of them
705  while(NbTris--)
706  {
707  udword TriangleIndex = *T++;
708  LSS_PRIM(TriangleIndex, OPC_CONTACT)
709  }
710  }
711  else
712  {
713  udword BaseIndex = CurrentLeaf.GetTriangleIndex();
714 
715  // Loop through triangles and test each of them
716  while(NbTris--)
717  {
718  udword TriangleIndex = BaseIndex++;
719  LSS_PRIM(TriangleIndex, OPC_CONTACT)
720  }
721  }
722  }
723  }
724 
725  return true;
726 }

Member Data Documentation

Container Opcode::HybridLSSCollider::mTouchedBoxes
protected

Definition at line 97 of file Opcode.h.


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