From c035de4e73a10256a3f9c56e805103f09493d80c Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Wed, 1 Apr 2015 11:38:54 -0700 Subject: [PATCH] cleanups --- tools/vhacd/src/VHACDUtil.cpp | 77 +++++++---------------------------- 1 file changed, 15 insertions(+), 62 deletions(-) diff --git a/tools/vhacd/src/VHACDUtil.cpp b/tools/vhacd/src/VHACDUtil.cpp index 8f41f67ad0..eab9a25b2c 100644 --- a/tools/vhacd/src/VHACDUtil.cpp +++ b/tools/vhacd/src/VHACDUtil.cpp @@ -13,7 +13,7 @@ #include "VHACDUtil.h" -//Read all the meshes from provided FBX file +// Read all the meshes from provided FBX file bool vhacd::VHACDUtil::loadFBX(const QString filename, FBXGeometry& result) { // open the fbx file @@ -38,37 +38,6 @@ bool vhacd::VHACDUtil::loadFBX(const QString filename, FBXGeometry& result) { } -// void vhacd::VHACDUtil::combineMeshes(FBXGeometryvhacd::LoadFBXResults *meshes, vhacd::LoadFBXResults *results) const { -// float largestDimension = 0; -// int indexStart = 0; - -// QVector emptyVertices; -// QVector emptyTriangles; -// results->perMeshVertices.append(emptyVertices); -// results->perMeshTriangleIndices.append(emptyTriangles); -// results->perMeshLargestDimension.append(largestDimension); - -// for (int i = 0; i < meshes->meshCount; i++) { -// QVector vertices = meshes->perMeshVertices.at(i); -// QVector triangles = meshes->perMeshTriangleIndices.at(i); -// const float largestDimension = meshes->perMeshLargestDimension.at(i); - -// for (int j = 0; j < triangles.size(); j++) { -// triangles[ j ] += indexStart; -// } -// indexStart += vertices.size(); - -// results->perMeshVertices[0] << vertices; -// results->perMeshTriangleIndices[0] << triangles; -// if (results->perMeshLargestDimension[0] < largestDimension) { -// results->perMeshLargestDimension[0] = largestDimension; -// } -// } - -// results->meshCount = 1; -// } - - // void vhacd::VHACDUtil::fattenMeshes(vhacd::LoadFBXResults *meshes, vhacd::LoadFBXResults *results) const { // for (int i = 0; i < meshes->meshCount; i++) { @@ -113,19 +82,6 @@ bool vhacd::VHACDUtil::computeVHACD(FBXGeometry& geometry, int startMeshIndex, int endMeshIndex, float minimumMeshSize, bool fattenFaces) { - - // vhacd::LoadFBXResults *meshes = new vhacd::LoadFBXResults; - // combineMeshes(inMeshes, meshes); - - // vhacd::LoadFBXResults *meshes = new vhacd::LoadFBXResults; - - // if (fattenFaces) { - // fattenMeshes(inMeshes, meshes); - // } else { - // meshes = inMeshes; - // } - - // count the mesh-parts QVector meshParts; int meshCount = 0; @@ -133,7 +89,6 @@ bool vhacd::VHACDUtil::computeVHACD(FBXGeometry& geometry, meshCount += mesh.parts.size(); } - VHACD::IVHACD * interfaceVHACD = VHACD::CreateVHACD(); if (startMeshIndex < 0) { @@ -143,12 +98,6 @@ bool vhacd::VHACDUtil::computeVHACD(FBXGeometry& geometry, endMeshIndex = meshCount; } - // for (int i = 0; i < meshCount; i++) { - // std::cout << meshes->perMeshTriangleIndices.at(i).size() << " "; - // } - // std::cout << "\n"; - - std::cout << "Performing V-HACD computation on " << endMeshIndex - startMeshIndex << " meshes ..... " << std::endl; result.meshExtents.reset(); @@ -200,6 +149,8 @@ bool vhacd::VHACDUtil::computeVHACD(FBXGeometry& geometry, // only process meshes with triangles if (triangles.size() <= 0) { + qDebug() << " Skipping (no triangles)..."; + count++; continue; } @@ -210,7 +161,8 @@ bool vhacd::VHACDUtil::computeVHACD(FBXGeometry& geometry, << "size =" << largestDimension; if (largestDimension < minimumMeshSize /* || largestDimension > 1000 */) { - qDebug() << " Skipping..."; + qDebug() << " Skipping (too small)..."; + count++; continue; } @@ -218,6 +170,7 @@ bool vhacd::VHACDUtil::computeVHACD(FBXGeometry& geometry, bool res = interfaceVHACD->Compute(&vertices[0].x, 3, nPoints, &triangles[0], 3, triangleCount, params); if (!res){ qDebug() << "V-HACD computation failed for Mesh : " << count; + count++; continue; } @@ -228,14 +181,11 @@ bool vhacd::VHACDUtil::computeVHACD(FBXGeometry& geometry, for (unsigned int j = 0; j < nConvexHulls; j++) { VHACD::IVHACD::ConvexHull hull; interfaceVHACD->GetConvexHull(j, hull); - // each convex-hull is a mesh-part + resultMesh.parts.append(FBXMeshPart()); FBXMeshPart &resultMeshPart = resultMesh.parts.last(); int hullIndexStart = resultMesh.vertices.size(); - - qDebug() << "j =" << j << "points =" << hull.m_nPoints << "tris =" << hull.m_nTriangles; - for (unsigned int i = 0; i < hull.m_nPoints; i++) { float x = hull.m_points[i * 3]; float y = hull.m_points[i * 3 + 1]; @@ -274,8 +224,11 @@ vhacd::VHACDUtil:: ~VHACDUtil(){ } //ProgressClaback implementation -void vhacd::ProgressCallback::Update(const double overallProgress, const double stageProgress, const double operationProgress, - const char * const stage, const char * const operation){ +void vhacd::ProgressCallback::Update(const double overallProgress, + const double stageProgress, + const double operationProgress, + const char* const stage, + const char* const operation) { int progress = (int)(overallProgress + 0.5); if (progress < 10){ @@ -287,9 +240,9 @@ void vhacd::ProgressCallback::Update(const double overallProgress, const double std::cout << progress << "%"; - if (progress >= 100){ - std::cout << std::endl; - } + if (progress >= 100){ + std::cout << std::endl; + } } vhacd::ProgressCallback::ProgressCallback(void){}