Mark remeshed component as Uncombined

master
Jeremy Hu 2020-01-04 22:19:03 +09:30
parent 2d05583937
commit 8c6a9fef29
1 changed files with 20 additions and 3 deletions

View File

@ -716,9 +716,12 @@ MeshCombiner::Mesh *MeshGenerator::combinePartMesh(const QString &partIdString,
it += xMirrorStart; it += xMirrorStart;
partCache.faces.push_back(newFace); partCache.faces.push_back(newFace);
} }
MeshCombiner::Mesh *newMesh = nullptr;
MeshCombiner::Mesh *xMirroredMesh = new MeshCombiner::Mesh(xMirroredVertices, xMirroredFaces, false); MeshCombiner::Mesh *xMirroredMesh = new MeshCombiner::Mesh(xMirroredVertices, xMirroredFaces, false);
MeshCombiner::Mesh *newMesh = combineTwoMeshes(*mesh, if (!xMirroredMesh->isNull()) {
*xMirroredMesh, MeshCombiner::Method::Union); newMesh = combineTwoMeshes(*mesh,
*xMirroredMesh, MeshCombiner::Method::Union);
}
delete xMirroredMesh; delete xMirroredMesh;
if (newMesh && !newMesh->isNull()) { if (newMesh && !newMesh->isNull()) {
delete mesh; delete mesh;
@ -834,6 +837,8 @@ CombineMode MeshGenerator::componentCombineMode(const std::map<QString, QString>
if (combineMode == CombineMode::Normal) { if (combineMode == CombineMode::Normal) {
if (isTrueValueString(valueOfKeyInMapOrEmpty(*component, "inverse"))) if (isTrueValueString(valueOfKeyInMapOrEmpty(*component, "inverse")))
combineMode = CombineMode::Inversion; combineMode = CombineMode::Inversion;
if (componentRemeshed(component))
combineMode = CombineMode::Uncombined;
} }
return combineMode; return combineMode;
} }
@ -1058,8 +1063,16 @@ MeshCombiner::Mesh *MeshGenerator::combineComponentMesh(const QString &component
delete mesh; delete mesh;
mesh = new MeshCombiner::Mesh(newVertices, newTriangles, componentId.isNull()); mesh = new MeshCombiner::Mesh(newVertices, newTriangles, componentId.isNull());
if (nullptr != mesh) { if (nullptr != mesh) {
if (!componentId.isNull()) {
if (mesh->isNull()) {
delete mesh;
mesh = nullptr;
}
}
delete componentCache.mesh; delete componentCache.mesh;
componentCache.mesh = new MeshCombiner::Mesh(*mesh); componentCache.mesh = nullptr;
if (nullptr != mesh)
componentCache.mesh = new MeshCombiner::Mesh(*mesh);
} }
} }
} }
@ -1198,6 +1211,10 @@ MeshCombiner::Mesh *MeshGenerator::combineTwoMeshes(const MeshCombiner::Mesh &fi
} }
} }
} }
if (newMesh->isNull()) {
delete newMesh;
return nullptr;
}
return newMesh; return newMesh;
} }