use strings to connect nodes
This makes the node system somewhat more high-level with the intent of making working with them far more flexible and stable. By making the architecture more abstracted, it becomes far less rigid which should allow us to do even more with it and make it much less crash prone.
This commit is contained in:
@@ -22,13 +22,14 @@
|
||||
|
||||
namespace olive {
|
||||
|
||||
const QString TrigonometryNode::kMethodIn = QStringLiteral("method_in");
|
||||
const QString TrigonometryNode::kXIn = QStringLiteral("x_in");
|
||||
|
||||
TrigonometryNode::TrigonometryNode()
|
||||
{
|
||||
method_in_ = new NodeInput(this, QStringLiteral("method_in"), NodeValue::kCombo);
|
||||
method_in_->SetConnectable(false);
|
||||
method_in_->SetKeyframable(false);
|
||||
AddInput(kMethodIn, NodeValue::kCombo, InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable));
|
||||
|
||||
x_in_ = new NodeInput(this, QStringLiteral("x_in"), NodeValue::kFloat, 0.0);
|
||||
AddInput(kXIn, NodeValue::kFloat, 0.0);
|
||||
}
|
||||
|
||||
olive::Node *olive::TrigonometryNode::copy() const
|
||||
@@ -70,18 +71,20 @@ void TrigonometryNode::Retranslate()
|
||||
tr("Hyperbolic Cosine"),
|
||||
tr("Hyperbolic Tangent")};
|
||||
|
||||
method_in_->set_combobox_strings(strings);
|
||||
SetComboBoxStrings(kMethodIn, strings);
|
||||
|
||||
method_in_->set_name(tr("Method"));
|
||||
SetInputName(kMethodIn, tr("Method"));
|
||||
}
|
||||
|
||||
NodeValueTable TrigonometryNode::Value(NodeValueDatabase &value) const
|
||||
NodeValueTable TrigonometryNode::Value(const QString &output, NodeValueDatabase &value) const
|
||||
{
|
||||
float x = value[x_in_].Take(NodeValue::kFloat).toFloat();
|
||||
Q_UNUSED(output)
|
||||
|
||||
float x = value[kXIn].Take(NodeValue::kFloat).toFloat();
|
||||
|
||||
NodeValueTable table = value.Merge();
|
||||
|
||||
switch (static_cast<Operation>(method_in_->GetStandardValue().toInt())) {
|
||||
switch (static_cast<Operation>(GetStandardValue(kMethodIn).toInt())) {
|
||||
case kOpSine:
|
||||
x = qSin(x);
|
||||
break;
|
||||
|
||||
@@ -40,7 +40,10 @@ public:
|
||||
|
||||
virtual void Retranslate() override;
|
||||
|
||||
virtual NodeValueTable Value(NodeValueDatabase &value) const override;
|
||||
virtual NodeValueTable Value(const QString& output, NodeValueDatabase &value) const override;
|
||||
|
||||
static const QString kMethodIn;
|
||||
static const QString kXIn;
|
||||
|
||||
private:
|
||||
enum Operation {
|
||||
@@ -55,10 +58,6 @@ private:
|
||||
kOpHypTangent
|
||||
};
|
||||
|
||||
NodeInput* method_in_;
|
||||
|
||||
NodeInput* x_in_;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user