diff options
author | Jacques Lucke <jacques@blender.org> | 2020-11-24 13:50:49 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2020-11-24 13:50:49 +0300 |
commit | 710842cd1de5a006edfe1a13bc432360c6138edc (patch) | |
tree | 0f43ae16b65ba4c492415435987a9cc2c724ffa3 | |
parent | 433fcbec1ac29106d5afaa37a81b93aba4ea47b2 (diff) |
Geometry Nodes: only output new data from Distribute and Instance nodes
This can be recombined with the original data using a
Join node if necessary.
-rw-r--r-- | source/blender/nodes/geometry/nodes/node_geo_point_distribute.cc | 13 | ||||
-rw-r--r-- | source/blender/nodes/geometry/nodes/node_geo_point_instance.cc | 7 |
2 files changed, 8 insertions, 12 deletions
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 7ab3bfba1b1..7f94ca35e6e 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_point_distribute.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_point_distribute.cc @@ -93,9 +93,10 @@ static Vector<float3> scatter_points_from_mesh(const Mesh *mesh, static void geo_node_point_distribute_exec(GeoNodeExecParams params) { GeometrySet geometry_set = params.extract_input<GeometrySet>("Geometry"); + GeometrySet geometry_set_out; if (!geometry_set.has_mesh()) { - params.set_output("Geometry", std::move(geometry_set)); + params.set_output("Geometry", std::move(geometry_set_out)); return; } @@ -103,9 +104,7 @@ static void geo_node_point_distribute_exec(GeoNodeExecParams params) const std::string density_attribute = params.extract_input<std::string>("Density Attribute"); if (density <= 0.0f) { - geometry_set.replace_mesh(nullptr); - geometry_set.replace_pointcloud(nullptr); - params.set_output("Geometry", std::move(geometry_set)); + params.set_output("Geometry", std::move(geometry_set_out)); return; } @@ -124,10 +123,8 @@ static void geo_node_point_distribute_exec(GeoNodeExecParams params) pointcloud->radius[i] = 0.05f; } - geometry_set.replace_mesh(nullptr); - geometry_set.replace_pointcloud(pointcloud); - - params.set_output("Geometry", std::move(geometry_set)); + geometry_set_out.replace_pointcloud(pointcloud); + params.set_output("Geometry", std::move(geometry_set_out)); } } // namespace blender::nodes diff --git a/source/blender/nodes/geometry/nodes/node_geo_point_instance.cc b/source/blender/nodes/geometry/nodes/node_geo_point_instance.cc index b8b7dc4cace..dfa50d38d43 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_point_instance.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_point_instance.cc @@ -76,13 +76,14 @@ static void add_instances_from_geometry_component(InstancesComponent &instances, static void geo_node_point_instance_exec(GeoNodeExecParams params) { GeometrySet geometry_set = params.extract_input<GeometrySet>("Geometry"); + GeometrySet geometry_set_out; bke::PersistentObjectHandle object_handle = params.extract_input<bke::PersistentObjectHandle>( "Object"); Object *object = params.handle_map().lookup(object_handle); if (object != nullptr) { - InstancesComponent &instances = geometry_set.get_component_for_write<InstancesComponent>(); + InstancesComponent &instances = geometry_set_out.get_component_for_write<InstancesComponent>(); if (geometry_set.has<MeshComponent>()) { add_instances_from_geometry_component( instances, *geometry_set.get_component_for_read<MeshComponent>(), object, params); @@ -93,9 +94,7 @@ static void geo_node_point_instance_exec(GeoNodeExecParams params) } } - geometry_set.remove<MeshComponent>(); - geometry_set.remove<PointCloudComponent>(); - params.set_output("Geometry", std::move(geometry_set)); + params.set_output("Geometry", std::move(geometry_set_out)); } } // namespace blender::nodes |