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.
This commit is contained in:
parent
bb9c83b9ff
commit
1266df87c8
Notes:
blender-bot
2023-02-14 06:27:47 +01:00
Referenced by issue #87554, freezes when entering edit mode with active geometry nodes
|
@ -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(
|
||||
|
|
Loading…
Reference in New Issue