diff --git a/application/sources/document.cc b/application/sources/document.cc index 5cd77126..c7c9c144 100644 --- a/application/sources/document.cc +++ b/application/sources/document.cc @@ -860,7 +860,6 @@ void Document::generateMesh() m_meshGenerator = new MeshGenerator(snapshot); m_meshGenerator->setId(m_nextMeshGenerationId++); m_meshGenerator->setDefaultPartColor(dust3d::Color::createWhite()); - m_meshGenerator->setInterpolationEnabled(true); if (nullptr == m_generatedCacheContext) m_generatedCacheContext = new MeshGenerator::GeneratedCacheContext; m_meshGenerator->setGeneratedCacheContext((dust3d::MeshGenerator::GeneratedCacheContext *)m_generatedCacheContext); diff --git a/dust3d/mesh/mesh_generator.cc b/dust3d/mesh/mesh_generator.cc index 9c06f195..a6660245 100644 --- a/dust3d/mesh/mesh_generator.cc +++ b/dust3d/mesh/mesh_generator.cc @@ -571,9 +571,7 @@ std::unique_ptr MeshGenerator::combineStitchingMesh(const st } std::unique_ptr MeshGenerator::combinePartMesh(const std::string &partIdString, - bool *hasError, - bool *retryable, - bool addIntermediateNodes) + bool *hasError) { auto findPart = m_snapshot->parts.find(partIdString); if (findPart == m_snapshot->parts.end()) { @@ -582,8 +580,6 @@ std::unique_ptr MeshGenerator::combinePartMesh(const std::st Uuid partId = Uuid(partIdString); auto &part = findPart->second; - - *retryable = true; bool isDisabled = String::isTrue(String::valueOrEmpty(part, "disabled")); std::string __mirroredByPartId = String::valueOrEmpty(part, "__mirroredByPartId"); @@ -659,21 +655,6 @@ std::unique_ptr MeshGenerator::combinePartMesh(const std::st if (!fetchPartOrderedNodes(searchPartIdString, &meshNodes, &isCircle)) return nullptr; - // TODO: Generate section preview mesh - // ... ... - - std::unique_ptr tubeMeshBuilder; - - TubeMeshBuilder::BuildParameters buildParameters; - buildParameters.deformThickness = deformThickness; - buildParameters.deformWidth = deformWidth; - buildParameters.deformUnified = deformUnified; - buildParameters.baseNormalRotation = cutRotation * Math::Pi; - buildParameters.cutFace = cutTemplate; - buildParameters.frontEndRounded = buildParameters.backEndRounded = rounded; - tubeMeshBuilder = std::make_unique(buildParameters, std::move(meshNodes), isCircle); - tubeMeshBuilder->build(); - auto &partCache = m_cacheContext->parts[partIdString]; partCache.objectNodes.clear(); partCache.objectEdges.clear(); @@ -685,13 +666,32 @@ std::unique_ptr MeshGenerator::combinePartMesh(const std::st partCache.roughness = roughness; partCache.isSuccessful = false; partCache.joined = (target == PartTarget::Model && !isDisabled); - partCache.vertices = tubeMeshBuilder->generatedVertices(); - partCache.faces = tubeMeshBuilder->generatedFaces(); - if (!__mirrorFromPartId.empty()) { - for (auto &it: partCache.vertices) - it.setX(-it.x()); - for (auto &it: partCache.faces) - std::reverse(it.begin(), it.end()); + + if (PartTarget::Model == target) { + std::unique_ptr tubeMeshBuilder; + TubeMeshBuilder::BuildParameters buildParameters; + buildParameters.deformThickness = deformThickness; + buildParameters.deformWidth = deformWidth; + buildParameters.deformUnified = deformUnified; + buildParameters.baseNormalRotation = cutRotation * Math::Pi; + buildParameters.cutFace = cutTemplate; + buildParameters.frontEndRounded = buildParameters.backEndRounded = rounded; + tubeMeshBuilder = std::make_unique(buildParameters, std::move(meshNodes), isCircle); + tubeMeshBuilder->build(); + partCache.vertices = tubeMeshBuilder->generatedVertices(); + partCache.faces = tubeMeshBuilder->generatedFaces(); + if (!__mirrorFromPartId.empty()) { + for (auto &it: partCache.vertices) + it.setX(-it.x()); + for (auto &it: partCache.faces) + std::reverse(it.begin(), it.end()); + } + } else if (PartTarget::CutFace == target) { + std::unique_ptr sectionPreviewMeshBuilder; + sectionPreviewMeshBuilder = std::make_unique(cutTemplate); + sectionPreviewMeshBuilder->build(); + partCache.vertices = sectionPreviewMeshBuilder->resultVertices(); + partCache.faces = sectionPreviewMeshBuilder->resultTriangles(); } bool hasMeshError = false; @@ -709,17 +709,11 @@ std::unique_ptr MeshGenerator::combinePartMesh(const std::st if (mesh && mesh->isNull()) { mesh.reset(); } - - //if (target != PartTarget::Model) { - // mesh.reset(); - //} if (hasMeshError && target == PartTarget::Model) { *hasError = true; } - // TODO: - return mesh; } @@ -1150,17 +1144,9 @@ std::unique_ptr MeshGenerator::combineComponentMesh(const st if ("partId" == linkDataType) { std::string partIdString = String::valueOrEmpty(*component, "linkData"); bool hasError = false; - bool retryable = true; - mesh = combinePartMesh(partIdString, &hasError, &retryable, m_interpolationEnabled); + mesh = combinePartMesh(partIdString, &hasError); if (hasError) { - mesh.reset(); - if (retryable && m_interpolationEnabled) { - hasError = false; - mesh = combinePartMesh(partIdString, &hasError, &retryable, false); - } - if (hasError) { - m_isSuccessful = false; - } + m_isSuccessful = false; } const auto &partCache = m_cacheContext->parts[partIdString]; if (partCache.joined) { @@ -1408,11 +1394,6 @@ void MeshGenerator::setSmoothShadingThresholdAngleDegrees(float degrees) m_smoothShadingThresholdAngleDegrees = degrees; } -void MeshGenerator::setInterpolationEnabled(bool interpolationEnabled) -{ - m_interpolationEnabled = interpolationEnabled; -} - void MeshGenerator::setWeldEnabled(bool enabled) { m_weldEnabled = enabled; diff --git a/dust3d/mesh/mesh_generator.h b/dust3d/mesh/mesh_generator.h index 48cd9523..fec2bfe7 100644 --- a/dust3d/mesh/mesh_generator.h +++ b/dust3d/mesh/mesh_generator.h @@ -95,7 +95,6 @@ public: virtual void generate(); void setGeneratedCacheContext(GeneratedCacheContext *cacheContext); void setSmoothShadingThresholdAngleDegrees(float degrees); - void setInterpolationEnabled(bool interpolationEnabled); void setDefaultPartColor(const Color &color); void setId(uint64_t id); void setWeldEnabled(bool enabled); @@ -123,7 +122,6 @@ private: float m_smoothShadingThresholdAngleDegrees = 60; uint64_t m_id = 0; bool m_weldEnabled = true; - bool m_interpolationEnabled = true; void collectParts(); void collectIncombinableMesh(const MeshCombiner::Mesh *mesh, const GeneratedComponent &componentCache); @@ -132,9 +130,7 @@ private: bool checkIsPartDependencyDirty(const std::string &partIdString); void checkDirtyFlags(); std::unique_ptr combinePartMesh(const std::string &partIdString, - bool *hasError, - bool *retryable, - bool addIntermediateNodes=true); + bool *hasError); std::unique_ptr combineComponentMesh(const std::string &componentIdString, CombineMode *combineMode); void makeXmirror(const std::vector &sourceVertices, const std::vector> &sourceFaces, std::vector *destVertices, std::vector> *destFaces);