diff options
author | Jacques Lucke <jacques@blender.org> | 2021-04-16 14:46:21 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2021-04-16 14:46:21 +0300 |
commit | be34d14575c494c5e291f5e96b397112683089b4 (patch) | |
tree | 529517678abba0c1b43803753563b04bc9eecb6a /source/blender/blenkernel/intern/geometry_set_instances.cc | |
parent | 45eafd65622d38a60341df7c79701c1fef152de4 (diff) | |
parent | 68c4ba348213b66543cdcd21da755fefaf286ef2 (diff) |
Merge branch 'blender-v2.93-release'
Diffstat (limited to 'source/blender/blenkernel/intern/geometry_set_instances.cc')
-rw-r--r-- | source/blender/blenkernel/intern/geometry_set_instances.cc | 40 |
1 files changed, 26 insertions, 14 deletions
diff --git a/source/blender/blenkernel/intern/geometry_set_instances.cc b/source/blender/blenkernel/intern/geometry_set_instances.cc index baeed4fc3bc..07d0e520c93 100644 --- a/source/blender/blenkernel/intern/geometry_set_instances.cc +++ b/source/blender/blenkernel/intern/geometry_set_instances.cc @@ -36,30 +36,42 @@ static void geometry_set_collect_recursive_collection(const Collection &collecti const float4x4 &transform, Vector<GeometryInstanceGroup> &r_sets); +static void add_final_mesh_as_geometry_component(const Object &object, GeometrySet &geometry_set) +{ + Mesh *mesh = BKE_modifier_get_evaluated_mesh_from_evaluated_object(&const_cast<Object &>(object), + false); + + if (mesh != nullptr) { + BKE_mesh_wrapper_ensure_mdata(mesh); + + MeshComponent &mesh_component = geometry_set.get_component_for_write<MeshComponent>(); + mesh_component.replace(mesh, GeometryOwnershipType::ReadOnly); + mesh_component.copy_vertex_group_names_from_object(object); + } +} + /** * \note This doesn't extract instances from the "dupli" system for non-geometry-nodes instances. */ static GeometrySet object_get_geometry_set_for_read(const Object &object) { - /* Objects evaluated with a nodes modifier will have a geometry set already. */ + if (object.type == OB_MESH && object.mode == OB_MODE_EDIT) { + GeometrySet geometry_set; + if (object.runtime.geometry_set_eval != nullptr) { + /* `geometry_set_eval` only contains non-mesh components, see `editbmesh_build_data`. */ + geometry_set = *object.runtime.geometry_set_eval; + } + add_final_mesh_as_geometry_component(object, geometry_set); + return geometry_set; + } if (object.runtime.geometry_set_eval != nullptr) { return *object.runtime.geometry_set_eval; } /* Otherwise, construct a new geometry set with the component based on the object type. */ - GeometrySet new_geometry_set; - + GeometrySet geometry_set; if (object.type == OB_MESH) { - Mesh *mesh = BKE_modifier_get_evaluated_mesh_from_evaluated_object( - &const_cast<Object &>(object), false); - - if (mesh != nullptr) { - BKE_mesh_wrapper_ensure_mdata(mesh); - - MeshComponent &mesh_component = new_geometry_set.get_component_for_write<MeshComponent>(); - mesh_component.replace(mesh, GeometryOwnershipType::ReadOnly); - mesh_component.copy_vertex_group_names_from_object(object); - } + add_final_mesh_as_geometry_component(object, geometry_set); } /* TODO: Cover the case of point-clouds without modifiers-- they may not be covered by the @@ -68,7 +80,7 @@ static GeometrySet object_get_geometry_set_for_read(const Object &object) /* TODO: Add volume support. */ /* Return by value since there is not always an existing geometry set owned elsewhere to use. */ - return new_geometry_set; + return geometry_set; } static void geometry_set_collect_recursive_collection_instance( |