change: change code style to Linux style except indent.
This commit is contained in:
+53
-52
@@ -20,7 +20,8 @@
|
||||
|
||||
#include "math.h"
|
||||
|
||||
namespace olive {
|
||||
namespace olive
|
||||
{
|
||||
|
||||
const QString MathNode::kMethodIn = QStringLiteral("method_in");
|
||||
const QString MathNode::kParamAIn = QStringLiteral("param_a_in");
|
||||
@@ -31,95 +32,95 @@ const QString MathNode::kParamCIn = QStringLiteral("param_c_in");
|
||||
|
||||
MathNode::MathNode()
|
||||
{
|
||||
AddInput(kMethodIn, NodeValue::kCombo, InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable));
|
||||
AddInput(kMethodIn, NodeValue::kCombo,
|
||||
InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable));
|
||||
|
||||
AddInput(kParamAIn, NodeValue::kFloat, 0.0);
|
||||
SetInputProperty(kParamAIn, QStringLiteral("decimalplaces"), 8);
|
||||
SetInputProperty(kParamAIn, QStringLiteral("autotrim"), true);
|
||||
AddInput(kParamAIn, NodeValue::kFloat, 0.0);
|
||||
SetInputProperty(kParamAIn, QStringLiteral("decimalplaces"), 8);
|
||||
SetInputProperty(kParamAIn, QStringLiteral("autotrim"), true);
|
||||
|
||||
AddInput(kParamBIn, NodeValue::kFloat, 0.0);
|
||||
SetInputProperty(kParamBIn, QStringLiteral("decimalplaces"), 8);
|
||||
SetInputProperty(kParamBIn, QStringLiteral("autotrim"), true);
|
||||
AddInput(kParamBIn, NodeValue::kFloat, 0.0);
|
||||
SetInputProperty(kParamBIn, QStringLiteral("decimalplaces"), 8);
|
||||
SetInputProperty(kParamBIn, QStringLiteral("autotrim"), true);
|
||||
}
|
||||
|
||||
QString MathNode::Name() const
|
||||
{
|
||||
// Default to naming after the operation
|
||||
if (parent()) {
|
||||
QString op_name = GetOperationName(GetOperation());
|
||||
if (!op_name.isEmpty()) {
|
||||
return op_name;
|
||||
}
|
||||
}
|
||||
// Default to naming after the operation
|
||||
if (parent()) {
|
||||
QString op_name = GetOperationName(GetOperation());
|
||||
if (!op_name.isEmpty()) {
|
||||
return op_name;
|
||||
}
|
||||
}
|
||||
|
||||
return tr("Math");
|
||||
return tr("Math");
|
||||
}
|
||||
|
||||
QString MathNode::id() const
|
||||
{
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.math");
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.math");
|
||||
}
|
||||
|
||||
QVector<Node::CategoryID> MathNode::Category() const
|
||||
{
|
||||
return {kCategoryMath};
|
||||
return { kCategoryMath };
|
||||
}
|
||||
|
||||
QString MathNode::Description() const
|
||||
{
|
||||
return tr("Perform a mathematical operation between two values.");
|
||||
return tr("Perform a mathematical operation between two values.");
|
||||
}
|
||||
|
||||
void MathNode::Retranslate()
|
||||
{
|
||||
super::Retranslate();
|
||||
super::Retranslate();
|
||||
|
||||
SetInputName(kMethodIn, tr("Method"));
|
||||
SetInputName(kParamAIn, tr("Value"));
|
||||
SetInputName(kParamBIn, tr("Value"));
|
||||
SetInputName(kMethodIn, tr("Method"));
|
||||
SetInputName(kParamAIn, tr("Value"));
|
||||
SetInputName(kParamBIn, tr("Value"));
|
||||
|
||||
QStringList operations = {GetOperationName(kOpAdd),
|
||||
GetOperationName(kOpSubtract),
|
||||
GetOperationName(kOpMultiply),
|
||||
GetOperationName(kOpDivide),
|
||||
QString(),
|
||||
GetOperationName(kOpPower)};
|
||||
QStringList operations = { GetOperationName(kOpAdd),
|
||||
GetOperationName(kOpSubtract),
|
||||
GetOperationName(kOpMultiply),
|
||||
GetOperationName(kOpDivide),
|
||||
QString(),
|
||||
GetOperationName(kOpPower) };
|
||||
|
||||
SetComboBoxStrings(kMethodIn, operations);
|
||||
SetComboBoxStrings(kMethodIn, operations);
|
||||
}
|
||||
|
||||
ShaderCode MathNode::GetShaderCode(const ShaderRequest &request) const
|
||||
{
|
||||
return GetShaderCodeInternal(request.id, kParamAIn, kParamBIn);
|
||||
return GetShaderCodeInternal(request.id, kParamAIn, kParamBIn);
|
||||
}
|
||||
|
||||
void MathNode::Value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const
|
||||
void MathNode::Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const
|
||||
{
|
||||
// Auto-detect what values to operate with
|
||||
// FIXME: Very inefficient
|
||||
NodeValueTable at, bt;
|
||||
at.Push(value[kParamAIn]);
|
||||
bt.Push(value[kParamBIn]);
|
||||
PairingCalculator calc(at, bt);
|
||||
// Auto-detect what values to operate with
|
||||
// FIXME: Very inefficient
|
||||
NodeValueTable at, bt;
|
||||
at.Push(value[kParamAIn]);
|
||||
bt.Push(value[kParamBIn]);
|
||||
PairingCalculator calc(at, bt);
|
||||
|
||||
// Do nothing if no pairing was found
|
||||
if (!calc.FoundMostLikelyPairing()) {
|
||||
return;
|
||||
}
|
||||
// Do nothing if no pairing was found
|
||||
if (!calc.FoundMostLikelyPairing()) {
|
||||
return;
|
||||
}
|
||||
|
||||
return ValueInternal(GetOperation(),
|
||||
calc.GetMostLikelyPairing(),
|
||||
kParamAIn,
|
||||
calc.GetMostLikelyValueA(),
|
||||
kParamBIn,
|
||||
calc.GetMostLikelyValueB(),
|
||||
globals,
|
||||
table);
|
||||
return ValueInternal(GetOperation(), calc.GetMostLikelyPairing(), kParamAIn,
|
||||
calc.GetMostLikelyValueA(), kParamBIn,
|
||||
calc.GetMostLikelyValueB(), globals, table);
|
||||
}
|
||||
|
||||
void MathNode::ProcessSamples(const NodeValueRow &values, const SampleBuffer &input, SampleBuffer &output, int index) const
|
||||
void MathNode::ProcessSamples(const NodeValueRow &values,
|
||||
const SampleBuffer &input, SampleBuffer &output,
|
||||
int index) const
|
||||
{
|
||||
return ProcessSamplesInternal(values, GetOperation(), kParamAIn, kParamBIn, input, output, index);
|
||||
return ProcessSamplesInternal(values, GetOperation(), kParamAIn, kParamBIn,
|
||||
input, output, index);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+30
-27
@@ -23,44 +23,47 @@
|
||||
|
||||
#include "mathbase.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
class MathNode : public MathNodeBase
|
||||
namespace olive
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
class MathNode : public MathNodeBase {
|
||||
Q_OBJECT
|
||||
public:
|
||||
MathNode();
|
||||
MathNode();
|
||||
|
||||
NODE_DEFAULT_FUNCTIONS(MathNode)
|
||||
NODE_DEFAULT_FUNCTIONS(MathNode)
|
||||
|
||||
virtual QString Name() const override;
|
||||
virtual QString id() const override;
|
||||
virtual QVector<CategoryID> Category() const override;
|
||||
virtual QString Description() const override;
|
||||
virtual QString Name() const override;
|
||||
virtual QString id() const override;
|
||||
virtual QVector<CategoryID> Category() const override;
|
||||
virtual QString Description() const override;
|
||||
|
||||
virtual void Retranslate() override;
|
||||
virtual void Retranslate() override;
|
||||
|
||||
virtual ShaderCode GetShaderCode(const ShaderRequest &request) const override;
|
||||
virtual ShaderCode
|
||||
GetShaderCode(const ShaderRequest &request) const override;
|
||||
|
||||
Operation GetOperation() const
|
||||
{
|
||||
return static_cast<Operation>(GetStandardValue(kMethodIn).toInt());
|
||||
}
|
||||
Operation GetOperation() const
|
||||
{
|
||||
return static_cast<Operation>(GetStandardValue(kMethodIn).toInt());
|
||||
}
|
||||
|
||||
void SetOperation(Operation o)
|
||||
{
|
||||
SetStandardValue(kMethodIn, o);
|
||||
}
|
||||
void SetOperation(Operation o)
|
||||
{
|
||||
SetStandardValue(kMethodIn, o);
|
||||
}
|
||||
|
||||
virtual void Value(const NodeValueRow& value, const NodeGlobals &globals, NodeValueTable *table) const override;
|
||||
virtual void Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const override;
|
||||
|
||||
virtual void ProcessSamples(const NodeValueRow &values, const SampleBuffer &input, SampleBuffer &output, int index) const override;
|
||||
|
||||
static const QString kMethodIn;
|
||||
static const QString kParamAIn;
|
||||
static const QString kParamBIn;
|
||||
static const QString kParamCIn;
|
||||
virtual void ProcessSamples(const NodeValueRow &values,
|
||||
const SampleBuffer &input, SampleBuffer &output,
|
||||
int index) const override;
|
||||
|
||||
static const QString kMethodIn;
|
||||
static const QString kParamAIn;
|
||||
static const QString kParamBIn;
|
||||
static const QString kParamCIn;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
+586
-503
File diff suppressed because it is too large
Load Diff
@@ -23,108 +23,116 @@
|
||||
|
||||
#include "node/node.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
class MathNodeBase : public Node
|
||||
namespace olive
|
||||
{
|
||||
|
||||
class MathNodeBase : public Node {
|
||||
public:
|
||||
MathNodeBase() = default;
|
||||
MathNodeBase() = default;
|
||||
|
||||
enum Operation {
|
||||
kOpAdd,
|
||||
kOpSubtract,
|
||||
kOpMultiply,
|
||||
kOpDivide,
|
||||
kOpPower
|
||||
};
|
||||
enum Operation { kOpAdd, kOpSubtract, kOpMultiply, kOpDivide, kOpPower };
|
||||
|
||||
static QString GetOperationName(Operation o);
|
||||
static QString GetOperationName(Operation o);
|
||||
|
||||
protected:
|
||||
enum Pairing {
|
||||
kPairNone = -1,
|
||||
enum Pairing {
|
||||
kPairNone = -1,
|
||||
|
||||
kPairNumberNumber,
|
||||
kPairVecVec,
|
||||
kPairMatrixMatrix,
|
||||
kPairColorColor,
|
||||
kPairTextureTexture,
|
||||
kPairNumberNumber,
|
||||
kPairVecVec,
|
||||
kPairMatrixMatrix,
|
||||
kPairColorColor,
|
||||
kPairTextureTexture,
|
||||
|
||||
kPairVecNumber,
|
||||
kPairMatrixVec,
|
||||
kPairNumberColor,
|
||||
kPairTextureNumber,
|
||||
kPairTextureColor,
|
||||
kPairTextureMatrix,
|
||||
kPairSampleSample,
|
||||
kPairSampleNumber,
|
||||
kPairVecNumber,
|
||||
kPairMatrixVec,
|
||||
kPairNumberColor,
|
||||
kPairTextureNumber,
|
||||
kPairTextureColor,
|
||||
kPairTextureMatrix,
|
||||
kPairSampleSample,
|
||||
kPairSampleNumber,
|
||||
|
||||
kPairCount
|
||||
};
|
||||
kPairCount
|
||||
};
|
||||
|
||||
class PairingCalculator {
|
||||
public:
|
||||
PairingCalculator(const NodeValueTable &table_a, const NodeValueTable &table_b);
|
||||
class PairingCalculator {
|
||||
public:
|
||||
PairingCalculator(const NodeValueTable &table_a,
|
||||
const NodeValueTable &table_b);
|
||||
|
||||
bool FoundMostLikelyPairing() const;
|
||||
Pairing GetMostLikelyPairing() const;
|
||||
bool FoundMostLikelyPairing() const;
|
||||
Pairing GetMostLikelyPairing() const;
|
||||
|
||||
const NodeValue& GetMostLikelyValueA() const;
|
||||
const NodeValue& GetMostLikelyValueB() const;
|
||||
const NodeValue &GetMostLikelyValueA() const;
|
||||
const NodeValue &GetMostLikelyValueB() const;
|
||||
|
||||
private:
|
||||
static QVector<int> GetPairLikelihood(const NodeValueTable& table);
|
||||
private:
|
||||
static QVector<int> GetPairLikelihood(const NodeValueTable &table);
|
||||
|
||||
Pairing most_likely_pairing_;
|
||||
Pairing most_likely_pairing_;
|
||||
|
||||
NodeValue most_likely_value_a_;
|
||||
NodeValue most_likely_value_a_;
|
||||
|
||||
NodeValue most_likely_value_b_;
|
||||
NodeValue most_likely_value_b_;
|
||||
};
|
||||
|
||||
};
|
||||
template <typename T, typename U>
|
||||
static T PerformAll(Operation operation, T a, U b);
|
||||
|
||||
template<typename T, typename U>
|
||||
static T PerformAll(Operation operation, T a, U b);
|
||||
template <typename T, typename U>
|
||||
static T PerformMultDiv(Operation operation, T a, U b);
|
||||
|
||||
template<typename T, typename U>
|
||||
static T PerformMultDiv(Operation operation, T a, U b);
|
||||
template <typename T, typename U>
|
||||
static T PerformAddSub(Operation operation, T a, U b);
|
||||
|
||||
template<typename T, typename U>
|
||||
static T PerformAddSub(Operation operation, T a, U b);
|
||||
template <typename T, typename U>
|
||||
static T PerformMult(Operation operation, T a, U b);
|
||||
|
||||
template<typename T, typename U>
|
||||
static T PerformMult(Operation operation, T a, U b);
|
||||
template <typename T, typename U>
|
||||
static T PerformAddSubMult(Operation operation, T a, U b);
|
||||
|
||||
template<typename T, typename U>
|
||||
static T PerformAddSubMult(Operation operation, T a, U b);
|
||||
template <typename T, typename U>
|
||||
static T PerformAddSubMultDiv(Operation operation, T a, U b);
|
||||
|
||||
template<typename T, typename U>
|
||||
static T PerformAddSubMultDiv(Operation operation, T a, U b);
|
||||
|
||||
static void PerformAllOnFloatBuffer(Operation operation, float *a, float b, int start, int end);
|
||||
static void PerformAllOnFloatBuffer(Operation operation, float *a, float b,
|
||||
int start, int end);
|
||||
|
||||
#if defined(Q_PROCESSOR_X86) || defined(Q_PROCESSOR_ARM)
|
||||
static void PerformAllOnFloatBufferSSE(Operation operation, float *a, float b, int start, int end);
|
||||
static void PerformAllOnFloatBufferSSE(Operation operation, float *a,
|
||||
float b, int start, int end);
|
||||
#endif
|
||||
|
||||
static QString GetShaderUniformType(const NodeValue::Type& type);
|
||||
static QString GetShaderUniformType(const NodeValue::Type &type);
|
||||
|
||||
static QString GetShaderVariableCall(const QString& input_id, const NodeValue::Type& type, const QString &coord_op = QString());
|
||||
static QString GetShaderVariableCall(const QString &input_id,
|
||||
const NodeValue::Type &type,
|
||||
const QString &coord_op = QString());
|
||||
|
||||
static QVector4D RetrieveVector(const NodeValue& val);
|
||||
static QVector4D RetrieveVector(const NodeValue &val);
|
||||
|
||||
static float RetrieveNumber(const NodeValue& val);
|
||||
static float RetrieveNumber(const NodeValue &val);
|
||||
|
||||
static bool NumberIsNoOp(const Operation& op, const float& number);
|
||||
static bool NumberIsNoOp(const Operation &op, const float &number);
|
||||
|
||||
ShaderCode GetShaderCodeInternal(const QString &shader_id, const QString ¶m_a_in, const QString ¶m_b_in) const;
|
||||
ShaderCode GetShaderCodeInternal(const QString &shader_id,
|
||||
const QString ¶m_a_in,
|
||||
const QString ¶m_b_in) const;
|
||||
|
||||
void PushVector(NodeValueTable* output, NodeValue::Type type, const QVector4D& vec) const;
|
||||
void PushVector(NodeValueTable *output, NodeValue::Type type,
|
||||
const QVector4D &vec) const;
|
||||
|
||||
void ValueInternal(Operation operation, Pairing pairing, const QString& param_a_in, const NodeValue &val_a, const QString& param_b_in, const NodeValue& val_b, const NodeGlobals &globals, NodeValueTable *output) const;
|
||||
|
||||
void ProcessSamplesInternal(const NodeValueRow &values, Operation operation, const QString& param_a_in, const QString& param_b_in, const SampleBuffer &input, SampleBuffer &output, int index) const;
|
||||
void ValueInternal(Operation operation, Pairing pairing,
|
||||
const QString ¶m_a_in, const NodeValue &val_a,
|
||||
const QString ¶m_b_in, const NodeValue &val_b,
|
||||
const NodeGlobals &globals,
|
||||
NodeValueTable *output) const;
|
||||
|
||||
void ProcessSamplesInternal(const NodeValueRow &values, Operation operation,
|
||||
const QString ¶m_a_in,
|
||||
const QString ¶m_b_in,
|
||||
const SampleBuffer &input, SampleBuffer &output,
|
||||
int index) const;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user