[Bf-blender-cvs] [2a8b987e9e4] master: Fix T83422: Dimensions incorrect after undoing if it has modified geometry.

Bastien Montagne noreply at git.blender.org
Mon Jan 11 17:59:37 CET 2021


Commit: 2a8b987e9e4dacd788ce955966d28c04ed91caf3
Author: Bastien Montagne
Date:   Tue Dec 8 17:57:16 2020 +0100
Branches: master
https://developer.blender.org/rB2a8b987e9e4dacd788ce955966d28c04ed91caf3

Fix T83422: Dimensions incorrect after undoing if it has modified geometry.

Root of the issue is that `BKE_object_eval_boundbox` (that ports back
evaluated bbox to orig object during active depsgraph evaluation) is
only called when object's geometry actually is evaluated.

However, with new undo, often Object itself can be changed by undo,
without requiring its geometry to be re-evaluated, which was leading to
the evaluated bbox not being copied back into orig object anymore.

Fixing that by moving bbox copying-to-orig code into
`BKE_object_sync_to_original` instead, which is always executed when
object is evaluated (as hinted by the comment above
`BKE_object_eval_boundbox` actually).

Also allows to cleanup code for armature eval, apparently.

Maniphest Tasks: T83422

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

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

M	source/blender/blenkernel/BKE_object.h
M	source/blender/blenkernel/intern/armature_update.c
M	source/blender/blenkernel/intern/object_update.c

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

diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h
index cd253ca4bbc..32d99191067 100644
--- a/source/blender/blenkernel/BKE_object.h
+++ b/source/blender/blenkernel/BKE_object.h
@@ -288,7 +288,6 @@ void BKE_object_eval_uber_data(struct Depsgraph *depsgraph,
                                struct Object *ob);
 void BKE_object_eval_assign_data(struct Object *object, struct ID *data, bool is_owned);
 
-void BKE_object_eval_boundbox(struct Depsgraph *depsgraph, struct Object *object);
 void BKE_object_sync_to_original(struct Depsgraph *depsgraph, struct Object *object);
 
 void BKE_object_eval_ptcache_reset(struct Depsgraph *depsgraph,
diff --git a/source/blender/blenkernel/intern/armature_update.c b/source/blender/blenkernel/intern/armature_update.c
index de00372c3ec..8c666597276 100644
--- a/source/blender/blenkernel/intern/armature_update.c
+++ b/source/blender/blenkernel/intern/armature_update.c
@@ -830,18 +830,6 @@ void BKE_pose_splineik_evaluate(struct Depsgraph *depsgraph,
   BKE_splineik_execute_tree(depsgraph, scene, object, rootchan, ctime);
 }
 
-/* Common part for both original and proxy armatrues. */
-static void pose_eval_done_common(struct Depsgraph *depsgraph, Object *object)
-{
-  const bArmature *armature = (bArmature *)object->data;
-  if (armature->edbo != NULL) {
-    return;
-  }
-  bPose *pose = object->pose;
-  UNUSED_VARS_NDEBUG(pose);
-  BLI_assert(pose != NULL);
-  BKE_object_eval_boundbox(depsgraph, object);
-}
 static void pose_eval_cleanup_common(Object *object)
 {
   bPose *pose = object->pose;
@@ -857,7 +845,6 @@ void BKE_pose_eval_done(struct Depsgraph *depsgraph, Object *object)
   UNUSED_VARS_NDEBUG(pose);
   DEG_debug_print_eval(depsgraph, __func__, object->id.name, object);
   BLI_assert(object->type == OB_ARMATURE);
-  pose_eval_done_common(depsgraph, object);
 }
 
 void BKE_pose_eval_cleanup(struct Depsgraph *depsgraph, Scene *scene, Object *object)
@@ -885,7 +872,6 @@ void BKE_pose_eval_proxy_done(struct Depsgraph *depsgraph, Object *object)
 {
   BLI_assert(ID_IS_LINKED(object) && object->proxy_from != NULL);
   DEG_debug_print_eval(depsgraph, __func__, object->id.name, object);
-  pose_eval_done_common(depsgraph, object);
 }
 
 void BKE_pose_eval_proxy_cleanup(struct Depsgraph *depsgraph, Object *object)
diff --git a/source/blender/blenkernel/intern/object_update.c b/source/blender/blenkernel/intern/object_update.c
index 1b4dc98252a..1d79f871fa2 100644
--- a/source/blender/blenkernel/intern/object_update.c
+++ b/source/blender/blenkernel/intern/object_update.c
@@ -268,25 +268,17 @@ void BKE_object_handle_data_update(Depsgraph *depsgraph, Scene *scene, Object *o
       }
     }
   }
-  BKE_object_eval_boundbox(depsgraph, ob);
 }
 
-/**
- * TODO(sergey): Ensure that bounding box is already calculated, and move this
- * into #BKE_object_sync_to_original().
- */
-void BKE_object_eval_boundbox(Depsgraph *depsgraph, Object *object)
+/** Bounding box from evaluated geometry. */
+static void object_sync_boundbox_to_original(Object *object_orig, Object *object_eval)
 {
-  if (!DEG_is_active(depsgraph)) {
-    return;
-  }
-  Object *ob_orig = DEG_get_original_object(object);
-  BoundBox *bb = BKE_object_boundbox_get(object);
+  BoundBox *bb = BKE_object_boundbox_get(object_eval);
   if (bb != NULL) {
-    if (ob_orig->runtime.bb == NULL) {
-      ob_orig->runtime.bb = MEM_mallocN(sizeof(*ob_orig->runtime.bb), __func__);
+    if (object_orig->runtime.bb == NULL) {
+      object_orig->runtime.bb = MEM_mallocN(sizeof(*object_orig->runtime.bb), __func__);
     }
-    *ob_orig->runtime.bb = *bb;
+    *object_orig->runtime.bb = *bb;
   }
 }
 
@@ -315,6 +307,8 @@ void BKE_object_sync_to_original(Depsgraph *depsgraph, Object *object)
       md_orig->error = BLI_strdup(md->error);
     }
   }
+
+  object_sync_boundbox_to_original(object_orig, object);
 }
 
 bool BKE_object_eval_proxy_copy(Depsgraph *depsgraph, Object *object)



More information about the Bf-blender-cvs mailing list