diff options
author | Hans Goudey <h.goudey@me.com> | 2021-04-25 23:01:19 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2021-04-25 23:01:19 +0300 |
commit | 9636e79c5a1b4fcf25c9a83a8f6cf5c8142fd328 (patch) | |
tree | 9f9fca5dae55130e585408c33fd5fddff93a17d4 /source | |
parent | e1c04da36f32d49f27a327fdd1a747837665f3f5 (diff) |
Splines: Reset unecessary geometry nodes changes
Diffstat (limited to 'source')
20 files changed, 175 insertions, 56 deletions
diff --git a/source/blender/blenkernel/BKE_geometry_set.hh b/source/blender/blenkernel/BKE_geometry_set.hh index cfcd9d25638..78d63aa412c 100644 --- a/source/blender/blenkernel/BKE_geometry_set.hh +++ b/source/blender/blenkernel/BKE_geometry_set.hh @@ -349,7 +349,6 @@ struct GeometrySet { void add(const GeometryComponent &component); blender::Vector<const GeometryComponent *> get_components_for_read() const; - blender::Vector<GeometryComponent *> get_components_for_write(); void compute_boundbox_without_instances(blender::float3 *r_min, blender::float3 *r_max) const; diff --git a/source/blender/blenkernel/intern/geometry_set.cc b/source/blender/blenkernel/intern/geometry_set.cc index 1493eedf01c..646afcc702f 100644 --- a/source/blender/blenkernel/intern/geometry_set.cc +++ b/source/blender/blenkernel/intern/geometry_set.cc @@ -171,19 +171,6 @@ Vector<const GeometryComponent *> GeometrySet::get_components_for_read() const return components; } -/** - * Get all geometry components in this geometry set. - */ -Vector<GeometryComponent *> GeometrySet::get_components_for_write() -{ - Vector<GeometryComponent *> components; - - for (const GeometryComponentType component_type : components_.keys()) { - components.append(&this->get_component_for_write(component_type)); - } - return components; -} - void GeometrySet::compute_boundbox_without_instances(float3 *r_min, float3 *r_max) const { const PointCloud *pointcloud = this->get_pointcloud_for_read(); diff --git a/source/blender/functions/FN_generic_virtual_array.hh b/source/blender/functions/FN_generic_virtual_array.hh index a7a13c02461..2a7d01a7423 100644 --- a/source/blender/functions/FN_generic_virtual_array.hh +++ b/source/blender/functions/FN_generic_virtual_array.hh @@ -642,7 +642,7 @@ class GVArray_For_EmbeddedVArray : public GVArray_For_VArray<T> { public: template<typename... Args> - GVArray_For_EmbeddedVArray(const int64_t size, Args &&...args) + GVArray_For_EmbeddedVArray(const int64_t size, Args &&... args) : GVArray_For_VArray<T>(size), embedded_varray_(std::forward<Args>(args)...) { this->varray_ = &embedded_varray_; @@ -657,7 +657,7 @@ class GVMutableArray_For_EmbeddedVMutableArray : public GVMutableArray_For_VMuta public: template<typename... Args> - GVMutableArray_For_EmbeddedVMutableArray(const int64_t size, Args &&...args) + GVMutableArray_For_EmbeddedVMutableArray(const int64_t size, Args &&... args) : GVMutableArray_For_VMutableArray<T>(size), embedded_varray_(std::forward<Args>(args)...) { this->varray_ = &embedded_varray_; 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 371740bfd7c..870d09da001 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 @@ -176,8 +176,15 @@ static void geo_node_align_rotation_to_vector_exec(GeoNodeExecParams params) geometry_set = geometry_set_realize_instances(geometry_set); - for (GeometryComponent *component : geometry_set.get_components_for_write()) { - align_rotations_on_component(*component, params); + if (geometry_set.has<MeshComponent>()) { + align_rotations_on_component(geometry_set.get_component_for_write<MeshComponent>(), params); + } + if (geometry_set.has<PointCloudComponent>()) { + align_rotations_on_component(geometry_set.get_component_for_write<PointCloudComponent>(), + params); + } + if (geometry_set.has<CurveComponent>()) { + align_rotations_on_component(geometry_set.get_component_for_write<CurveComponent>(), params); } params.set_output("Geometry", geometry_set); diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_clamp.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_clamp.cc index b544c962849..21538db5455 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_attribute_clamp.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_clamp.cc @@ -249,8 +249,14 @@ static void geo_node_attribute_clamp_exec(GeoNodeExecParams params) geometry_set = geometry_set_realize_instances(geometry_set); - for (GeometryComponent *component : geometry_set.get_components_for_write()) { - clamp_attribute(*component, params); + if (geometry_set.has<MeshComponent>()) { + clamp_attribute(geometry_set.get_component_for_write<MeshComponent>(), params); + } + if (geometry_set.has<PointCloudComponent>()) { + clamp_attribute(geometry_set.get_component_for_write<PointCloudComponent>(), params); + } + if (geometry_set.has<CurveComponent>()) { + clamp_attribute(geometry_set.get_component_for_write<CurveComponent>(), params); } params.set_output("Geometry", geometry_set); 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 6e41573470d..07f29b81bc5 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 @@ -98,8 +98,14 @@ static void geo_node_attribute_color_ramp_exec(GeoNodeExecParams params) geometry_set = geometry_set_realize_instances(geometry_set); - for (GeometryComponent *component : geometry_set.get_components_for_write()) { - execute_on_component(params, *component); + if (geometry_set.has<MeshComponent>()) { + execute_on_component(params, geometry_set.get_component_for_write<MeshComponent>()); + } + if (geometry_set.has<PointCloudComponent>()) { + execute_on_component(params, geometry_set.get_component_for_write<PointCloudComponent>()); + } + if (geometry_set.has<CurveComponent>()) { + execute_on_component(params, geometry_set.get_component_for_write<CurveComponent>()); } params.set_output("Geometry", std::move(geometry_set)); diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_combine_xyz.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_combine_xyz.cc index 460db230fdb..d8c52d16f41 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_attribute_combine_xyz.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_combine_xyz.cc @@ -121,8 +121,14 @@ static void geo_node_attribute_combine_xyz_exec(GeoNodeExecParams params) geometry_set = geometry_set_realize_instances(geometry_set); - for (GeometryComponent *component : geometry_set.get_components_for_write()) { - combine_attributes(*component, params); + if (geometry_set.has<MeshComponent>()) { + combine_attributes(geometry_set.get_component_for_write<MeshComponent>(), params); + } + if (geometry_set.has<PointCloudComponent>()) { + combine_attributes(geometry_set.get_component_for_write<PointCloudComponent>(), params); + } + if (geometry_set.has<CurveComponent>()) { + combine_attributes(geometry_set.get_component_for_write<CurveComponent>(), params); } params.set_output("Geometry", geometry_set); 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 dfaeeaa85aa..a2ff1668a06 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_attribute_compare.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_compare.cc @@ -328,8 +328,14 @@ static void geo_node_attribute_compare_exec(GeoNodeExecParams params) geometry_set = geometry_set_realize_instances(geometry_set); - for (GeometryComponent *component : geometry_set.get_components_for_write()) { - attribute_compare_calc(*component, params); + if (geometry_set.has<MeshComponent>()) { + attribute_compare_calc(geometry_set.get_component_for_write<MeshComponent>(), params); + } + if (geometry_set.has<PointCloudComponent>()) { + attribute_compare_calc(geometry_set.get_component_for_write<PointCloudComponent>(), params); + } + if (geometry_set.has<CurveComponent>()) { + attribute_compare_calc(geometry_set.get_component_for_write<CurveComponent>(), params); } params.set_output("Geometry", geometry_set); diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_convert.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_convert.cc index cfc8e5801fc..d084f806500 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_attribute_convert.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_convert.cc @@ -147,8 +147,29 @@ static void geo_node_attribute_convert_exec(GeoNodeExecParams params) return; } - for (GeometryComponent *component : geometry_set.get_components_for_write()) { - attribute_convert_calc(*component, params, source_name, result_name, data_type, domain); + if (geometry_set.has<MeshComponent>()) { + attribute_convert_calc(geometry_set.get_component_for_write<MeshComponent>(), + params, + source_name, + result_name, + data_type, + domain); + } + if (geometry_set.has<PointCloudComponent>()) { + attribute_convert_calc(geometry_set.get_component_for_write<PointCloudComponent>(), + params, + source_name, + result_name, + data_type, + domain); + } + if (geometry_set.has<CurveComponent>()) { + attribute_convert_calc(geometry_set.get_component_for_write<CurveComponent>(), + params, + source_name, + result_name, + data_type, + domain); } params.set_output("Geometry", geometry_set); 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 dd77a8101b5..60522fd0f72 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_attribute_fill.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_fill.cc @@ -137,8 +137,14 @@ static void geo_node_attribute_fill_exec(GeoNodeExecParams params) geometry_set = geometry_set_realize_instances(geometry_set); - for (GeometryComponent *component : geometry_set.get_components_for_write()) { - fill_attribute(*component, params); + if (geometry_set.has<MeshComponent>()) { + fill_attribute(geometry_set.get_component_for_write<MeshComponent>(), params); + } + if (geometry_set.has<PointCloudComponent>()) { + fill_attribute(geometry_set.get_component_for_write<PointCloudComponent>(), params); + } + if (geometry_set.has<CurveComponent>()) { + fill_attribute(geometry_set.get_component_for_write<CurveComponent>(), params); } params.set_output("Geometry", geometry_set); diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_map_range.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_map_range.cc index 6b7e3ba3a3f..102649205db 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_attribute_map_range.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_map_range.cc @@ -382,8 +382,14 @@ static void geo_node_attribute_map_range_exec(GeoNodeExecParams params) { GeometrySet geometry_set = params.extract_input<GeometrySet>("Geometry"); - for (GeometryComponent *component : geometry_set.get_components_for_write()) { - map_range_attribute(*component, params); + if (geometry_set.has<MeshComponent>()) { + map_range_attribute(geometry_set.get_component_for_write<MeshComponent>(), params); + } + if (geometry_set.has<PointCloudComponent>()) { + map_range_attribute(geometry_set.get_component_for_write<PointCloudComponent>(), params); + } + if (geometry_set.has<CurveComponent>()) { + map_range_attribute(geometry_set.get_component_for_write<CurveComponent>(), params); } params.set_output("Geometry", geometry_set); 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 8f03e0db04f..d131437f364 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_attribute_math.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_math.cc @@ -265,8 +265,14 @@ static void geo_node_attribute_math_exec(GeoNodeExecParams params) geometry_set = geometry_set_realize_instances(geometry_set); - for (GeometryComponent *component : geometry_set.get_components_for_write()) { - attribute_math_calc(*component, params); + if (geometry_set.has<MeshComponent>()) { + attribute_math_calc(geometry_set.get_component_for_write<MeshComponent>(), params); + } + if (geometry_set.has<PointCloudComponent>()) { + attribute_math_calc(geometry_set.get_component_for_write<PointCloudComponent>(), params); + } + if (geometry_set.has<CurveComponent>()) { + attribute_math_calc(geometry_set.get_component_for_write<CurveComponent>(), params); } params.set_output("Geometry", geometry_set); 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 dcec53b53d9..bbea05fa6a1 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_attribute_mix.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_mix.cc @@ -195,8 +195,14 @@ static void geo_node_attribute_mix_exec(GeoNodeExecParams params) geometry_set = geometry_set_realize_instances(geometry_set); - for (GeometryComponent *component : geometry_set.get_components_for_write()) { - attribute_mix_calc(*component, params); + if (geometry_set.has<MeshComponent>()) { + attribute_mix_calc(geometry_set.get_component_for_write<MeshComponent>(), params); + } + if (geometry_set.has<PointCloudComponent>()) { + attribute_mix_calc(geometry_set.get_component_for_write<PointCloudComponent>(), params); + } + if (geometry_set.has<CurveComponent>()) { + attribute_mix_calc(geometry_set.get_component_for_write<CurveComponent>(), params); } params.set_output("Geometry", geometry_set); diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_proximity.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_proximity.cc index 4a408b5941e..9c22b7fa87f 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_attribute_proximity.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_proximity.cc @@ -245,8 +245,17 @@ static void geo_node_attribute_proximity_exec(GeoNodeExecParams params) * for the target geometry set. However, the generic BVH API complicates this. */ geometry_set_target = geometry_set_realize_instances(geometry_set_target); - for (GeometryComponent *component : geometry_set.get_components_for_write()) { - attribute_calc_proximity(*component, geometry_set_target, params); + if (geometry_set.has<MeshComponent>()) { + attribute_calc_proximity( + geometry_set.get_component_for_write<MeshComponent>(), geometry_set_target, params); + } + if (geometry_set.has<PointCloudComponent>()) { + attribute_calc_proximity( + geometry_set.get_component_for_write<PointCloudComponent>(), geometry_set_target, params); + } + if (geometry_set.has<CurveComponent>()) { + attribute_calc_proximity( + geometry_set.get_component_for_write<CurveComponent>(), geometry_set_target, params); } params.set_output("Geometry", geometry_set); 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 f10e752268a..9fc8326457e 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_attribute_randomize.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_randomize.cc @@ -286,9 +286,29 @@ static void geo_node_random_attribute_exec(GeoNodeExecParams params) geometry_set = geometry_set_realize_instances(geometry_set); - for (GeometryComponent *component : geometry_set.get_components_for_write()) { - randomize_attribute_on_component( - *component, params, attribute_name, data_type, operation, seed); + if (geometry_set.has<MeshComponent>()) { + randomize_attribute_on_component(geometry_set.get_component_for_write<MeshComponent>(), + params, + attribute_name, + data_type, + operation, + seed); + } + if (geometry_set.has<PointCloudComponent>()) { + randomize_attribute_on_component(geometry_set.get_component_for_write<PointCloudComponent>(), + params, + attribute_name, + data_type, + operation, + seed); + } + if (geometry_set.has<CurveComponent>()) { + randomize_attribute_on_component(geometry_set.get_component_for_write<CurveComponent>(), + params, + attribute_name, + data_type, + operation, + seed); } params.set_output("Geometry", geometry_set); diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_remove.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_remove.cc index e4d5354a5c5..e4f3230ebb9 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_attribute_remove.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_remove.cc @@ -62,8 +62,17 @@ static void geo_node_attribute_remove_exec(GeoNodeExecParams params) geometry_set = geometry_set_realize_instances(geometry_set); - for (GeometryComponent *component : geometry_set.get_components_for_write()) { - remove_attribute(*component, params, attribute_names); + if (geometry_set.has<MeshComponent>()) { + remove_attribute( + geometry_set.get_component_for_write<MeshComponent>(), params, attribute_names); + } + if (geometry_set.has<PointCloudComponent>()) { + remove_attribute( + geometry_set.get_component_for_write<PointCloudComponent>(), params, attribute_names); + } + if (geometry_set.has<CurveComponent>()) { + remove_attribute( + geometry_set.get_component_for_write<CurveComponent>(), params, attribute_names); } params.set_output("Geometry", geometry_set); diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_sample_texture.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_sample_texture.cc index 26912efff4c..5fbf894541f 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_attribute_sample_texture.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_sample_texture.cc @@ -112,8 +112,14 @@ static void geo_node_attribute_sample_texture_exec(GeoNodeExecParams params) geometry_set = geometry_set_realize_instances(geometry_set); - for (GeometryComponent *component : geometry_set.get_components_for_write()) { - execute_on_component(*component, params); + if (geometry_set.has<MeshComponent>()) { + execute_on_component(geometry_set.get_component_for_write<MeshComponent>(), params); + } + if (geometry_set.has<PointCloudComponent>()) { + execute_on_component(geometry_set.get_component_for_write<PointCloudComponent>(), params); + } + if (geometry_set.has<CurveComponent>()) { + execute_on_component(geometry_set.get_component_for_write<CurveComponent>(), params); } params.set_output("Geometry", geometry_set); diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_separate_xyz.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_separate_xyz.cc index 5192934d611..148ed212633 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_attribute_separate_xyz.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_separate_xyz.cc @@ -142,8 +142,14 @@ static void geo_node_attribute_separate_xyz_exec(GeoNodeExecParams params) geometry_set = geometry_set_realize_instances(geometry_set); - for (GeometryComponent *component : geometry_set.get_components_for_write()) { - separate_attribute(*component, params); + if (geometry_set.has<MeshComponent>()) { + separate_attribute(geometry_set.get_component_for_write<MeshComponent>(), params); + } + if (geometry_set.has<PointCloudComponent>()) { + separate_attribute(geometry_set.get_component_for_write<PointCloudComponent>(), params); + } + if (geometry_set.has<PointCloudComponent>()) { + separate_attribute(geometry_set.get_component_for_write<PointCloudComponent>(), params); } params.set_output("Geometry", geometry_set); 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 749fc54443a..ba846b361f5 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 @@ -503,8 +503,15 @@ static void geo_node_attribute_vector_math_exec(GeoNodeExecParams params) geometry_set = geometry_set_realize_instances(geometry_set); - for (GeometryComponent *component : geometry_set.get_components_for_write()) { - attribute_vector_math_calc(*component, params); + if (geometry_set.has<MeshComponent>()) { + attribute_vector_math_calc(geometry_set.get_component_for_write<MeshComponent>(), params); + } + if (geometry_set.has<PointCloudComponent>()) { + attribute_vector_math_calc(geometry_set.get_component_for_write<PointCloudComponent>(), + params); + } + if (geometry_set.has<CurveComponent>()) { + attribute_vector_math_calc(geometry_set.get_component_for_write<CurveComponent>(), params); } params.set_output("Geometry", geometry_set); diff --git a/source/blender/nodes/geometry/nodes/node_geo_join_geometry.cc b/source/blender/nodes/geometry/nodes/node_geo_join_geometry.cc index 4f994a75a0e..dd97bd65f69 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_join_geometry.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_join_geometry.cc @@ -262,8 +262,9 @@ static void join_components(Span<const VolumeComponent *> src_components, Geomet } /** - * Curve components are a special case, retrieved with write access as an optimization - * to avoid copying unecessarily when possible. + * Curve components are a special case. It's possibly to exploit the fact that they simply store + * splines by retrieved with write access is an optimization to avoid copying unecessarily when + * possible. */ static void join_curve_components(MutableSpan<GeometrySet> src_geometry_sets, GeometrySet &result) { @@ -271,10 +272,10 @@ static void join_curve_components(MutableSpan<GeometrySet> src_geometry_sets, Ge Vector<CurveComponent *> src_components; for (GeometrySet &geometry_set : src_geometry_sets) { if (geometry_set.has_curve()) { - /* Getting write access for write access seems counterintuitive at first, but it can actually - * allow avoiding a copy in the case where the input spline has no other users, because the - * splines can be moved from the source curve rather than copying them from a read-only - * source. Retrieving the curve for write will make a copy only when necessary. */ + /* Getting write access for write access seems counterintuitive, but it can actually allow + * avoiding a copy in the case where the input spline has no other users, because the splines + * can be moved from the source curve rather than copying them from a read-only source. + * Retrieving the curve for write will make a copy only when it has a user elsewhere. */ CurveComponent &component = geometry_set.get_component_for_write<CurveComponent>(); src_components.append(&component); } @@ -291,7 +292,6 @@ static void join_curve_components(MutableSpan<GeometrySet> src_geometry_sets, Ge CurveComponent &dst_component = result.get_component_for_write<CurveComponent>(); DCurve *dst_curve = new DCurve(); for (CurveComponent *component : src_components) { - DCurve *src_curve = component->get_for_write(); for (SplinePtr &spline : src_curve->splines) { dst_curve->splines.append(std::move(spline)); |