Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacques Lucke <jacques@blender.org>2021-04-16 14:05:32 +0300
committerJacques Lucke <jacques@blender.org>2021-04-16 14:05:49 +0300
commit1266df87c86067d7c2d18ef71dd0e5520de1a382 (patch)
treec9fa6f56c3a72a8ee934cd7c9b76cd7a25992705
parentbb9c83b9ffcd50afbc2f26eafebe49ccb165c042 (diff)
Fix unreported: instances disappear when instanced mesh is in edit mode
The issue is that for historic reasons, `geometry_set_eval` does not contain the mesh component when the object is in edit mode.
-rw-r--r--source/blender/blenkernel/intern/geometry_set_instances.cc40
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(