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

Method copyVertices

src/collision/ConvexMesh.cpp:77–113  ·  view source on GitHub ↗

Copy the vertices into the mesh

Source from the content-addressed store, hash-verified

75
76// Copy the vertices into the mesh
77bool ConvexMesh::copyVertices(const PolygonVertexArray& polygonVertexArray, std::vector<Message>& errors) {
78
79 bool isValid = true;
80
81 mCentroid.setToZero();
82
83 if (polygonVertexArray.getNbVertices() > 0) {
84 mBounds.setMin(polygonVertexArray.getVertex(0));
85 mBounds.setMax( polygonVertexArray.getVertex(0));
86 }
87
88 // For each vertex
89 for (uint32 i=0 ; i < polygonVertexArray.getNbVertices(); i++) {
90
91 const Vector3 vertex = polygonVertexArray.getVertex(i);
92 mVertices.add(vertex);
93
94 // Compute centroid
95 mCentroid += vertex;
96
97 // Inflate the bounds of the mesh with the vertex (if necessary)
98 mBounds.inflateWithPoint(vertex);
99 }
100
101 if (getNbVertices() > 0) {
102
103 mCentroid /= static_cast<decimal>(getNbVertices());
104 }
105 else {
106
107 errors.push_back(Message("The mesh does not have any vertices"));
108
109 isValid = false;
110 }
111
112 return isValid;
113}
114
115// Create the half-edge structure of the mesh
116/// This method returns true if the mesh is valid or false otherwise

Callers

nothing calls this directly

Calls 8

setMinMethod · 0.80
setMaxMethod · 0.80
inflateWithPointMethod · 0.80
MessageClass · 0.50
setToZeroMethod · 0.45
getNbVerticesMethod · 0.45
getVertexMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected