Add single node mesh

master
Jeremy HU 2022-10-18 21:06:49 +11:00
parent 57b1a802f3
commit 7c9626bcab
1 changed files with 23 additions and 17 deletions

View File

@ -38,6 +38,7 @@
#include <dust3d/mesh/trim_vertices.h> #include <dust3d/mesh/trim_vertices.h>
#include <dust3d/mesh/tube_mesh_builder.h> #include <dust3d/mesh/tube_mesh_builder.h>
#include <dust3d/mesh/weld_vertices.h> #include <dust3d/mesh/weld_vertices.h>
#include <dust3d/mesh/box_mesh.h>
#include <functional> #include <functional>
namespace dust3d { namespace dust3d {
@ -663,23 +664,28 @@ std::unique_ptr<MeshCombiner::Mesh> MeshGenerator::combinePartMesh(const std::st
partCache.joined = (target == PartTarget::Model && !isDisabled); partCache.joined = (target == PartTarget::Model && !isDisabled);
if (PartTarget::Model == target) { if (PartTarget::Model == target) {
std::unique_ptr<TubeMeshBuilder> tubeMeshBuilder; if (1 == meshNodes.size()) {
TubeMeshBuilder::BuildParameters buildParameters; size_t subdivideTimes = subdived ? 1 : 0;
buildParameters.deformThickness = deformThickness; buildBoxMesh(meshNodes[0].origin, meshNodes[0].radius, subdivideTimes, partCache.vertices, partCache.faces);
buildParameters.deformWidth = deformWidth; } else {
buildParameters.deformUnified = deformUnified; std::unique_ptr<TubeMeshBuilder> tubeMeshBuilder;
buildParameters.baseNormalRotation = cutRotation * Math::Pi; TubeMeshBuilder::BuildParameters buildParameters;
buildParameters.cutFace = cutTemplate; buildParameters.deformThickness = deformThickness;
buildParameters.frontEndRounded = buildParameters.backEndRounded = rounded; buildParameters.deformWidth = deformWidth;
tubeMeshBuilder = std::make_unique<TubeMeshBuilder>(buildParameters, std::move(meshNodes), isCircle); buildParameters.deformUnified = deformUnified;
tubeMeshBuilder->build(); buildParameters.baseNormalRotation = cutRotation * Math::Pi;
partCache.vertices = tubeMeshBuilder->generatedVertices(); buildParameters.cutFace = cutTemplate;
partCache.faces = tubeMeshBuilder->generatedFaces(); buildParameters.frontEndRounded = buildParameters.backEndRounded = rounded;
if (!__mirrorFromPartId.empty()) { tubeMeshBuilder = std::make_unique<TubeMeshBuilder>(buildParameters, std::move(meshNodes), isCircle);
for (auto& it : partCache.vertices) tubeMeshBuilder->build();
it.setX(-it.x()); partCache.vertices = tubeMeshBuilder->generatedVertices();
for (auto& it : partCache.faces) partCache.faces = tubeMeshBuilder->generatedFaces();
std::reverse(it.begin(), it.end()); 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) { } else if (PartTarget::CutFace == target) {
std::unique_ptr<SectionPreviewMeshBuilder> sectionPreviewMeshBuilder; std::unique_ptr<SectionPreviewMeshBuilder> sectionPreviewMeshBuilder;