From 2a8b987e9e4dacd788ce955966d28c04ed91caf3 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Tue, 8 Dec 2020 17:57:16 +0100 Subject: 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 --- source/blender/blenkernel/intern/object_update.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) (limited to 'source/blender/blenkernel/intern/object_update.c') 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) -- cgit v1.2.3