[Bf-blender-cvs] [c7fcc50842d] blender-v3.0-release: Fix T91986: incorrect syncing of geometry instances

Jacques Lucke noreply at git.blender.org
Thu Nov 4 18:32:10 CET 2021


Commit: c7fcc50842d85664d2b07c32b181951ea7661440
Author: Jacques Lucke
Date:   Thu Nov 4 18:32:01 2021 +0100
Branches: blender-v3.0-release
https://developer.blender.org/rBc7fcc50842d85664d2b07c32b181951ea7661440

Fix T91986: incorrect syncing of geometry instances

The issue was that some geometries were not synced again even when
they changed. This commit adds a map that keeps track of the geometries
that need to be updated when an object has changed.

Differential Revision: https://developer.blender.org/D13020

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

M	intern/cycles/blender/object.cpp
M	intern/cycles/blender/sync.cpp
M	intern/cycles/blender/sync.h
M	source/blender/makesrna/intern/makesrna.c

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

diff --git a/intern/cycles/blender/object.cpp b/intern/cycles/blender/object.cpp
index 9919b9d1836..3800ea0ecd2 100644
--- a/intern/cycles/blender/object.cpp
+++ b/intern/cycles/blender/object.cpp
@@ -161,6 +161,11 @@ Object *BlenderSync::sync_object(BL::Depsgraph &b_depsgraph,
   if (is_instance) {
     persistent_id_array = b_instance.persistent_id();
     persistent_id = persistent_id_array.data;
+    if (!b_ob_info.is_real_object_data()) {
+      /* Remember which object data the geometry is coming from, so that we can sync it when the
+       * object has changed. */
+      instance_geometries_by_object[b_ob_info.real_object.ptr.data].insert(b_ob_info.object_data);
+    }
   }
 
   /* light is handled separately */
@@ -560,6 +565,7 @@ void BlenderSync::sync_objects(BL::Depsgraph &b_depsgraph,
   else {
     geometry_motion_synced.clear();
   }
+  instance_geometries_by_object.clear();
 
   /* initialize culling */
   BlenderObjectCulling culling(scene, b_scene);
diff --git a/intern/cycles/blender/sync.cpp b/intern/cycles/blender/sync.cpp
index cf0b77a9b16..ffd1e78b7f8 100644
--- a/intern/cycles/blender/sync.cpp
+++ b/intern/cycles/blender/sync.cpp
@@ -183,6 +183,15 @@ void BlenderSync::sync_recalc(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d
               (object_subdivision_type(b_ob, preview, experimental) != Mesh::SUBDIVISION_NONE)) {
             BL::ID key = BKE_object_is_modified(b_ob) ? b_ob : b_ob.data();
             geometry_map.set_recalc(key);
+
+            /* Sync all contained geometry instances as well when the object changed.. */
+            map<void *, set<BL::ID>>::const_iterator instance_geometries =
+                instance_geometries_by_object.find(b_ob.ptr.data);
+            if (instance_geometries != instance_geometries_by_object.end()) {
+              for (BL::ID geometry : instance_geometries->second) {
+                geometry_map.set_recalc(geometry);
+              }
+            }
           }
 
           if (updated_geometry) {
diff --git a/intern/cycles/blender/sync.h b/intern/cycles/blender/sync.h
index c2377406876..7e5d0324ca9 100644
--- a/intern/cycles/blender/sync.h
+++ b/intern/cycles/blender/sync.h
@@ -225,6 +225,8 @@ class BlenderSync {
   set<Geometry *> geometry_synced;
   set<Geometry *> geometry_motion_synced;
   set<Geometry *> geometry_motion_attribute_synced;
+  /** Remember which geometries come from which objects to be able to sync them after changes. */
+  map<void *, set<BL::ID>> instance_geometries_by_object;
   set<float> motion_times;
   void *world_map;
   bool world_recalc;
diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c
index 36f19907080..f2e87b29c1f 100644
--- a/source/blender/makesrna/intern/makesrna.c
+++ b/source/blender/makesrna/intern/makesrna.c
@@ -4792,6 +4792,7 @@ static const char *cpp_classes =
     "\n"
     "    bool operator==(const Pointer &other) const { return ptr.data == other.ptr.data; }\n"
     "    bool operator!=(const Pointer &other) const { return ptr.data != other.ptr.data; }\n"
+    "    bool operator<(const Pointer &other) const { return ptr.data < other.ptr.data; }\n"
     "\n"
     "    PointerRNA ptr;\n"
     "};\n"



More information about the Bf-blender-cvs mailing list