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
This commit is contained in:
Bastien Montagne 2020-12-08 17:57:16 +01:00
parent e44e0e4e78
commit 2a8b987e9e
Notes: blender-bot 2023-02-14 06:25:25 +01:00
Referenced by issue #83422, Dimensions incorrect after undoing change to an object's dimension if it has a Mirror modifier
3 changed files with 8 additions and 29 deletions

View File

@ -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,

View File

@ -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)

View File

@ -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)