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

#include <Opcode.h>

Inheritance diagram for Opcode::HybridOBBCollider:
Opcode::OBBCollider Opcode::VolumeCollider Opcode::Collider

Public Member Functions

 HybridOBBCollider ()
 
virtual ~HybridOBBCollider ()
 
bool Collide (OBBCache &cache, const OBB &box, const HybridModel &model, const Matrix4x4 *worldb=null, const Matrix4x4 *worldm=null)
 
- Public Member Functions inherited from Opcode::OBBCollider
 OBBCollider ()
 
virtual ~OBBCollider ()
 
bool Collide (OBBCache &cache, const OBB &box, const Model &model, const Matrix4x4 *worldb=null, const Matrix4x4 *worldm=null)
 
inline_ void SetFullBoxBoxTest (bool flag)
 
 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::OBBCollider
Matrix3x3 mAR
 Absolute rotation matrix. More...
 
Matrix3x3 mRModelToBox
 Rotation from model space to obb space. More...
 
Matrix3x3 mRBoxToModel
 Rotation from obb space to model space. More...
 
Point mTModelToBox
 Translation from model space to obb space. More...
 
Point mTBoxToModel
 Translation from obb space to model space. More...
 
Point mBoxExtents
 
Point mB0
 
Point mB1
 
float mBBx1
 
float mBBy1
 
float mBBz1
 
float mBB_1
 
float mBB_2
 
float mBB_3
 
float mBB_4
 
float mBB_5
 
float mBB_6
 
float mBB_7
 
float mBB_8
 
float mBB_9
 
Point mLeafVerts [3]
 Triangle vertices. More...
 
bool mFullBoxBoxTest
 Perform full BV-BV tests (true) or SAT-lite tests (false) 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::OBBCollider
void _Collide (const AABBCollisionNode *node)
 
void _Collide (const AABBNoLeafNode *node)
 
void _Collide (const AABBQuantizedNode *node)
 
void _Collide (const AABBQuantizedNoLeafNode *node)
 
void _CollideNoPrimitiveTest (const AABBCollisionNode *node)
 
void _CollideNoPrimitiveTest (const AABBNoLeafNode *node)
 
void _CollideNoPrimitiveTest (const AABBQuantizedNode *node)
 
void _CollideNoPrimitiveTest (const AABBQuantizedNoLeafNode *node)
 
inline_ bool OBBContainsBox (const Point &bc, const Point &be)
 
inline_ bool BoxBoxOverlap (const Point &extents, const Point &center)
 
inline_ bool TriBoxOverlap ()
 
bool InitQuery (OBBCache &cache, const OBB &box, const Matrix4x4 *worldb=null, const Matrix4x4 *worldm=null)
 

Detailed Description

Definition at line 131 of file Opcode.h.

Constructor & Destructor Documentation

HybridOBBCollider::HybridOBBCollider ( )

Constructor.

Definition at line 632 of file OPC_OBBCollider.cpp.

633 {
634 }
HybridOBBCollider::~HybridOBBCollider ( )
virtual

Destructor.

Definition at line 641 of file OPC_OBBCollider.cpp.

642 {
643 }

Member Function Documentation

bool HybridOBBCollider::Collide ( OBBCache cache,
const OBB box,
const HybridModel model,
const Matrix4x4 worldb = null,
const Matrix4x4 worldm = null 
)

Definition at line 645 of file OPC_OBBCollider.cpp.

References Opcode::OBBCollider::_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::VolumeCollider::mTouchedPrimitives, OBB_PRIM, Opcode::OPC_CONTACT, Opcode::OPC_NO_PRIMITIVE_TESTS, Container::Reset(), Opcode::Collider::Setup(), and Opcode::VolumeCache::TouchedPrimitives.

646 {
647  // We don't want primitive tests here!
649 
650  // Checkings
651  if(!Setup(&model)) return false;
652 
653  // Init collision query
654  if(InitQuery(cache, box, worldb, worldm)) return true;
655 
656  // Special case for 1-leaf trees
658  {
659  // Here we're supposed to perform a normal query, except our tree has a single node, i.e. just a few triangles
660  udword Nb = mIMesh->GetNbTriangles();
661 
662  // Loop through all triangles
663  for(udword i=0;i<Nb;i++)
664  {
666  }
667  return true;
668  }
669 
670  // Override destination array since we're only going to get leaf boxes here
673 
674  // Now, do the actual query against leaf boxes
675  if(!model.HasLeafNodes())
676  {
677  if(model.IsQuantized())
678  {
679  const AABBQuantizedNoLeafTree* Tree = (const AABBQuantizedNoLeafTree*)model.GetTree();
680 
681  // Setup dequantization coeffs
682  mCenterCoeff = Tree->mCenterCoeff;
684 
685  // Perform collision query - we don't want primitive tests here!
686  _CollideNoPrimitiveTest(Tree->GetNodes());
687  }
688  else
689  {
690  const AABBNoLeafTree* Tree = (const AABBNoLeafTree*)model.GetTree();
691 
692  // Perform collision query - we don't want primitive tests here!
693  _CollideNoPrimitiveTest(Tree->GetNodes());
694  }
695  }
696  else
697  {
698  if(model.IsQuantized())
699  {
700  const AABBQuantizedTree* Tree = (const AABBQuantizedTree*)model.GetTree();
701 
702  // Setup dequantization coeffs
703  mCenterCoeff = Tree->mCenterCoeff;
705 
706  // Perform collision query - we don't want primitive tests here!
707  _CollideNoPrimitiveTest(Tree->GetNodes());
708  }
709  else
710  {
711  const AABBCollisionTree* Tree = (const AABBCollisionTree*)model.GetTree();
712 
713  // Perform collision query - we don't want primitive tests here!
714  _CollideNoPrimitiveTest(Tree->GetNodes());
715  }
716  }
717 
718  // We only have a list of boxes so far
719  if(GetContactStatus())
720  {
721  // Reset contact status, since it currently only reflects collisions with leaf boxes
723 
724  // Change dest container so that we can use built-in overlap tests and get collided primitives
725  cache.TouchedPrimitives.Reset();
727 
728  // Read touched leaf boxes
730  const udword* Touched = mTouchedBoxes.GetEntries();
731 
732  const LeafTriangles* LT = model.GetLeafTriangles();
733  const udword* Indices = model.GetIndices();
734 
735  // Loop through touched leaves
736  while(Nb--)
737  {
738  const LeafTriangles& CurrentLeaf = LT[*Touched++];
739 
740  // Each leaf box has a set of triangles
741  udword NbTris = CurrentLeaf.GetNbTriangles();
742  if(Indices)
743  {
744  const udword* T = &Indices[CurrentLeaf.GetTriangleIndex()];
745 
746  // Loop through triangles and test each of them
747  while(NbTris--)
748  {
749  udword TriangleIndex = *T++;
750  OBB_PRIM(TriangleIndex, OPC_CONTACT)
751  }
752  }
753  else
754  {
755  udword BaseIndex = CurrentLeaf.GetTriangleIndex();
756 
757  // Loop through triangles and test each of them
758  while(NbTris--)
759  {
760  udword TriangleIndex = BaseIndex++;
761  OBB_PRIM(TriangleIndex, OPC_CONTACT)
762  }
763  }
764  }
765  }
766 
767  return true;
768 }

Member Data Documentation

Container Opcode::HybridOBBCollider::mTouchedBoxes
protected

Definition at line 140 of file Opcode.h.


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