Enable three nodes branch on gridded part

master
Jeremy Hu 2019-12-15 11:44:04 +09:30
parent 4f6c82d825
commit 40a6968599
4 changed files with 16 additions and 5 deletions

View File

@ -421,14 +421,17 @@ void GridMeshBuilder::setSubdived(bool subdived)
m_subdived = subdived; m_subdived = subdived;
} }
void GridMeshBuilder::build() bool GridMeshBuilder::build()
{ {
if (m_subdived) if (m_subdived)
applyModifiers(); applyModifiers();
prepareNodeVertices(); prepareNodeVertices();
findCycles(); findCycles();
if (m_cycles.empty())
return false;
generateFaces(); generateFaces();
extrude(); extrude();
return true;
} }
void GridMeshBuilder::findCycles() void GridMeshBuilder::findCycles()
@ -442,3 +445,4 @@ void GridMeshBuilder::findCycles()
cycleFinder.find(); cycleFinder.find();
m_cycles = cycleFinder.getCycles(); m_cycles = cycleFinder.getCycles();
} }

View File

@ -25,7 +25,7 @@ public:
size_t addNode(const QVector3D &position, float radius); size_t addNode(const QVector3D &position, float radius);
size_t addEdge(size_t firstNodeIndex, size_t secondNodeIndex); size_t addEdge(size_t firstNodeIndex, size_t secondNodeIndex);
void setSubdived(bool subdived); void setSubdived(bool subdived);
void build(); bool build();
const std::vector<QVector3D> &getGeneratedPositions(); const std::vector<QVector3D> &getGeneratedPositions();
const std::vector<size_t> &getGeneratedSources(); const std::vector<size_t> &getGeneratedSources();
const std::vector<std::vector<size_t>> &getGeneratedFaces(); const std::vector<std::vector<size_t>> &getGeneratedFaces();

View File

@ -580,8 +580,7 @@ MeshCombiner::Mesh *MeshGenerator::combinePartMesh(const QString &partIdString,
if (subdived) if (subdived)
gridMeshBuilder->setSubdived(true); gridMeshBuilder->setSubdived(true);
gridMeshBuilder->build(); buildSucceed = gridMeshBuilder->build();
buildSucceed = true;
partCache.vertices = gridMeshBuilder->getGeneratedPositions(); partCache.vertices = gridMeshBuilder->getGeneratedPositions();
partCache.faces = gridMeshBuilder->getGeneratedFaces(); partCache.faces = gridMeshBuilder->getGeneratedFaces();

View File

@ -73,5 +73,13 @@ void SkeletonDocument::findAllNeighbors(QUuid nodeId, std::set<QUuid> &neighbors
bool SkeletonDocument::isNodeConnectable(QUuid nodeId) const bool SkeletonDocument::isNodeConnectable(QUuid nodeId) const
{ {
const auto &node = findNode(nodeId);
if (nullptr == node)
return false;
if (node->edgeIds.size() < 2)
return true; return true;
const SkeletonPart *part = findPart(node->partId);
if (nullptr == part)
return false;
return part->gridded;
} }