Skip to content

Commit fb5ae99

Browse files
committed
Morph GUI updates: Allow Morph Double-Dipping checkbox, connected morphs warning dialog
1 parent 85c97fa commit fb5ae99

File tree

3 files changed

+71
-25
lines changed

3 files changed

+71
-25
lines changed

include/DzBridgeMorphSelectionDialog.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ namespace DzBridgeNameSpace
9999

100100
Q_INVOKABLE bool IsAutoJCMEnabled() { return autoJCMCheckBox->isChecked(); }
101101
Q_INVOKABLE bool IsFakeDualQuatEnabled() { return fakeDualQuatCheckBox->isChecked(); }
102+
Q_INVOKABLE bool IsAllowMorphDoubleDippingEnabled() { return allowMorphDoubleDippingCheckBox->isChecked(); }
102103

103104
// Recursive function for finding all active JCM morphs for a node
104105
Q_INVOKABLE QList<JointLinkInfo> GetActiveJointControlledMorphs(DzNode* Node = nullptr);
@@ -114,6 +115,9 @@ namespace DzBridgeNameSpace
114115
Q_INVOKABLE MorphInfo GetMorphInfoFromName(QString morphName);
115116
Q_INVOKABLE void SetAutoJCMVisible(bool bVisible);
116117
Q_INVOKABLE void SetAutoJCMEnabled(bool bEnabled);
118+
// DB 2023-July-10
119+
Q_INVOKABLE void SetAllowMorphDoubleDippingVisible(bool bVisible);
120+
Q_INVOKABLE void SetAllowMorphDoubleDippingEnabled(bool bEnabled);
117121

118122
// get morph property name
119123
Q_INVOKABLE static QString getMorphPropertyName(DzProperty* pMorphProperty);
@@ -200,6 +204,9 @@ namespace DzBridgeNameSpace
200204
QTreeWidgetItem* charactersTreeItem;
201205
QCheckBox* autoJCMCheckBox;
202206
QCheckBox* fakeDualQuatCheckBox;
207+
QPushButton* AddConnectedMorphsButton;
208+
209+
QCheckBox* allowMorphDoubleDippingCheckBox;
203210

204211
QSettings* settings;
205212
};

src/DzBridgeAction.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3297,14 +3297,16 @@ bool DzBridgeAction::readGui(DzBridgeDialog* BridgeDialog)
32973297
if (checkForIrreversibleOperations_in_disconnectOverrideControllers() == true)
32983298
{
32993299
// warn user
3300-
auto userChoice = QMessageBox::warning(0, "Daz Bridge",
3301-
tr("You are exporting morph controllers that directly control other morphs that are also \n\
3302-
being exported. To prevent morph values from incorrect exponential growth in these cases, \n\
3303-
we must now disconnect all linked morph controllers. This may cause irrersible changes to \n\
3304-
your scene. Please save changes to the scene before proceeding."),
3305-
QMessageBox::Ignore | QMessageBox::Abort,
3306-
QMessageBox::Abort);
3307-
if (userChoice == QMessageBox::StandardButton::Abort)
3300+
auto userChoice = QMessageBox::question(0, "Daz Bridge",
3301+
tr("You are exporting morph controllers that are \"connected\" or controlling \n\
3302+
the strength of other morphs that are also being exported. \n\n\
3303+
To prevent morph values from exponential growth to 200% or more \n\
3304+
(aka \"Double-Dipping\"), we must now disconnect all linked morph \n\
3305+
controllers. This may cause irreversible changes to your scene.\n\n\
3306+
Are you ready to proceed, or do you want to Cancel to save your changes?"),
3307+
QMessageBox::Yes | QMessageBox::Cancel,
3308+
QMessageBox::Yes);
3309+
if (userChoice == QMessageBox::StandardButton::Cancel)
33083310
return false;
33093311
}
33103312
}

src/DzBridgeMorphSelectionDialog.cpp

Lines changed: 54 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,21 @@ DzBridgeMorphSelectionDialog::DzBridgeMorphSelectionDialog(QWidget *parent) :
162162
fakeDualQuatCheckBox->setVisible(false);
163163
fakeDualQuatCheckBox->setWhatsThis("Adds additional JCMs that fake the difference between Linear Blending and Dual Quaternion Skinning.");
164164

165+
allowMorphDoubleDippingCheckBox = new QCheckBox(tr("Allow Morph Double-Dipping."));
166+
allowMorphDoubleDippingCheckBox->setChecked(false);
167+
allowMorphDoubleDippingCheckBox->setVisible(true);
168+
QString sAllowDoubleDippingHelpText = QString(tr("Allow Connected Morphs such as Victoria 9 and Victoria 9 Head \
169+
and Victoria 9 Body to all fully contribute to the exported blendshape when they are exported simultaneously. \
170+
WARNING: this will cause 200% or similar morph distortion when they are all applied together and may break \
171+
functionallity for some Morph and JCM products."));
172+
allowMorphDoubleDippingCheckBox->setWhatsThis(sAllowDoubleDippingHelpText);
173+
allowMorphDoubleDippingCheckBox->setToolTip(sAllowDoubleDippingHelpText);
174+
165175
QPushButton* AddConnectedMorphsButton = new QPushButton("Add Connected Morphs");
176+
AddConnectedMorphsButton->setVisible(false);
177+
QString sAddConnectedMorphsHelpText = QString(tr("Add any morphs or property sliders which can contribute to strength of exported morphs."));
178+
AddConnectedMorphsButton->setWhatsThis(sAddConnectedMorphsHelpText);
179+
AddConnectedMorphsButton->setToolTip(sAddConnectedMorphsHelpText);
166180

167181
((QGridLayout*)JCMGroupBox->layout())->addWidget(ArmsJCMButton, 0, 0);
168182
((QGridLayout*)JCMGroupBox->layout())->addWidget(LegsJCMButton, 0, 1);
@@ -175,6 +189,7 @@ DzBridgeMorphSelectionDialog::DzBridgeMorphSelectionDialog(QWidget *parent) :
175189
MorphGroupBox->layout()->addWidget(autoJCMCheckBox);
176190
MorphGroupBox->layout()->addWidget(fakeDualQuatCheckBox);
177191
MorphGroupBox->layout()->addWidget(AddConnectedMorphsButton);
192+
MorphGroupBox->layout()->addWidget(allowMorphDoubleDippingCheckBox);
178193

179194
if (!settings->value("AutoJCMEnabled").isNull())
180195
{
@@ -1361,28 +1376,32 @@ QList<QString> DzBridgeMorphSelectionDialog::getMorphNamesToDisconnectList()
13611376
{
13621377
QList<QString> morphsToDisconnect;
13631378

1364-
foreach (MorphInfo exportMorph, m_morphsToExport_finalized)
1379+
// DB 2023-July-10, Allow Morph Double-Dipping
1380+
if (this->allowMorphDoubleDippingCheckBox->isChecked() == false)
13651381
{
1366-
DzProperty* morphProperty = exportMorph.Property;
1367-
// DB (2022-Sept-26): crashfix
1368-
if (morphProperty == nullptr)
1369-
continue;
1370-
1371-
// DB, 2022-June-07: NOTE: using iterator may be more efficient due to potentially large number of controllers
1372-
for (auto iterator = morphProperty->controllerListIterator(); iterator.hasNext(); )
1382+
foreach (MorphInfo exportMorph, m_morphsToExport_finalized)
13731383
{
1374-
DzERCLink* ercLink = qobject_cast<DzERCLink*>(iterator.next());
1375-
if (ercLink == nullptr)
1384+
DzProperty* morphProperty = exportMorph.Property;
1385+
// DB (2022-Sept-26): crashfix
1386+
if (morphProperty == nullptr)
13761387
continue;
1377-
auto controllerProperty = ercLink->getProperty();
1378-
QString sControllerName = getMorphPropertyName(controllerProperty);
1379-
// iterate through each exported morph
1380-
foreach (MorphInfo compareMorph, m_morphsToExport_finalized)
1388+
1389+
// DB, 2022-June-07: NOTE: using iterator may be more efficient due to potentially large number of controllers
1390+
for (auto iterator = morphProperty->controllerListIterator(); iterator.hasNext(); )
13811391
{
1382-
if (compareMorph.Name == sControllerName)
1392+
DzERCLink* ercLink = qobject_cast<DzERCLink*>(iterator.next());
1393+
if (ercLink == nullptr)
1394+
continue;
1395+
auto controllerProperty = ercLink->getProperty();
1396+
QString sControllerName = getMorphPropertyName(controllerProperty);
1397+
// iterate through each exported morph
1398+
foreach (MorphInfo compareMorph, m_morphsToExport_finalized)
13831399
{
1384-
morphsToDisconnect.append(exportMorph.Name);
1385-
break;
1400+
if (compareMorph.Name == sControllerName)
1401+
{
1402+
morphsToDisconnect.append(exportMorph.Name);
1403+
break;
1404+
}
13861405
}
13871406
}
13881407
}
@@ -1407,6 +1426,7 @@ void DzBridgeMorphSelectionDialog::SetAutoJCMVisible(bool bVisible)
14071426
return;
14081427
autoJCMCheckBox->setVisible(bVisible);
14091428
fakeDualQuatCheckBox->setVisible(bVisible);
1429+
AddConnectedMorphsButton->setVisible(bVisible);
14101430
update();
14111431
}
14121432

@@ -1435,4 +1455,21 @@ void DzBridgeMorphSelectionDialog::SetAutoJCMEnabled(bool bEnabled)
14351455
update();
14361456
}
14371457

1458+
void DzBridgeMorphSelectionDialog::SetAllowMorphDoubleDippingEnabled(bool bEnabled)
1459+
{
1460+
if (allowMorphDoubleDippingCheckBox == nullptr)
1461+
return;
1462+
allowMorphDoubleDippingCheckBox->setChecked(bEnabled);
1463+
update();
1464+
}
1465+
1466+
void DzBridgeMorphSelectionDialog::SetAllowMorphDoubleDippingVisible(bool bVisible)
1467+
{
1468+
if (allowMorphDoubleDippingCheckBox == nullptr)
1469+
return;
1470+
allowMorphDoubleDippingCheckBox->setVisible(bVisible);
1471+
update();
1472+
}
1473+
1474+
14381475
#include "moc_DzBridgeMorphSelectionDialog.cpp"

0 commit comments

Comments
 (0)