diff options
author | Jacques Lucke <jacques@blender.org> | 2021-11-23 11:32:12 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2021-11-23 11:32:12 +0300 |
commit | 6987060f7082e77cfc4ead7db3e7c9d6aaf349b1 (patch) | |
tree | 85190a83e5e7cfc77edc6396702e6569e78f597e /source | |
parent | f749506163b7d2409c63c469f00e9bb1cbb2e68d (diff) |
Fix T93090: crash with data transfer modifier and geometry nodes
There was a missing normals layer that was requested by the data transfer
modifier from the target object. The normal layer was correctly added to
the target object. However, it never reached the data transfer modifier
because the mesh was copied in `BKE_object_get_evaluated_mesh`
(in the call to `get_mesh_for_write`) and the copy does not include the normals
layer.
The solution is to not use `get_mesh_for_write` here which was only used
because `BKE_object_get_evaluated_mesh` returns a non-const `Mesh *`.
Mid term, it should actually return a `const Mesh *` to avoid the confusion.
Differential Revision: https://developer.blender.org/D13319
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/intern/object.cc | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/source/blender/blenkernel/intern/object.cc b/source/blender/blenkernel/intern/object.cc index deef053b658..4b01ee29828 100644 --- a/source/blender/blenkernel/intern/object.cc +++ b/source/blender/blenkernel/intern/object.cc @@ -4564,10 +4564,11 @@ Mesh *BKE_object_get_evaluated_mesh(const Object *object) * object types either store it there or add a reference to it if it's owned elsewhere. */ GeometrySet *geometry_set_eval = object->runtime.geometry_set_eval; if (geometry_set_eval) { - /* Some areas expect to be able to modify the evaluated mesh. Theoretically this should be - * avoided, or at least protected with a lock, so a const mesh could be returned from this - * function. */ - Mesh *mesh = geometry_set_eval->get_mesh_for_write(); + /* Some areas expect to be able to modify the evaluated mesh in limited ways. Theoretically + * this should be avoided, or at least protected with a lock, so a const mesh could be returned + * from this function. We use a const_cast instead of #get_mesh_for_write, because that might + * result in a copy of the mesh when it is shared. */ + Mesh *mesh = const_cast<Mesh *>(geometry_set_eval->get_mesh_for_read()); if (mesh) { return mesh; } |