Fix compile error on macos introduced in last commit

std::optional::value() is not available on macos.
This commit is contained in:
Manuel Castilla
2021-07-26 22:44:10 +02:00
parent 6a903d9088
commit 05315af81d
2 changed files with 8 additions and 16 deletions

View File

@@ -54,33 +54,24 @@ ScaleOperation::ScaleOperation(DataType data_type) : BaseScaleOperation()
this->m_inputYOperation = nullptr; this->m_inputYOperation = nullptr;
} }
static std::optional<float> get_constant_scale(NodeOperation *op) float ScaleOperation::get_constant_scale(const int input_op_idx, const float factor)
{ {
if (op->get_flags().is_constant_operation) { const bool is_constant = getInputOperation(input_op_idx)->get_flags().is_constant_operation;
return ((ConstantOperation *)op)->get_constant_elem()[0]; if (is_constant) {
return ((ConstantOperation *)getInputOperation(input_op_idx))->get_constant_elem()[0] * factor;
} }
return std::optional<float>(); return 1.0f;
} }
float ScaleOperation::get_constant_scale_x() float ScaleOperation::get_constant_scale_x()
{ {
std::optional<float> scale_x = get_constant_scale(getInputOperation(1)); return get_constant_scale(1, get_relative_scale_x_factor());
if (scale_x.has_value()) {
return scale_x.value() * get_relative_scale_x_factor();
}
return 1.0f;
} }
float ScaleOperation::get_constant_scale_y() float ScaleOperation::get_constant_scale_y()
{ {
std::optional<float> scale_y = get_constant_scale(getInputOperation(2)); return get_constant_scale(2, get_relative_scale_y_factor());
if (scale_y.has_value()) {
return scale_y.value() * get_relative_scale_y_factor();
}
return 1.0f;
} }
BLI_INLINE float scale_coord(const int coord, const float center, const float relative_scale) BLI_INLINE float scale_coord(const int coord, const float center, const float relative_scale)

View File

@@ -71,6 +71,7 @@ class ScaleOperation : public BaseScaleOperation {
virtual float get_relative_scale_y_factor() = 0; virtual float get_relative_scale_y_factor() = 0;
private: private:
float get_constant_scale(int input_op_idx, float factor);
float get_constant_scale_x(); float get_constant_scale_x();
float get_constant_scale_y(); float get_constant_scale_y();
void scale_area(rcti &rect, float scale_x, float scale_y); void scale_area(rcti &rect, float scale_x, float scale_y);