Implement bone joints picking
parent
cd963fa87d
commit
9475e9e0ac
|
@ -77,10 +77,10 @@ void BoneManageWidget::showSelectedBoneProperties()
|
||||||
|
|
||||||
m_propertyMenu = std::make_unique<QMenu>(this->parentWidget());
|
m_propertyMenu = std::make_unique<QMenu>(this->parentWidget());
|
||||||
|
|
||||||
connect(propertyWidget, &BonePropertyWidget::pickBoneJoints, this, [this]() {
|
connect(propertyWidget, &BonePropertyWidget::pickBoneJoints, this, [this](const dust3d::Uuid& boneId, size_t joints) {
|
||||||
if (nullptr == this->m_propertyMenu)
|
if (nullptr == this->m_propertyMenu)
|
||||||
return;
|
return;
|
||||||
this->m_document->setEditMode(Document::EditMode::Pick);
|
this->m_document->startBoneJointsPicking(boneId, joints);
|
||||||
this->m_propertyMenu->close();
|
this->m_propertyMenu->close();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,9 @@ BonePropertyWidget::BonePropertyWidget(Document* document,
|
||||||
nodePicker->setToolTip(tr("Click node one by one on canvas as joints in order"));
|
nodePicker->setToolTip(tr("Click node one by one on canvas as joints in order"));
|
||||||
Theme::initIconButton(nodePicker);
|
Theme::initIconButton(nodePicker);
|
||||||
|
|
||||||
connect(nodePicker, &QPushButton::clicked, this, &BonePropertyWidget::pickBoneJoints);
|
connect(nodePicker, &QPushButton::clicked, this, [this]() {
|
||||||
|
emit this->pickBoneJoints(this->m_boneId, (size_t)this->m_jointsWidget->value());
|
||||||
|
});
|
||||||
|
|
||||||
QHBoxLayout* jointsLayout = new QHBoxLayout;
|
QHBoxLayout* jointsLayout = new QHBoxLayout;
|
||||||
jointsLayout->addWidget(new QLabel(tr("Joints")));
|
jointsLayout->addWidget(new QLabel(tr("Joints")));
|
||||||
|
|
|
@ -13,7 +13,7 @@ class BonePropertyWidget : public QWidget {
|
||||||
signals:
|
signals:
|
||||||
void renameBone(const dust3d::Uuid& boneId, const QString& name);
|
void renameBone(const dust3d::Uuid& boneId, const QString& name);
|
||||||
void groupOperationAdded();
|
void groupOperationAdded();
|
||||||
void pickBoneJoints();
|
void pickBoneJoints(const dust3d::Uuid& boneId, size_t joints);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BonePropertyWidget(Document* document,
|
BonePropertyWidget(Document* document,
|
||||||
|
|
|
@ -1562,6 +1562,9 @@ void Document::setEditMode(Document::EditMode mode)
|
||||||
if (editMode == mode)
|
if (editMode == mode)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (EditMode::Pick == editMode)
|
||||||
|
resetCurrentBone();
|
||||||
|
|
||||||
editMode = mode;
|
editMode = mode;
|
||||||
emit editModeChanged();
|
emit editModeChanged();
|
||||||
}
|
}
|
||||||
|
@ -2925,3 +2928,46 @@ const Document::Bone* Document::findBone(const dust3d::Uuid& boneId) const
|
||||||
return nullptr;
|
return nullptr;
|
||||||
return &boneIt->second;
|
return &boneIt->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Document::stopBoneJointsPicking()
|
||||||
|
{
|
||||||
|
if (EditMode::Pick != editMode)
|
||||||
|
return;
|
||||||
|
setEditMode(EditMode::Select);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Document::startBoneJointsPicking(const dust3d::Uuid& boneId, size_t boneJoints)
|
||||||
|
{
|
||||||
|
stopBoneJointsPicking();
|
||||||
|
|
||||||
|
m_currentBondId = boneId;
|
||||||
|
m_currentBoneJoints = boneJoints;
|
||||||
|
|
||||||
|
setEditMode(EditMode::Pick);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Document::resetCurrentBone()
|
||||||
|
{
|
||||||
|
m_currentBondId = dust3d::Uuid();
|
||||||
|
m_currentBoneJoints = 0;
|
||||||
|
m_currentBoneJointNodes.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Document::pickBoneNode(const dust3d::Uuid& nodeId)
|
||||||
|
{
|
||||||
|
if (m_currentBondId.isNull())
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (const auto& it : m_currentBoneJointNodes) {
|
||||||
|
if (it == nodeId)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_currentBoneJointNodes.push_back(nodeId);
|
||||||
|
if (m_currentBoneJointNodes.size() < m_currentBoneJoints)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// TODO: Apply bone joints
|
||||||
|
|
||||||
|
stopBoneJointsPicking();
|
||||||
|
}
|
||||||
|
|
|
@ -519,6 +519,9 @@ public slots:
|
||||||
void removeBone(const dust3d::Uuid& boneId);
|
void removeBone(const dust3d::Uuid& boneId);
|
||||||
void setBoneAttachment(const dust3d::Uuid& boneId, const dust3d::Uuid& toBoneId, int toBoneJointIndex);
|
void setBoneAttachment(const dust3d::Uuid& boneId, const dust3d::Uuid& toBoneId, int toBoneJointIndex);
|
||||||
void renameBone(const dust3d::Uuid& boneId, const QString& name);
|
void renameBone(const dust3d::Uuid& boneId, const QString& name);
|
||||||
|
void startBoneJointsPicking(const dust3d::Uuid& boneId, size_t boneJoints);
|
||||||
|
void stopBoneJointsPicking();
|
||||||
|
void pickBoneNode(const dust3d::Uuid& nodeId);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void resolveSnapshotBoundingBox(const dust3d::Snapshot& snapshot, QRectF* mainProfile, QRectF* sideProfile);
|
void resolveSnapshotBoundingBox(const dust3d::Snapshot& snapshot, QRectF* mainProfile, QRectF* sideProfile);
|
||||||
|
@ -533,6 +536,7 @@ private:
|
||||||
void removeComponentRecursively(dust3d::Uuid componentId);
|
void removeComponentRecursively(dust3d::Uuid componentId);
|
||||||
void updateLinkedPart(dust3d::Uuid oldPartId, dust3d::Uuid newPartId);
|
void updateLinkedPart(dust3d::Uuid oldPartId, dust3d::Uuid newPartId);
|
||||||
dust3d::Uuid createNode(dust3d::Uuid nodeId, float x, float y, float z, float radius, dust3d::Uuid fromNodeId);
|
dust3d::Uuid createNode(dust3d::Uuid nodeId, float x, float y, float z, float radius, dust3d::Uuid fromNodeId);
|
||||||
|
void resetCurrentBone();
|
||||||
|
|
||||||
bool m_isResultMeshObsolete = false;
|
bool m_isResultMeshObsolete = false;
|
||||||
MeshGenerator* m_meshGenerator = nullptr;
|
MeshGenerator* m_meshGenerator = nullptr;
|
||||||
|
@ -557,6 +561,9 @@ private:
|
||||||
float m_originZ = 0;
|
float m_originZ = 0;
|
||||||
dust3d::Uuid m_currentCanvasComponentId;
|
dust3d::Uuid m_currentCanvasComponentId;
|
||||||
bool m_allPositionRelatedLocksEnabled = true;
|
bool m_allPositionRelatedLocksEnabled = true;
|
||||||
|
dust3d::Uuid m_currentBondId;
|
||||||
|
size_t m_currentBoneJoints = 0;
|
||||||
|
std::vector<dust3d::Uuid> m_currentBoneJointNodes;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static unsigned long m_maxSnapshot;
|
static unsigned long m_maxSnapshot;
|
||||||
|
|
|
@ -574,6 +574,8 @@ DocumentWindow::DocumentWindow()
|
||||||
connect(canvasGraphicsWidget, &SkeletonGraphicsWidget::addNodesToBone, m_document, &Document::addNodesToBone);
|
connect(canvasGraphicsWidget, &SkeletonGraphicsWidget::addNodesToBone, m_document, &Document::addNodesToBone);
|
||||||
connect(canvasGraphicsWidget, &SkeletonGraphicsWidget::removeNodesFromBone, m_document, &Document::removeNodesFromBone);
|
connect(canvasGraphicsWidget, &SkeletonGraphicsWidget::removeNodesFromBone, m_document, &Document::removeNodesFromBone);
|
||||||
|
|
||||||
|
connect(canvasGraphicsWidget, &SkeletonGraphicsWidget::nodePicked, m_document, &Document::pickBoneNode);
|
||||||
|
|
||||||
connect(canvasGraphicsWidget, &SkeletonGraphicsWidget::setXlockState, m_document, &Document::setXlockState);
|
connect(canvasGraphicsWidget, &SkeletonGraphicsWidget::setXlockState, m_document, &Document::setXlockState);
|
||||||
connect(canvasGraphicsWidget, &SkeletonGraphicsWidget::setYlockState, m_document, &Document::setYlockState);
|
connect(canvasGraphicsWidget, &SkeletonGraphicsWidget::setYlockState, m_document, &Document::setYlockState);
|
||||||
connect(canvasGraphicsWidget, &SkeletonGraphicsWidget::setZlockState, m_document, &Document::setZlockState);
|
connect(canvasGraphicsWidget, &SkeletonGraphicsWidget::setZlockState, m_document, &Document::setZlockState);
|
||||||
|
|
|
@ -1487,7 +1487,6 @@ bool SkeletonGraphicsWidget::mousePress(QMouseEvent* event)
|
||||||
}
|
}
|
||||||
} else if (Document::EditMode::Pick == m_document->editMode) {
|
} else if (Document::EditMode::Pick == m_document->editMode) {
|
||||||
if (m_hoveredNodeItem) {
|
if (m_hoveredNodeItem) {
|
||||||
dust3dDebug << "nodePicked:" << m_hoveredNodeItem->id().toString();
|
|
||||||
emit nodePicked(m_hoveredNodeItem->id());
|
emit nodePicked(m_hoveredNodeItem->id());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue