diff --git a/dust3d/mesh/mesh_generator.cc b/dust3d/mesh/mesh_generator.cc index 52886396..40f2f83b 100644 --- a/dust3d/mesh/mesh_generator.cc +++ b/dust3d/mesh/mesh_generator.cc @@ -38,6 +38,7 @@ #include #include #include +#include #include namespace dust3d { @@ -663,23 +664,28 @@ std::unique_ptr MeshGenerator::combinePartMesh(const std::st partCache.joined = (target == PartTarget::Model && !isDisabled); 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()); + if (1 == meshNodes.size()) { + size_t subdivideTimes = subdived ? 1 : 0; + buildBoxMesh(meshNodes[0].origin, meshNodes[0].radius, subdivideTimes, partCache.vertices, partCache.faces); + } else { + 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;