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

Method init

src/collision/TriangleMesh.cpp:42–67  ·  view source on GitHub ↗

Initialize the mesh using a TriangleVertexArray

Source from the content-addressed store, hash-verified

40
41// Initialize the mesh using a TriangleVertexArray
42bool TriangleMesh::init(const TriangleVertexArray& triangleVertexArray, std::vector<Message>& messages) {
43
44 bool isValid = true;
45
46 // Reserve memory for the vertices, faces and edges
47 mVertices.reserve(triangleVertexArray.getNbVertices());
48 mTriangles.reserve(triangleVertexArray.getNbTriangles() * 3);
49 mVerticesNormals.reserve(triangleVertexArray.getNbVertices());
50
51 computeEpsilon(triangleVertexArray);
52
53 // Create the half-edge structure of the mesh
54 isValid &= copyData(triangleVertexArray, messages);
55
56 // If the normals are not provided by the user
57 if (!triangleVertexArray.getHasNormals() && isValid) {
58
59 // Compute the normals
60 computeVerticesNormals();
61 }
62
63 // Insert all the triangles into the dynamic AABB tree
64 initBVHTree();
65
66 return isValid;
67}
68
69// Compute the epsilon value for this mesh
70void TriangleMesh::computeEpsilon(const TriangleVertexArray& triangleVertexArray) {

Callers

nothing calls this directly

Calls 4

getHasNormalsMethod · 0.80
reserveMethod · 0.45
getNbVerticesMethod · 0.45
getNbTrianglesMethod · 0.45

Tested by

no test coverage detected