Transform: Avoid use of ob->recalc in snapping code
authorSergey Sharybin <sergey.vfx@gmail.com>
Wed, 29 Nov 2017 14:29:39 +0000 (15:29 +0100)
committerSergey Sharybin <sergey.vfx@gmail.com>
Wed, 29 Nov 2017 14:37:09 +0000 (15:37 +0100)
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!

source/blender/blenkernel/BKE_object.h
source/blender/blenkernel/intern/object_update.c
source/blender/editors/transform/transform_snap.c

index d1a4033957b8a70f7d441d124a7cc61307995c5d..2772b3e2e6b4ea0100648ddaf0120af5a9f262f2 100644 (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);
index 17721a8077f93fbebdd155b3e4cac65a33ebbdea..fd2b5ff589f3786a18cef8a91a0fb1d673ee3e7c 100644 (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);
+}
index 45b8ca3749f0e0b9c30a3c258f92c0bc105d0181..5750224de3d361322c52eae80b60f3245d69b451 100644 (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]);
                }