Build the new faces that contain the new vertex and the horizon edges
| 242 | |
| 243 | // Build the new faces that contain the new vertex and the horizon edges |
| 244 | void QuickHull::buildNewFaces(uint32 newVertexIndex, |
| 245 | Array<QHHalfEdgeStructure::Vertex*>& horizonVertices, |
| 246 | QHHalfEdgeStructure& convexHull, |
| 247 | Array<Vector3>& points, |
| 248 | Array<QHHalfEdgeStructure::Face*>& newFaces, |
| 249 | MemoryAllocator& allocator) { |
| 250 | |
| 251 | // Add the new vertex to the convex hull |
| 252 | QHHalfEdgeStructure::Vertex* v = convexHull.addVertex(newVertexIndex); |
| 253 | |
| 254 | Array<QHHalfEdgeStructure::Vertex*> faceVertices(allocator, 8); |
| 255 | |
| 256 | // For each horizon edge |
| 257 | for (uint32 i=0; i < horizonVertices.size(); i += 2) { |
| 258 | |
| 259 | QHHalfEdgeStructure::Vertex* v2 = horizonVertices[i]; |
| 260 | QHHalfEdgeStructure::Vertex* v3 = horizonVertices[i+1]; |
| 261 | |
| 262 | // Create the vertices of a triangular face |
| 263 | faceVertices.add(v2); |
| 264 | faceVertices.add(v3); |
| 265 | faceVertices.add(v); |
| 266 | |
| 267 | // Create a new face |
| 268 | QHHalfEdgeStructure::Face* face = convexHull.addFace(faceVertices, points, allocator); |
| 269 | |
| 270 | newFaces.add(face); |
| 271 | |
| 272 | faceVertices.clear(); |
| 273 | } |
| 274 | } |
| 275 | |
| 276 | // Delete all the faces visible from the vertex to be added |
| 277 | void QuickHull::deleteVisibleFaces(const Array<QHHalfEdgeStructure::Face*>& visibleFaces, |