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

Method createConvexMesh

src/engine/PhysicsCommon.cpp:607–629  ·  view source on GitHub ↗

Create a convex mesh from a PolygonVertexArray describing vertices and faces The data (vertices, faces indices, ...) are copied from the PolygonVertexArray into the created ConvexMesh. * @param polygonVertexArray A pointer to the polygon vertex array to use to create the convex mesh * @param messages A reference to a vector of messages. This vector might contains errors that occured during the cr

Source from the content-addressed store, hash-verified

605 * @return A pointer to the created ConvexMesh instance or nullptr if errors occured during the creation
606 */
607ConvexMesh* PhysicsCommon::createConvexMesh(const PolygonVertexArray& polygonVertexArray, std::vector<Message>& messages) {
608
609 MemoryAllocator& allocator = mMemoryManager.getHeapAllocator();
610
611 // Create the convex mesh
612 ConvexMesh* mesh = new (mMemoryManager.allocate(MemoryManager::AllocationType::Pool, sizeof(ConvexMesh))) ConvexMesh(allocator);
613
614 // Create the half-edge structure of the mesh
615 bool isValid = mesh->init(polygonVertexArray, messages);
616
617 // If the mesh is not valid
618 if (!isValid) {
619 mesh->~ConvexMesh();
620 allocator.release(mesh, sizeof(ConvexMesh));
621 return nullptr;
622 }
623
624 // If the mesh is valid
625
626 mConvexMeshes.add(mesh);
627
628 return mesh;
629}
630
631// Create a convex mesh from an array of vertices (automatically computing the convex hull using QuickHull)
632/// The data (vertices) are copied from the VertexArray into the created ConvexMesh.

Callers 8

testConvexHullsMethod · 0.80
TestRigidBodyMethod · 0.80
TestPointInsideMethod · 0.80
TestRaycastMethod · 0.80
TestConvexMeshMethod · 0.80
TestWorldQueriesMethod · 0.80
ConvexMeshMethod · 0.80
ConvexHullMethod · 0.80

Calls 5

~ConvexMeshMethod · 0.80
allocateMethod · 0.45
initMethod · 0.45
releaseMethod · 0.45
addMethod · 0.45

Tested by 6

testConvexHullsMethod · 0.64
TestRigidBodyMethod · 0.64
TestPointInsideMethod · 0.64
TestRaycastMethod · 0.64
TestConvexMeshMethod · 0.64
TestWorldQueriesMethod · 0.64