MCPcopy Create free account
hub / github.com/DanielChappuis/reactphysics3d / initBVHTree

Method initBVHTree

src/collision/TriangleMesh.cpp:242–263  ·  view source on GitHub ↗

Insert all the triangles into the dynamic AABB tree

Source from the content-addressed store, hash-verified

240
241// Insert all the triangles into the dynamic AABB tree
242void TriangleMesh::initBVHTree() {
243
244 assert(mTriangles.size() % 3 == 0);
245
246 // TODO : Try to randomly add the triangles into the tree to obtain a better tree
247
248 // For each triangle of the mesh
249 for (uint32 f=0; f < mTriangles.size() / 3; f++) {
250
251 // Get the triangle vertices
252 Vector3 trianglePoints[3];
253 trianglePoints[0] = mVertices[mTriangles[f * 3]];
254 trianglePoints[1] = mVertices[mTriangles[f * 3 + 1]];
255 trianglePoints[2] = mVertices[mTriangles[f * 3 + 2]];
256
257 // Create the AABB for the triangle
258 AABB aabb = AABB::createAABBForTriangle(trianglePoints);
259
260 // Add the AABB with the index of the triangle into the dynamic AABB tree
261 mDynamicAABBTree.addObject(aabb, f);
262 }
263}
264
265// Return the minimum bounds of the mesh in the x,y,z direction
266/**

Callers

nothing calls this directly

Calls 2

addObjectMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected