math: fixed power function

Corrected shader code and fixed bug in widget bridge that reported an
incorrect index.
This commit is contained in:
itsmattkc
2020-07-17 12:33:28 +10:00
parent 662d66ad10
commit 6309b8fbb7
2 changed files with 21 additions and 2 deletions
+10 -1
View File
@@ -65,7 +65,16 @@ ShaderCode MathNodeBase::GetShaderCodeInternal(const QString &shader_id, NodeInp
operation = QStringLiteral("%1 / %2");
break;
case kOpPower:
operation = QStringLiteral("pow(%1, %2)");
if (pairing == kPairTextureNumber) {
// The "number" in this operation has to be declared a vec4
if (type_a & NodeParam::kNumber) {
operation = QStringLiteral("pow(%2, vec4(%1))");
} else {
operation = QStringLiteral("pow(%1, vec4(%2))");
}
} else {
operation = QStringLiteral("pow(%1, %2)");
}
break;
}
@@ -363,7 +363,17 @@ void NodeParamViewWidgetBridge::WidgetCallback()
case NodeParam::kCombo:
{
// Widget is a QComboBox
SetInputValue(static_cast<QComboBox*>(widgets_.first())->currentIndex(), 0);
QComboBox* cb = static_cast<QComboBox*>(widgets_.first());
int index = cb->currentIndex();
// Subtract any splitters up until this point
for (int i=index-1; i>=0; i--) {
if (cb->itemData(i, Qt::AccessibleDescriptionRole).toString() == QStringLiteral("separator")) {
index--;
}
}
SetInputValue(index, 0);
break;
}
}