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!
This commit is contained in:
Sergey Sharybin 2017-11-29 15:29:39 +01:00
parent c8b1a83a8c
commit 60703e45f3
3 changed files with 22 additions and 5 deletions

View File

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

View File

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

View File

@ -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]);
}