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-11-23 11:32:12 +0300
committerJacques Lucke <jacques@blender.org>2021-11-23 11:32:12 +0300
commit6987060f7082e77cfc4ead7db3e7c9d6aaf349b1 (patch)
tree85190a83e5e7cfc77edc6396702e6569e78f597e
parentf749506163b7d2409c63c469f00e9bb1cbb2e68d (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
-rw-r--r--source/blender/blenkernel/intern/object.cc9
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;
}