From 6309b8fbb7637d9ef38cfa0462f0fe685476eccc Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Fri, 17 Jul 2020 12:33:28 +1000 Subject: [PATCH] math: fixed power function Corrected shader code and fixed bug in widget bridge that reported an incorrect index. --- app/node/math/math/mathbase.cpp | 11 ++++++++++- .../nodeparamview/nodeparamviewwidgetbridge.cpp | 12 +++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/app/node/math/math/mathbase.cpp b/app/node/math/math/mathbase.cpp index b5ee9d76d..4a793af93 100644 --- a/app/node/math/math/mathbase.cpp +++ b/app/node/math/math/mathbase.cpp @@ -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; } diff --git a/app/widget/nodeparamview/nodeparamviewwidgetbridge.cpp b/app/widget/nodeparamview/nodeparamviewwidgetbridge.cpp index 9950864d7..456323238 100644 --- a/app/widget/nodeparamview/nodeparamviewwidgetbridge.cpp +++ b/app/widget/nodeparamview/nodeparamviewwidgetbridge.cpp @@ -363,7 +363,17 @@ void NodeParamViewWidgetBridge::WidgetCallback() case NodeParam::kCombo: { // Widget is a QComboBox - SetInputValue(static_cast(widgets_.first())->currentIndex(), 0); + QComboBox* cb = static_cast(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; } }