Add part round end
parent
73c13a9cb4
commit
d075ee3ba7
|
@ -164,8 +164,19 @@ ComponentPropertyWidget::ComponentPropertyWidget(Document *document,
|
||||||
emit groupOperationAdded();
|
emit groupOperationAdded();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
QCheckBox *roundEndStateBox = new QCheckBox();
|
||||||
|
Theme::initCheckbox(roundEndStateBox);
|
||||||
|
roundEndStateBox->setText(tr("Round end"));
|
||||||
|
roundEndStateBox->setChecked(m_part->rounded);
|
||||||
|
|
||||||
|
connect(roundEndStateBox, &QCheckBox::stateChanged, this, [=]() {
|
||||||
|
emit setPartRoundState(m_partId, roundEndStateBox->isChecked());
|
||||||
|
emit groupOperationAdded();
|
||||||
|
});
|
||||||
|
|
||||||
QHBoxLayout *optionsLayout = new QHBoxLayout;
|
QHBoxLayout *optionsLayout = new QHBoxLayout;
|
||||||
optionsLayout->addStretch();
|
optionsLayout->addStretch();
|
||||||
|
optionsLayout->addWidget(roundEndStateBox);
|
||||||
optionsLayout->addWidget(chamferStateBox);
|
optionsLayout->addWidget(chamferStateBox);
|
||||||
optionsLayout->addWidget(subdivStateBox);
|
optionsLayout->addWidget(subdivStateBox);
|
||||||
|
|
||||||
|
@ -194,6 +205,7 @@ ComponentPropertyWidget::ComponentPropertyWidget(Document *document,
|
||||||
connect(this, &ComponentPropertyWidget::setPartCutRotation, m_document, &Document::setPartCutRotation);
|
connect(this, &ComponentPropertyWidget::setPartCutRotation, m_document, &Document::setPartCutRotation);
|
||||||
connect(this, &ComponentPropertyWidget::setPartSubdivState, m_document, &Document::setPartSubdivState);
|
connect(this, &ComponentPropertyWidget::setPartSubdivState, m_document, &Document::setPartSubdivState);
|
||||||
connect(this, &ComponentPropertyWidget::setPartChamferState, m_document, &Document::setPartChamferState);
|
connect(this, &ComponentPropertyWidget::setPartChamferState, m_document, &Document::setPartChamferState);
|
||||||
|
connect(this, &ComponentPropertyWidget::setPartRoundState, m_document, &Document::setPartRoundState);
|
||||||
connect(this, &ComponentPropertyWidget::groupOperationAdded, m_document, &Document::saveSnapshot);
|
connect(this, &ComponentPropertyWidget::groupOperationAdded, m_document, &Document::saveSnapshot);
|
||||||
|
|
||||||
setLayout(mainLayout);
|
setLayout(mainLayout);
|
||||||
|
|
|
@ -19,6 +19,7 @@ signals:
|
||||||
void setPartDeformUnified(const dust3d::Uuid &partId, bool unified);
|
void setPartDeformUnified(const dust3d::Uuid &partId, bool unified);
|
||||||
void setPartSubdivState(const dust3d::Uuid &partId, bool subdived);
|
void setPartSubdivState(const dust3d::Uuid &partId, bool subdived);
|
||||||
void setPartChamferState(const dust3d::Uuid &partId, bool chamfered);
|
void setPartChamferState(const dust3d::Uuid &partId, bool chamfered);
|
||||||
|
void setPartRoundState(const dust3d::Uuid &partId, bool rounded);
|
||||||
void setPartCutRotation(const dust3d::Uuid &partId, float cutRotation);
|
void setPartCutRotation(const dust3d::Uuid &partId, float cutRotation);
|
||||||
void groupOperationAdded();
|
void groupOperationAdded();
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -664,6 +664,7 @@ std::unique_ptr<MeshCombiner::Mesh> MeshGenerator::combinePartMesh(const std::st
|
||||||
buildParameters.deformUnified = deformUnified;
|
buildParameters.deformUnified = deformUnified;
|
||||||
buildParameters.baseNormalRotation = cutRotation * Math::Pi;
|
buildParameters.baseNormalRotation = cutRotation * Math::Pi;
|
||||||
buildParameters.cutFace = cutTemplate;
|
buildParameters.cutFace = cutTemplate;
|
||||||
|
buildParameters.frontEndRounded = buildParameters.backEndRounded = rounded;
|
||||||
auto tubeMeshBuilder = std::make_unique<TubeMeshBuilder>(buildParameters, std::move(meshNodes), isCircle);
|
auto tubeMeshBuilder = std::make_unique<TubeMeshBuilder>(buildParameters, std::move(meshNodes), isCircle);
|
||||||
tubeMeshBuilder->build();
|
tubeMeshBuilder->build();
|
||||||
|
|
||||||
|
|
|
@ -49,8 +49,33 @@ const std::vector<std::vector<size_t>> &TubeMeshBuilder::generatedFaces()
|
||||||
return m_generatedFaces;
|
return m_generatedFaces;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TubeMeshBuilder::applyRoundEnd()
|
||||||
|
{
|
||||||
|
if (m_isCircle)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (m_nodes.size() <= 1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (m_buildParameters.frontEndRounded) {
|
||||||
|
auto newNode = m_nodes.front();
|
||||||
|
newNode.radius *= 0.5;
|
||||||
|
newNode.origin += (m_nodes[0].origin - m_nodes[1].origin).normalized() * newNode.radius;
|
||||||
|
m_nodes.insert(m_nodes.begin(), newNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_buildParameters.backEndRounded) {
|
||||||
|
auto newNode = m_nodes.back();
|
||||||
|
newNode.radius *= 0.5;
|
||||||
|
newNode.origin += (m_nodes[m_nodes.size() - 1].origin - m_nodes[m_nodes.size() - 2].origin).normalized() * newNode.radius;
|
||||||
|
m_nodes.emplace_back(newNode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void TubeMeshBuilder::preprocessNodes()
|
void TubeMeshBuilder::preprocessNodes()
|
||||||
{
|
{
|
||||||
|
applyRoundEnd();
|
||||||
|
|
||||||
// TODO: Interpolate...
|
// TODO: Interpolate...
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,8 @@ public:
|
||||||
double deformWidth = 1.0;
|
double deformWidth = 1.0;
|
||||||
bool deformUnified = false;
|
bool deformUnified = false;
|
||||||
double baseNormalRotation = 0.0;
|
double baseNormalRotation = 0.0;
|
||||||
|
bool frontEndRounded = false;
|
||||||
|
bool backEndRounded = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
TubeMeshBuilder(const BuildParameters &buildParameters, std::vector<MeshNode> &&nodes, bool isCircle);
|
TubeMeshBuilder(const BuildParameters &buildParameters, std::vector<MeshNode> &&nodes, bool isCircle);
|
||||||
|
@ -64,6 +66,7 @@ private:
|
||||||
std::vector<Vector3> buildCutFaceVertices(const Vector3 &origin,
|
std::vector<Vector3> buildCutFaceVertices(const Vector3 &origin,
|
||||||
double radius,
|
double radius,
|
||||||
const Vector3 &forwardDirection);
|
const Vector3 &forwardDirection);
|
||||||
|
void applyRoundEnd();
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue