diff options
author | Jacques Lucke <jacques@blender.org> | 2021-09-29 11:55:32 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2021-09-29 11:55:32 +0300 |
commit | 24a965bb16c22e33752dfb6c22105b96a8649aeb (patch) | |
tree | 032646e69fb86b53a66024e96105ff4a56587497 /source/blender | |
parent | f51bef75f44681c7a33cf54c790ff4cee949c274 (diff) |
Fix T91767: crash when instancing geometry coming from modifier
The issue was that the `GeometrySet` that comes from the modifier does
not have full ownership of the mesh for legacy reasons to avoid copies.
Calling `ensure_owns_direct_data` makes sure that the geometry set
actually owns the geometry so that it can be instanced.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/nodes/geometry/nodes/node_geo_instance_on_points.cc | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/source/blender/nodes/geometry/nodes/node_geo_instance_on_points.cc b/source/blender/nodes/geometry/nodes/node_geo_instance_on_points.cc index 490535224c8..8c0c0763be8 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_instance_on_points.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_instance_on_points.cc @@ -57,10 +57,9 @@ static void geo_node_instance_on_points_declare(NodeDeclarationBuilder &b) static void add_instances_from_component(InstancesComponent &dst_component, const GeometryComponent &src_component, + const GeometrySet &instance, const GeoNodeExecParams ¶ms) { - GeometrySet instance = params.get_input<GeometrySet>("Instance"); - const AttributeDomain domain = ATTR_DOMAIN_POINT; const int domain_size = src_component.attribute_domain_size(domain); @@ -163,23 +162,27 @@ static void add_instances_from_component(InstancesComponent &dst_component, static void geo_node_instance_on_points_exec(GeoNodeExecParams params) { GeometrySet geometry_set = params.extract_input<GeometrySet>("Points"); + GeometrySet instance = params.get_input<GeometrySet>("Instance"); + instance.ensure_owns_direct_data(); geometry_set.modify_geometry_sets([&](GeometrySet &geometry_set) { InstancesComponent &instances = geometry_set.get_component_for_write<InstancesComponent>(); if (geometry_set.has<MeshComponent>()) { add_instances_from_component( - instances, *geometry_set.get_component_for_read<MeshComponent>(), params); + instances, *geometry_set.get_component_for_read<MeshComponent>(), instance, params); geometry_set.remove(GEO_COMPONENT_TYPE_MESH); } if (geometry_set.has<PointCloudComponent>()) { - add_instances_from_component( - instances, *geometry_set.get_component_for_read<PointCloudComponent>(), params); + add_instances_from_component(instances, + *geometry_set.get_component_for_read<PointCloudComponent>(), + instance, + params); geometry_set.remove(GEO_COMPONENT_TYPE_POINT_CLOUD); } if (geometry_set.has<CurveComponent>()) { add_instances_from_component( - instances, *geometry_set.get_component_for_read<CurveComponent>(), params); + instances, *geometry_set.get_component_for_read<CurveComponent>(), instance, params); geometry_set.remove(GEO_COMPONENT_TYPE_CURVE); } /* Unused references may have been added above. Remove those now so that other nodes don't |