mirror of
https://github.com/JulianGro/overte.git
synced 2025-05-01 06:27:31 +02:00
cleanups
This commit is contained in:
parent
4859278214
commit
c035de4e73
1 changed files with 15 additions and 62 deletions
|
@ -13,7 +13,7 @@
|
||||||
#include "VHACDUtil.h"
|
#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) {
|
bool vhacd::VHACDUtil::loadFBX(const QString filename, FBXGeometry& result) {
|
||||||
|
|
||||||
// open the fbx file
|
// 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<glm::vec3> emptyVertices;
|
|
||||||
// QVector<int> emptyTriangles;
|
|
||||||
// results->perMeshVertices.append(emptyVertices);
|
|
||||||
// results->perMeshTriangleIndices.append(emptyTriangles);
|
|
||||||
// results->perMeshLargestDimension.append(largestDimension);
|
|
||||||
|
|
||||||
// for (int i = 0; i < meshes->meshCount; i++) {
|
|
||||||
// QVector<glm::vec3> vertices = meshes->perMeshVertices.at(i);
|
|
||||||
// QVector<int> 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 {
|
// void vhacd::VHACDUtil::fattenMeshes(vhacd::LoadFBXResults *meshes, vhacd::LoadFBXResults *results) const {
|
||||||
|
|
||||||
// for (int i = 0; i < meshes->meshCount; i++) {
|
// for (int i = 0; i < meshes->meshCount; i++) {
|
||||||
|
@ -113,19 +82,6 @@ bool vhacd::VHACDUtil::computeVHACD(FBXGeometry& geometry,
|
||||||
int startMeshIndex,
|
int startMeshIndex,
|
||||||
int endMeshIndex, float minimumMeshSize,
|
int endMeshIndex, float minimumMeshSize,
|
||||||
bool fattenFaces) {
|
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
|
// count the mesh-parts
|
||||||
QVector<FBXMeshPart> meshParts;
|
QVector<FBXMeshPart> meshParts;
|
||||||
int meshCount = 0;
|
int meshCount = 0;
|
||||||
|
@ -133,7 +89,6 @@ bool vhacd::VHACDUtil::computeVHACD(FBXGeometry& geometry,
|
||||||
meshCount += mesh.parts.size();
|
meshCount += mesh.parts.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VHACD::IVHACD * interfaceVHACD = VHACD::CreateVHACD();
|
VHACD::IVHACD * interfaceVHACD = VHACD::CreateVHACD();
|
||||||
|
|
||||||
if (startMeshIndex < 0) {
|
if (startMeshIndex < 0) {
|
||||||
|
@ -143,12 +98,6 @@ bool vhacd::VHACDUtil::computeVHACD(FBXGeometry& geometry,
|
||||||
endMeshIndex = meshCount;
|
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;
|
std::cout << "Performing V-HACD computation on " << endMeshIndex - startMeshIndex << " meshes ..... " << std::endl;
|
||||||
|
|
||||||
result.meshExtents.reset();
|
result.meshExtents.reset();
|
||||||
|
@ -200,6 +149,8 @@ bool vhacd::VHACDUtil::computeVHACD(FBXGeometry& geometry,
|
||||||
|
|
||||||
// only process meshes with triangles
|
// only process meshes with triangles
|
||||||
if (triangles.size() <= 0) {
|
if (triangles.size() <= 0) {
|
||||||
|
qDebug() << " Skipping (no triangles)...";
|
||||||
|
count++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,7 +161,8 @@ bool vhacd::VHACDUtil::computeVHACD(FBXGeometry& geometry,
|
||||||
<< "size =" << largestDimension;
|
<< "size =" << largestDimension;
|
||||||
|
|
||||||
if (largestDimension < minimumMeshSize /* || largestDimension > 1000 */) {
|
if (largestDimension < minimumMeshSize /* || largestDimension > 1000 */) {
|
||||||
qDebug() << " Skipping...";
|
qDebug() << " Skipping (too small)...";
|
||||||
|
count++;
|
||||||
continue;
|
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);
|
bool res = interfaceVHACD->Compute(&vertices[0].x, 3, nPoints, &triangles[0], 3, triangleCount, params);
|
||||||
if (!res){
|
if (!res){
|
||||||
qDebug() << "V-HACD computation failed for Mesh : " << count;
|
qDebug() << "V-HACD computation failed for Mesh : " << count;
|
||||||
|
count++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,14 +181,11 @@ bool vhacd::VHACDUtil::computeVHACD(FBXGeometry& geometry,
|
||||||
for (unsigned int j = 0; j < nConvexHulls; j++) {
|
for (unsigned int j = 0; j < nConvexHulls; j++) {
|
||||||
VHACD::IVHACD::ConvexHull hull;
|
VHACD::IVHACD::ConvexHull hull;
|
||||||
interfaceVHACD->GetConvexHull(j, hull);
|
interfaceVHACD->GetConvexHull(j, hull);
|
||||||
// each convex-hull is a mesh-part
|
|
||||||
resultMesh.parts.append(FBXMeshPart());
|
resultMesh.parts.append(FBXMeshPart());
|
||||||
FBXMeshPart &resultMeshPart = resultMesh.parts.last();
|
FBXMeshPart &resultMeshPart = resultMesh.parts.last();
|
||||||
|
|
||||||
int hullIndexStart = resultMesh.vertices.size();
|
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++) {
|
for (unsigned int i = 0; i < hull.m_nPoints; i++) {
|
||||||
float x = hull.m_points[i * 3];
|
float x = hull.m_points[i * 3];
|
||||||
float y = hull.m_points[i * 3 + 1];
|
float y = hull.m_points[i * 3 + 1];
|
||||||
|
@ -274,8 +224,11 @@ vhacd::VHACDUtil:: ~VHACDUtil(){
|
||||||
}
|
}
|
||||||
|
|
||||||
//ProgressClaback implementation
|
//ProgressClaback implementation
|
||||||
void vhacd::ProgressCallback::Update(const double overallProgress, const double stageProgress, const double operationProgress,
|
void vhacd::ProgressCallback::Update(const double overallProgress,
|
||||||
const char * const stage, const char * const operation){
|
const double stageProgress,
|
||||||
|
const double operationProgress,
|
||||||
|
const char* const stage,
|
||||||
|
const char* const operation) {
|
||||||
int progress = (int)(overallProgress + 0.5);
|
int progress = (int)(overallProgress + 0.5);
|
||||||
|
|
||||||
if (progress < 10){
|
if (progress < 10){
|
||||||
|
@ -287,9 +240,9 @@ void vhacd::ProgressCallback::Update(const double overallProgress, const double
|
||||||
|
|
||||||
std::cout << progress << "%";
|
std::cout << progress << "%";
|
||||||
|
|
||||||
if (progress >= 100){
|
if (progress >= 100){
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vhacd::ProgressCallback::ProgressCallback(void){}
|
vhacd::ProgressCallback::ProgressCallback(void){}
|
||||||
|
|
Loading…
Reference in a new issue