OPCODE_Model Class ReferenceList of all members.
Detailed DescriptionThe main collision wrapper, for all trees. Supported trees are:
1) Build an OPCODE_Model using a creation structure:
OPCODE_Model Sample; OPCODECREATE OPCC; OPCC.NbTris = ...; OPCC.NbVerts = ...; OPCC.Tris = ...; OPCC.Verts = ...; OPCC.Rules = ...; OPCC.NoLeaf = ...; OPCC.Quantized = ...; Sample.Build(OPCC); 2) Create a tree collider and setup it:
AABBTreeCollider TC; TC.SetFirstContact(...); TC.SetFullBoxBoxTest(...); TC.SetFullPrimBoxTest(...); TC.SetTemporalCoherence(...); 3) Setup object callbacks. Geometry & topology are NOT stored in the collision system, in order to save some ram. So, when the system needs them to perform accurate intersection tests, you're requested to provide the triangle-vertices corresponding to a given face index. Ex:
static void ColCallback(udword triangleindex, VertexPointers& triangle, udword userdata) { // Get back Mesh0 or Mesh1 (you also can use 2 different callbacks) Mesh* MyMesh = (Mesh*)userdata; // Get correct triangle in the app-controlled database const Triangle* Tri = MyMesh->GetTriangle(triangleindex); // Setup pointers to vertices for the collision system triangle.Vertex[0] = MyMesh->GetVertex(Tri->mVRef[0]); triangle.Vertex[1] = MyMesh->GetVertex(Tri->mVRef[1]); triangle.Vertex[2] = MyMesh->GetVertex(Tri->mVRef[2]); } // Setup callbacks TC.SetUserData0(udword(Mesh0)); TC.SetUserData1(udword(Mesh1)); TC.SetCallbackObj0(ColCallback); TC.SetCallbackObj1(ColCallback); Of course, you should make this callback as fast as possible. And you're also not supposed to modify the geometry *after* the collision trees have been built. The alternative was to store the geometry & topology in the collision system as well (as in RAPID) but we have found this approach to waste a lot of ram in many cases. 4) Perform a collision query
// Setup cache
static BVTCache ColCache;
ColCache.Model0 = &Model0;
ColCache.Model1 = &Model1;
// Collision query
bool IsOk = TC.Collide(ColCache, World0, World1);
// Get collision status => if true, objects overlap
bool Status = TC.GetContactStatus();
// Number of colliding pairs and list of pairs
udword NbPairs = TC.GetNbPairs();
Pair* p = TC.GetPairs()
5) Stats
Model0.GetUsedBytes() = number of bytes used for this collision tree
TC.GetNbBVBVTests() = number of BV-BV overlap tests performed during last query
TC.GetNbPrimPrimTests() = number of Triangle-Triangle overlap tests performed during last query
TC.GetNbBVPrimTests() = number of Triangle-BV overlap tests performed during last query
Constructor & Destructor Documentation
Member Function Documentation
The documentation for this class was generated from the following files:
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||