nodevalue: begin abstracting qvariant
This commit is contained in:
@@ -141,12 +141,12 @@ QVector4D MathNodeBase::RetrieveVector(const NodeValue &val)
|
||||
// QVariant doesn't know that QVector*D can convert themselves so we do it here
|
||||
switch (val.type()) {
|
||||
case NodeValue::kVec2:
|
||||
return val.data().value<QVector2D>();
|
||||
return val.toVec2();
|
||||
case NodeValue::kVec3:
|
||||
return val.data().value<QVector3D>();
|
||||
return val.toVec3();
|
||||
case NodeValue::kVec4:
|
||||
default:
|
||||
return val.data().value<QVector4D>();
|
||||
return val.toVec4();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -225,7 +225,7 @@ void MathNodeBase::ValueInternal(Operation operation, Pairing pairing, const QSt
|
||||
if (val_a.type() == NodeValue::kRational && val_b.type() == NodeValue::kRational && operation != kOpPower) {
|
||||
// Preserve rationals
|
||||
output->Push(NodeValue::kRational,
|
||||
QVariant::fromValue(PerformAddSubMultDiv<rational, rational>(operation, val_a.data().value<rational>(), val_b.data().value<rational>())),
|
||||
QVariant::fromValue(PerformAddSubMultDiv<rational, rational>(operation, val_a.toRational(), val_b.toRational())),
|
||||
this);
|
||||
} else {
|
||||
output->Push(NodeValue::kFloat,
|
||||
@@ -247,7 +247,7 @@ void MathNodeBase::ValueInternal(Operation operation, Pairing pairing, const QSt
|
||||
|
||||
case kPairMatrixVec:
|
||||
{
|
||||
QMatrix4x4 matrix = (val_a.type() == NodeValue::kMatrix) ? val_a.data().value<QMatrix4x4>() : val_b.data().value<QMatrix4x4>();
|
||||
QMatrix4x4 matrix = (val_a.type() == NodeValue::kMatrix) ? val_a.toMatrix() : val_b.toMatrix();
|
||||
QVector4D vec = (val_a.type() == NodeValue::kMatrix) ? RetrieveVector(val_b) : RetrieveVector(val_a);
|
||||
|
||||
// Only valid operation is multiply
|
||||
@@ -269,16 +269,16 @@ void MathNodeBase::ValueInternal(Operation operation, Pairing pairing, const QSt
|
||||
|
||||
case kPairMatrixMatrix:
|
||||
{
|
||||
QMatrix4x4 mat_a = val_a.data().value<QMatrix4x4>();
|
||||
QMatrix4x4 mat_b = val_b.data().value<QMatrix4x4>();
|
||||
QMatrix4x4 mat_a = val_a.toMatrix();
|
||||
QMatrix4x4 mat_b = val_b.toMatrix();
|
||||
output->Push(NodeValue::kMatrix, PerformAddSubMult<QMatrix4x4, QMatrix4x4>(operation, mat_a, mat_b), this);
|
||||
break;
|
||||
}
|
||||
|
||||
case kPairColorColor:
|
||||
{
|
||||
Color col_a = val_a.data().value<Color>();
|
||||
Color col_b = val_b.data().value<Color>();
|
||||
Color col_a = val_a.toColor();
|
||||
Color col_b = val_b.toColor();
|
||||
|
||||
// Only add and subtract are valid operations
|
||||
output->Push(NodeValue::kColor, QVariant::fromValue(PerformAddSub<Color, Color>(operation, col_a, col_b)), this);
|
||||
@@ -288,8 +288,8 @@ void MathNodeBase::ValueInternal(Operation operation, Pairing pairing, const QSt
|
||||
|
||||
case kPairNumberColor:
|
||||
{
|
||||
Color col = (val_a.type() == NodeValue::kColor) ? val_a.data().value<Color>() : val_b.data().value<Color>();
|
||||
float num = (val_a.type() == NodeValue::kColor) ? val_b.data().toFloat() : val_a.data().toFloat();
|
||||
Color col = (val_a.type() == NodeValue::kColor) ? val_a.toColor() : val_b.toColor();
|
||||
float num = (val_a.type() == NodeValue::kColor) ? val_b.toDouble() : val_a.toDouble();
|
||||
|
||||
// Only multiply and divide are valid operations
|
||||
output->Push(NodeValue::kColor, QVariant::fromValue(PerformMult<Color, float>(operation, col, num)), this);
|
||||
@@ -298,8 +298,8 @@ void MathNodeBase::ValueInternal(Operation operation, Pairing pairing, const QSt
|
||||
|
||||
case kPairSampleSample:
|
||||
{
|
||||
SampleBufferPtr samples_a = val_a.data().value<SampleBufferPtr>();
|
||||
SampleBufferPtr samples_b = val_b.data().value<SampleBufferPtr>();
|
||||
SampleBufferPtr samples_a = val_a.toSamples();
|
||||
SampleBufferPtr samples_b = val_b.toSamples();
|
||||
|
||||
int max_samples = qMax(samples_a->sample_count(), samples_b->sample_count());
|
||||
int min_samples = qMin(samples_a->sample_count(), samples_b->sample_count());
|
||||
@@ -348,7 +348,7 @@ void MathNodeBase::ValueInternal(Operation operation, Pairing pairing, const QSt
|
||||
|
||||
const NodeValue& number_val = val_a.type() == NodeValue::kTexture ? val_b : val_a;
|
||||
const NodeValue& texture_val = val_a.type() == NodeValue::kTexture ? val_a : val_b;
|
||||
TexturePtr texture = texture_val.data().value<TexturePtr>();
|
||||
TexturePtr texture = texture_val.toTexture();
|
||||
|
||||
if (!texture) {
|
||||
operation_is_noop = true;
|
||||
@@ -361,7 +361,7 @@ void MathNodeBase::ValueInternal(Operation operation, Pairing pairing, const QSt
|
||||
const QVector2D &sequence_res = globals.resolution();
|
||||
QVector2D texture_res(texture->params().width() * texture->pixel_aspect_ratio().toDouble(), texture->params().height());
|
||||
|
||||
QMatrix4x4 adjusted_matrix = TransformDistortNode::AdjustMatrixByResolutions(number_val.data().value<QMatrix4x4>(),
|
||||
QMatrix4x4 adjusted_matrix = TransformDistortNode::AdjustMatrixByResolutions(number_val.toMatrix(),
|
||||
sequence_res,
|
||||
texture->params().offset(),
|
||||
texture_res);
|
||||
@@ -449,9 +449,9 @@ void MathNodeBase::ProcessSamplesInternal(const NodeValueRow &values, MathNodeBa
|
||||
float MathNodeBase::RetrieveNumber(const NodeValue &val)
|
||||
{
|
||||
if (val.type() == NodeValue::kRational) {
|
||||
return val.data().value<rational>().toDouble();
|
||||
return val.toRational().toDouble();
|
||||
} else {
|
||||
return val.data().toFloat();
|
||||
return val.toDouble();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user