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

Method init

src/collision/ConvexMesh.cpp:51–74  ·  view source on GitHub ↗

Initialize a mesh and returns errors if any

Source from the content-addressed store, hash-verified

49
50// Initialize a mesh and returns errors if any
51bool ConvexMesh::init(const PolygonVertexArray& polygonVertexArray, std::vector<Message>& errors) {
52
53 bool isValid = true;
54
55 // Reserve memory for the vertices, faces and edges
56 mVertices.reserve(polygonVertexArray.getNbVertices());
57 mFacesNormals.reserve(polygonVertexArray.getNbFaces());
58 mHalfEdgeStructure.reserve(polygonVertexArray.getNbFaces(), polygonVertexArray.getNbVertices(),
59 (polygonVertexArray.getNbVertices() + polygonVertexArray.getNbFaces() - 2) * 2);
60
61 // Copy the vertices from the PolygonVertexArray into the mesh
62 isValid &= copyVertices(polygonVertexArray, errors);
63
64 // Create the half-edge structure of the mesh
65 isValid &= createHalfEdgeStructure(polygonVertexArray, errors);
66
67 // Compute the faces normals
68 isValid &= computeFacesNormals(errors);
69
70 // Compute the volume of the mesh
71 computeVolume();
72
73 return isValid;
74}
75
76// Copy the vertices into the mesh
77bool ConvexMesh::copyVertices(const PolygonVertexArray& polygonVertexArray, std::vector<Message>& errors) {

Callers

nothing calls this directly

Calls 3

reserveMethod · 0.45
getNbVerticesMethod · 0.45
getNbFacesMethod · 0.45

Tested by

no test coverage detected