diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2017-11-29 17:29:39 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2017-11-29 17:37:09 +0300 |
commit | 60703e45f36a92f8e49a7be7c951538e5b747a41 (patch) | |
tree | d6fea68e590991c636ea4499687a4e45f6ee2299 /source/blender | |
parent | c8b1a83a8c41f5e162a3c9b31ea75923415d57cd (diff) |
Transform: Avoid use of ob->recalc in snapping code
Do a direct update of object transform instead, without involving
manual trickery of recalc flag.
Shouldn't be functional changes as far as artists are concerned,
but will allow us to get rid of recalc flags in 2.8.
Thanks Bastien for review!
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/BKE_object.h | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/object_update.c | 16 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_snap.c | 7 |
3 files changed, 22 insertions, 5 deletions
diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h index d1a4033957b..2772b3e2e6b 100644 --- a/source/blender/blenkernel/BKE_object.h +++ b/source/blender/blenkernel/BKE_object.h @@ -201,6 +201,10 @@ void BKE_object_eval_cloth(struct EvaluationContext *eval_ctx, struct Object *object); +void BKE_object_eval_transform_all(struct EvaluationContext *eval_ctx, + struct Scene *scene, + struct Object *object); + void BKE_object_handle_data_update(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob); diff --git a/source/blender/blenkernel/intern/object_update.c b/source/blender/blenkernel/intern/object_update.c index 17721a8077f..fd2b5ff589f 100644 --- a/source/blender/blenkernel/intern/object_update.c +++ b/source/blender/blenkernel/intern/object_update.c @@ -342,3 +342,19 @@ void BKE_object_eval_cloth(EvaluationContext *UNUSED(eval_ctx), Scene *scene, Ob DEBUG_PRINT("%s on %s\n", __func__, object->id.name); BKE_ptcache_object_reset(scene, object, PTCACHE_RESET_DEPSGRAPH); } + +void BKE_object_eval_transform_all(EvaluationContext *eval_ctx, + Scene *scene, + Object *object) +{ + /* This mimics full transform update chain from new depsgraph. */ + BKE_object_eval_local_transform(eval_ctx, scene, object); + if (object->parent != NULL) { + BKE_object_eval_parent(eval_ctx, scene, object); + } + if (!BLI_listbase_is_empty(&object->constraints)) { + BKE_object_eval_constraints(eval_ctx, scene, object); + } + BKE_object_eval_uber_transform(eval_ctx, scene, object); + BKE_object_eval_done(eval_ctx, object); +} diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index 45b8ca3749f..5750224de3d 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -316,9 +316,7 @@ void applyProject(TransInfo *t) mul_m4_v3(ob->obmat, iloc); } else if (t->flag & T_OBJECT) { - /* TODO(sergey): Ideally force update is not needed here. */ - td->ob->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME; - BKE_object_handle_update(G.main->eval_ctx, t->scene, td->ob); + BKE_object_eval_transform_all(G.main->eval_ctx, t->scene, td->ob); copy_v3_v3(iloc, td->ob->obmat[3]); } @@ -407,8 +405,7 @@ void applyGridAbsolute(TransInfo *t) mul_m4_v3(obmat, iloc); } else if (t->flag & T_OBJECT) { - td->ob->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME; - BKE_object_handle_update(G.main->eval_ctx, t->scene, td->ob); + BKE_object_eval_transform_all(G.main->eval_ctx, t->scene, td->ob); copy_v3_v3(iloc, td->ob->obmat[3]); } |