Insert all the triangles into the dynamic AABB tree
| 240 | |
| 241 | // Insert all the triangles into the dynamic AABB tree |
| 242 | void 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 | /** |