diff options
author | Jacques Lucke <jacques@blender.org> | 2021-01-14 17:55:51 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2021-01-14 17:55:51 +0300 |
commit | 9131c697ddda0ad640167d9f52e97bb697e187d0 (patch) | |
tree | c73ec2089ab6611569f849c07eb5ccd2cb009caf /source/blender/nodes | |
parent | 87955143845230919326914e5377f76ce231d306 (diff) | |
parent | e5ee7e9a2df93d7f28f9e1f8bc0eb2d33dfadfb4 (diff) |
Merge branch 'blender-v2.92-release'
Diffstat (limited to 'source/blender/nodes')
12 files changed, 35 insertions, 33 deletions
diff --git a/source/blender/nodes/geometry/nodes/node_geo_align_rotation_to_vector.cc b/source/blender/nodes/geometry/nodes/node_geo_align_rotation_to_vector.cc index c38f54ce7f7..eac77b25bd6 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_align_rotation_to_vector.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_align_rotation_to_vector.cc @@ -41,12 +41,12 @@ static void align_rotations_on_component(GeometryComponent &component, const NodeGeometryAlignRotationToVector &storage = *(const NodeGeometryAlignRotationToVector *) node.storage; - WriteAttributePtr rotation_attribute = component.attribute_try_ensure_for_write( + OutputAttributePtr rotation_attribute = component.attribute_try_get_for_output( "rotation", ATTR_DOMAIN_POINT, CD_PROP_FLOAT3); if (!rotation_attribute) { return; } - MutableSpan<float3> rotations = rotation_attribute->get_span().typed<float3>(); + MutableSpan<float3> rotations = rotation_attribute->get_span<float3>(); FloatReadAttribute factors = params.get_input_attribute<float>( "Factor", component, ATTR_DOMAIN_POINT, 1.0f); @@ -85,7 +85,7 @@ static void align_rotations_on_component(GeometryComponent &component, rotations[i] = new_rotation; } - rotation_attribute->apply_span(); + rotation_attribute.apply_span_and_save(); } static void geo_node_align_rotation_to_vector_exec(GeoNodeExecParams params) diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_color_ramp.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_color_ramp.cc index 2aca9ed581c..9b0900e19ab 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_attribute_color_ramp.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_color_ramp.cc @@ -46,7 +46,7 @@ static void execute_on_component(const GeoNodeExecParams ¶ms, GeometryCompon /* Once we support more domains at the user level, we have to decide how the result domain is * chosen. */ const AttributeDomain result_domain = ATTR_DOMAIN_POINT; - WriteAttributePtr attribute_result = component.attribute_try_ensure_for_write( + OutputAttributePtr attribute_result = component.attribute_try_get_for_output( result_name, result_domain, result_type); if (!attribute_result) { return; @@ -64,7 +64,7 @@ static void execute_on_component(const GeoNodeExecParams ¶ms, GeometryCompon BKE_colorband_evaluate(color_ramp, data_in[i], data_out[i]); } - attribute_result->apply_span(); + attribute_result.apply_span_and_save(); } static void geo_node_attribute_color_ramp_exec(GeoNodeExecParams params) diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_compare.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_compare.cc index 8ea88e7153d..20a2b2127c2 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_attribute_compare.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_compare.cc @@ -242,7 +242,7 @@ static void attribute_compare_calc(GeometryComponent &component, const GeoNodeEx /* Get result attribute first, in case it has to overwrite one of the existing attributes. */ const std::string result_name = params.get_input<std::string>("Result"); - WriteAttributePtr attribute_result = component.attribute_try_ensure_for_write( + OutputAttributePtr attribute_result = component.attribute_try_get_for_output( result_name, result_domain, result_type); if (!attribute_result) { return; @@ -260,8 +260,7 @@ static void attribute_compare_calc(GeometryComponent &component, const GeoNodeEx return; } - BooleanWriteAttribute attribute_result_bool = *attribute_result; - MutableSpan<bool> result_span = attribute_result_bool.get_span_for_write_only(); + MutableSpan<bool> result_span = attribute_result->get_span_for_write_only<bool>(); /* Use specific types for correct equality operations, but for other operations we use implicit * conversions and float comparison. In other words, the comparison is not element-wise. */ @@ -300,7 +299,7 @@ static void attribute_compare_calc(GeometryComponent &component, const GeoNodeEx do_math_operation(*attribute_a, *attribute_b, operation, result_span); } - attribute_result_bool.apply_span(); + attribute_result.apply_span_and_save(); } static void geo_node_attribute_compare_exec(GeoNodeExecParams params) diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_fill.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_fill.cc index 96685196917..9cec4070f89 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_attribute_fill.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_fill.cc @@ -68,7 +68,7 @@ static void fill_attribute(GeometryComponent &component, const GeoNodeExecParams return; } - WriteAttributePtr attribute = component.attribute_try_ensure_for_write( + OutputAttributePtr attribute = component.attribute_try_get_for_output( attribute_name, domain, data_type); if (!attribute) { return; @@ -79,33 +79,31 @@ static void fill_attribute(GeometryComponent &component, const GeoNodeExecParams const float value = params.get_input<float>("Value_001"); MutableSpan<float> attribute_span = attribute->get_span_for_write_only<float>(); attribute_span.fill(value); - attribute->apply_span(); break; } case CD_PROP_FLOAT3: { const float3 value = params.get_input<float3>("Value"); MutableSpan<float3> attribute_span = attribute->get_span_for_write_only<float3>(); attribute_span.fill(value); - attribute->apply_span(); break; } case CD_PROP_COLOR: { const Color4f value = params.get_input<Color4f>("Value_002"); MutableSpan<Color4f> attribute_span = attribute->get_span_for_write_only<Color4f>(); attribute_span.fill(value); - attribute->apply_span(); break; } case CD_PROP_BOOL: { const bool value = params.get_input<bool>("Value_003"); MutableSpan<bool> attribute_span = attribute->get_span_for_write_only<bool>(); attribute_span.fill(value); - attribute->apply_span(); break; } default: break; } + + attribute.apply_span_and_save(); } static void geo_node_attribute_fill_exec(GeoNodeExecParams params) diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_math.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_math.cc index 6e3b34f702a..f8ec9124db3 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_attribute_math.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_math.cc @@ -107,7 +107,7 @@ static void attribute_math_calc(GeometryComponent &component, const GeoNodeExecP /* Get result attribute first, in case it has to overwrite one of the existing attributes. */ const std::string result_name = params.get_input<std::string>("Result"); - WriteAttributePtr attribute_result = component.attribute_try_ensure_for_write( + OutputAttributePtr attribute_result = component.attribute_try_get_for_output( result_name, result_domain, result_type); if (!attribute_result) { return; @@ -123,6 +123,7 @@ static void attribute_math_calc(GeometryComponent &component, const GeoNodeExecP } do_math_operation(*attribute_a, *attribute_b, *attribute_result, operation); + attribute_result.save(); } static void geo_node_attribute_math_exec(GeoNodeExecParams params) diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_mix.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_mix.cc index 4d8645b3b25..58d67145e75 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_attribute_mix.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_mix.cc @@ -136,7 +136,7 @@ static void attribute_mix_calc(GeometryComponent &component, const GeoNodeExecPa result_domain = result_attribute_read->domain(); } - WriteAttributePtr attribute_result = component.attribute_try_ensure_for_write( + OutputAttributePtr attribute_result = component.attribute_try_get_for_output( result_name, result_domain, result_type); if (!attribute_result) { return; @@ -155,6 +155,7 @@ static void attribute_mix_calc(GeometryComponent &component, const GeoNodeExecPa *attribute_a, *attribute_b, *attribute_result); + attribute_result.save(); } static void geo_node_attribute_mix_exec(GeoNodeExecParams params) diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_randomize.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_randomize.cc index 60e1441e363..0e7bb25e659 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_attribute_randomize.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_randomize.cc @@ -151,7 +151,7 @@ static void randomize_attribute(GeometryComponent &component, return; } - WriteAttributePtr attribute = component.attribute_try_ensure_for_write( + OutputAttributePtr attribute = component.attribute_try_get_for_output( attribute_name, domain, data_type); if (!attribute) { return; @@ -179,6 +179,8 @@ static void randomize_attribute(GeometryComponent &component, default: break; } + + attribute.save(); } static void geo_node_random_attribute_exec(GeoNodeExecParams params) diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_vector_math.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_vector_math.cc index de377e8bc87..529906a35e7 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_attribute_vector_math.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_vector_math.cc @@ -345,7 +345,7 @@ static void attribute_vector_math_calc(GeometryComponent &component, /* Get result attribute first, in case it has to overwrite one of the existing attributes. */ const std::string result_name = params.get_input<std::string>("Result"); - WriteAttributePtr attribute_result = component.attribute_try_ensure_for_write( + OutputAttributePtr attribute_result = component.attribute_try_get_for_output( result_name, result_domain, result_type); if (!attribute_result) { return; @@ -390,6 +390,7 @@ static void attribute_vector_math_calc(GeometryComponent &component, *attribute_a, *attribute_b, *attribute_c, *attribute_result, operation); break; } + attribute_result.save(); } static void geo_node_attribute_vector_math_exec(GeoNodeExecParams params) diff --git a/source/blender/nodes/geometry/nodes/node_geo_point_distribute.cc b/source/blender/nodes/geometry/nodes/node_geo_point_distribute.cc index 46b29a08feb..5e9b780db6d 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_point_distribute.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_point_distribute.cc @@ -248,11 +248,11 @@ BLI_NOINLINE static void add_remaining_point_attributes(const Mesh &mesh, Span<float3> bary_coords, Span<int> looptri_indices) { - WriteAttributePtr id_attribute = component.attribute_try_ensure_for_write( + OutputAttributePtr id_attribute = component.attribute_try_get_for_output( "id", ATTR_DOMAIN_POINT, CD_PROP_INT32); - WriteAttributePtr normal_attribute = component.attribute_try_ensure_for_write( + OutputAttributePtr normal_attribute = component.attribute_try_get_for_output( "normal", ATTR_DOMAIN_POINT, CD_PROP_FLOAT3); - WriteAttributePtr rotation_attribute = component.attribute_try_ensure_for_write( + OutputAttributePtr rotation_attribute = component.attribute_try_get_for_output( "rotation", ATTR_DOMAIN_POINT, CD_PROP_FLOAT3); compute_special_attributes(mesh, @@ -262,9 +262,9 @@ BLI_NOINLINE static void add_remaining_point_attributes(const Mesh &mesh, id_attribute->get_span_for_write_only<int>(), rotation_attribute->get_span_for_write_only<float3>()); - id_attribute->apply_span(); - normal_attribute->apply_span(); - rotation_attribute->apply_span(); + id_attribute.apply_span_and_save(); + normal_attribute.apply_span_and_save(); + rotation_attribute.apply_span_and_save(); } static void sample_mesh_surface_with_minimum_distance(const Mesh &mesh, diff --git a/source/blender/nodes/geometry/nodes/node_geo_point_rotate.cc b/source/blender/nodes/geometry/nodes/node_geo_point_rotate.cc index f22036ffe62..b1451dfb89e 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_point_rotate.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_point_rotate.cc @@ -104,13 +104,13 @@ static void point_rotate_on_component(GeometryComponent &component, const bNode &node = params.node(); const NodeGeometryRotatePoints &storage = *(const NodeGeometryRotatePoints *)node.storage; - WriteAttributePtr rotation_attribute = component.attribute_try_ensure_for_write( + OutputAttributePtr rotation_attribute = component.attribute_try_get_for_output( "rotation", ATTR_DOMAIN_POINT, CD_PROP_FLOAT3); if (!rotation_attribute) { return; } - MutableSpan<float3> rotations = rotation_attribute->get_span().typed<float3>(); + MutableSpan<float3> rotations = rotation_attribute->get_span<float3>(); const int domain_size = rotations.size(); if (storage.type == GEO_NODE_POINT_ROTATE_TYPE_AXIS_ANGLE) { @@ -138,7 +138,7 @@ static void point_rotate_on_component(GeometryComponent &component, } } - rotation_attribute->apply_span(); + rotation_attribute.apply_span_and_save(); } static void geo_node_point_rotate_exec(GeoNodeExecParams params) diff --git a/source/blender/nodes/geometry/nodes/node_geo_point_scale.cc b/source/blender/nodes/geometry/nodes/node_geo_point_scale.cc index 165f467fef0..e5cbe27768d 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_point_scale.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_point_scale.cc @@ -34,7 +34,7 @@ namespace blender::nodes { static void execute_on_component(GeoNodeExecParams params, GeometryComponent &component) { - Float3WriteAttribute scale_attribute = component.attribute_try_ensure_for_write( + OutputAttributePtr scale_attribute = component.attribute_try_get_for_output( "scale", ATTR_DOMAIN_POINT, CD_PROP_FLOAT3); ReadAttributePtr attribute = params.get_input_attribute( "Factor", component, ATTR_DOMAIN_POINT, CD_PROP_FLOAT3, nullptr); @@ -43,12 +43,12 @@ static void execute_on_component(GeoNodeExecParams params, GeometryComponent &co } Span<float3> data = attribute->get_span<float3>(); - MutableSpan<float3> scale_span = scale_attribute.get_span(); + MutableSpan<float3> scale_span = scale_attribute->get_span<float3>(); for (const int i : scale_span.index_range()) { scale_span[i] = scale_span[i] * data[i]; } - scale_attribute.apply_span(); + scale_attribute.apply_span_and_save(); } static void geo_node_point_scale_exec(GeoNodeExecParams params) diff --git a/source/blender/nodes/geometry/nodes/node_geo_point_translate.cc b/source/blender/nodes/geometry/nodes/node_geo_point_translate.cc index 1dbc6016024..72176b11fdb 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_point_translate.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_point_translate.cc @@ -34,7 +34,7 @@ namespace blender::nodes { static void execute_on_component(GeoNodeExecParams params, GeometryComponent &component) { - Float3WriteAttribute position_attribute = component.attribute_try_ensure_for_write( + OutputAttributePtr position_attribute = component.attribute_try_get_for_output( "position", ATTR_DOMAIN_POINT, CD_PROP_FLOAT3); ReadAttributePtr attribute = params.get_input_attribute( "Translation", component, ATTR_DOMAIN_POINT, CD_PROP_FLOAT3, nullptr); @@ -43,12 +43,12 @@ static void execute_on_component(GeoNodeExecParams params, GeometryComponent &co } Span<float3> data = attribute->get_span<float3>(); - MutableSpan<float3> scale_span = position_attribute.get_span(); + MutableSpan<float3> scale_span = position_attribute->get_span<float3>(); for (const int i : scale_span.index_range()) { scale_span[i] = scale_span[i] + data[i]; } - position_attribute.apply_span(); + position_attribute.apply_span_and_save(); } static void geo_node_point_translate_exec(GeoNodeExecParams params) |