[Bf-blender-cvs] [6987060f708] blender-v3.0-release: Fix T93090: crash with data transfer modifier and geometry nodes

Jacques Lucke noreply at git.blender.org
Tue Nov 23 09:32:54 CET 2021


Commit: 6987060f7082e77cfc4ead7db3e7c9d6aaf349b1
Author: Jacques Lucke
Date:   Tue Nov 23 09:32:12 2021 +0100
Branches: blender-v3.0-release
https://developer.blender.org/rB6987060f7082e77cfc4ead7db3e7c9d6aaf349b1

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

===================================================================

M	source/blender/blenkernel/intern/object.cc

===================================================================

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;
     }



More information about the Bf-blender-cvs mailing list