diff --git a/tools/vhacd/src/VHACDUtil.cpp b/tools/vhacd/src/VHACDUtil.cpp index 4f2cb0e2b8..faec01ef14 100644 --- a/tools/vhacd/src/VHACDUtil.cpp +++ b/tools/vhacd/src/VHACDUtil.cpp @@ -54,9 +54,24 @@ bool vhacd::VHACDUtil::loadFBX(const QString filename, vhacd::LoadFBXResults *re //get the triangle indices for each mesh QVector triangles; - foreach(FBXMeshPart part, mesh.parts){ - QVector indices = part.triangleIndices; + foreach(FBXMeshPart meshPart, mesh.parts){ + QVector indices = meshPart.triangleIndices; triangles += indices; + + unsigned int quadCount = meshPart.quadIndices.size() / 4; + for (unsigned int i = 0; i < quadCount; i++) { + unsigned int p0Index = meshPart.quadIndices[i*4]; + unsigned int p1Index = meshPart.quadIndices[i*4+1]; + unsigned int p2Index = meshPart.quadIndices[i*4+2]; + unsigned int p3Index = meshPart.quadIndices[i*4+3]; + // split each quad into two triangles + triangles.append(p0Index); + triangles.append(p1Index); + triangles.append(p2Index); + triangles.append(p0Index); + triangles.append(p2Index); + triangles.append(p3Index); + } } //only read meshes with triangles @@ -148,21 +163,26 @@ void vhacd::VHACDUtil::fattenMeshes(vhacd::LoadFBXResults *meshes, vhacd::LoadFB -bool vhacd::VHACDUtil::computeVHACD(vhacd::LoadFBXResults *meshes, VHACD::IVHACD::Parameters params, +bool vhacd::VHACDUtil::computeVHACD(vhacd::LoadFBXResults *inMeshes, VHACD::IVHACD::Parameters params, vhacd::ComputeResults *results, - int startMeshIndex, int endMeshIndex, float minimumMeshSize) const { + int startMeshIndex, int endMeshIndex, float minimumMeshSize, + bool fattenFaces) const { - // vhacd::LoadFBXResults *meshes = new vhacd::LoadFBXResults; + vhacd::LoadFBXResults *meshes = new vhacd::LoadFBXResults; // combineMeshes(inMeshes, meshes); // vhacd::LoadFBXResults *meshes = new vhacd::LoadFBXResults; - // fattenMeshes(inMeshes, meshes); + + if (fattenFaces) { + fattenMeshes(inMeshes, meshes); + } else { + meshes = inMeshes; + } VHACD::IVHACD * interfaceVHACD = VHACD::CreateVHACD(); int meshCount = meshes->meshCount; int count = 0; - std::cout << "Performing V-HACD computation on " << meshCount << " meshes ..... " << std::endl; if (startMeshIndex < 0) { startMeshIndex = 0; @@ -171,6 +191,8 @@ bool vhacd::VHACDUtil::computeVHACD(vhacd::LoadFBXResults *meshes, VHACD::IVHACD endMeshIndex = meshCount; } + std::cout << "Performing V-HACD computation on " << endMeshIndex - startMeshIndex << " meshes ..... " << std::endl; + for (int i = startMeshIndex; i < endMeshIndex; i++){ qDebug() << "--------------------"; std::vector vertices = meshes->perMeshVertices.at(i).toStdVector(); @@ -211,7 +233,6 @@ bool vhacd::VHACDUtil::computeVHACD(vhacd::LoadFBXResults *meshes, VHACD::IVHACD } hull.m_points = m_points_copy; - int *m_triangles_copy = new int[hull.m_nTriangles * 3]; // std::copy(std::begin(hull.m_triangles), std::end(hull.m_triangles), std::begin(m_triangles_copy)); for (unsigned int i=0; i