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,6 +664,10 @@ 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) {
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; std::unique_ptr<TubeMeshBuilder> tubeMeshBuilder;
TubeMeshBuilder::BuildParameters buildParameters; TubeMeshBuilder::BuildParameters buildParameters;
buildParameters.deformThickness = deformThickness; buildParameters.deformThickness = deformThickness;
@ -681,6 +686,7 @@ std::unique_ptr<MeshCombiner::Mesh> MeshGenerator::combinePartMesh(const std::st
for (auto& it : partCache.faces) for (auto& it : partCache.faces)
std::reverse(it.begin(), it.end()); 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;
sectionPreviewMeshBuilder = std::make_unique<SectionPreviewMeshBuilder>(cutTemplate); sectionPreviewMeshBuilder = std::make_unique<SectionPreviewMeshBuilder>(cutTemplate);