Copy the vertices into the mesh
| 75 | |
| 76 | // Copy the vertices into the mesh |
| 77 | bool 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 |
nothing calls this directly
no test coverage detected