Depsgraph: Add utility function to tag pose for recalc
authorSergey Sharybin <sergey.vfx@gmail.com>
Tue, 12 May 2015 08:13:36 +0000 (13:13 +0500)
committerSergey Sharybin <sergey.vfx@gmail.com>
Tue, 12 May 2015 11:06:36 +0000 (16:06 +0500)
Currently this function only tags pose itself, totally matching previous
behavior. But this will be needed in the future once new dependency graph
is landed, because of it's granular nature which relies on the fact that
pose channels are all up to date when building the graph.

Should be no functional changes so far.

source/blender/blenkernel/BKE_action.h
source/blender/blenkernel/intern/action.c
source/blender/blenloader/intern/readfile.c
source/blender/blenloader/intern/versioning_legacy.c
source/blender/editors/armature/pose_edit.c
source/blender/editors/interface/interface_templates.c
source/blender/editors/object/object_add.c
source/blender/editors/object/object_constraint.c
source/blender/makesrna/intern/rna_pose.c

index 6fd490723ab48f237b2d2ee235416dfce4fe1a5a..fdb465f7105159ebc75020c2d152600c6820d593 100644 (file)
@@ -198,6 +198,9 @@ bool BKE_pose_copy_result(struct bPose *to, struct bPose *from);
 /* clear all transforms */
 void BKE_pose_rest(struct bPose *pose);
 
+/* Tag pose for recalc. Also tag all related data to be recalc. */
+void BKE_pose_tag_recalc(struct Main *bmain, struct bPose *pose);
+
 #ifdef __cplusplus
 };
 #endif
index 9ce198bd687be90383fdbd108c5196317f9238dc..708c64f8ffc0d7baaa7f7b12d48991024e8f6090 100644 (file)
@@ -1317,6 +1317,12 @@ bool BKE_pose_copy_result(bPose *to, bPose *from)
        return true;
 }
 
+/* Tag pose for recalc. Also tag all related data to be recalc. */
+void BKE_pose_tag_recalc(Main *UNUSED(bmain), bPose *pose)
+{
+       pose->flag |= POSE_RECALC;
+}
+
 /* For the calculation of the effects of an Action at the given frame on an object 
  * This is currently only used for the Action Constraint 
  */
index a4dd2264816fcc7f1b63a9ae49beb48acc2f744a..6634767d4129e6b66443718a3028d2a00dc0caad 100644 (file)
 
 #include "BLF_translation.h"
 
+#include "BKE_action.h"
 #include "BKE_armature.h"
 #include "BKE_brush.h"
 #include "BKE_cloth.h"
@@ -3009,7 +3010,7 @@ static void lib_link_pose(FileData *fd, Main *bmain, Object *ob, bPose *pose)
        
        if (rebuild) {
                DAG_id_tag_update_ex(bmain, &ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME);
-               pose->flag |= POSE_RECALC;
+               BKE_pose_tag_recalc(bmain, pose);
        }
 }
 
index 94ad348bfcffa7b2a69552ea07f2dda2402301f1..dab22d414d8f220b7f3515b8eb683bf94bb64bdd 100644 (file)
@@ -77,6 +77,7 @@
 #include "BLI_blenlib.h"
 #include "BLI_math.h"
 
+#include "BKE_action.h"
 #include "BKE_armature.h"
 #include "BKE_colortools.h"
 #include "BKE_constraint.h"
@@ -1950,7 +1951,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
                        /* btw. armature_rebuild_pose is further only called on leave editmode */
                        if (ob->type == OB_ARMATURE) {
                                if (ob->pose)
-                                       ob->pose->flag |= POSE_RECALC;
+                                       BKE_pose_tag_recalc(main, ob->pose);
 
                                /* cannot call stuff now (pointers!), done in setup_app_data */
                                ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME;
@@ -2074,7 +2075,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
                                                                data->rootbone = -1;
 
                                                                /* update_pose_etc handles rootbone == -1 */
-                                                               ob->pose->flag |= POSE_RECALC;
+                                                               BKE_pose_tag_recalc(main, ob->pose);
                                                        }
                                                }
                                        }
index bc90031524777a32b77319a58f6a9608220a7475..e87c324d7ec303eeeda5c13bcdd968f3c8210f54 100644 (file)
@@ -436,7 +436,7 @@ static void pose_copy_menu(Scene *scene)
                                                pchan->constflag |= pchanact->constflag;
                                                
                                                if (ob->pose)
-                                                       ob->pose->flag |= POSE_RECALC;
+                                                       BKE_pose_tag_recalc(bmain, ob->pose);
                                        }
                                        break;
                                        case 6: /* Transform Locks */
@@ -550,7 +550,7 @@ static void pose_copy_menu(Scene *scene)
                BKE_pose_update_constraint_flags(ob->pose); /* we could work out the flags but its simpler to do this */
                
                if (ob->pose)
-                       ob->pose->flag |= POSE_RECALC;
+                       BKE_pose_tag_recalc(bmain, ob->pose);
        }
        
        DAG_id_tag_update(&ob->id, OB_RECALC_DATA); // and all its relations
index 9a34e4be98065d1b66209439dd5b2fb6c73ba9a1..ccbd30d12300270dbd349b3692f07bc3f5b0190e 100644 (file)
@@ -1074,7 +1074,8 @@ static void do_constraint_panels(bContext *C, void *ob_pt, int event)
                case B_CONSTRAINT_CHANGETARGET:
                {
                        Main *bmain = CTX_data_main(C);
-                       if (ob->pose) ob->pose->flag |= POSE_RECALC;  /* checks & sorts pose channels */
+                       if (ob->pose)
+                               BKE_pose_tag_recalc(bmain, ob->pose); /* checks & sorts pose channels */
                        DAG_relations_tag_update(bmain);
                        break;
                }
index 27d77f0635e0b92d4c80ee7604494c6c17e4d59f..b8c66fdd1092f53d2fde1acbd1f112ba21064e8b 100644 (file)
@@ -57,6 +57,7 @@
 
 #include "BLF_translation.h"
 
+#include "BKE_action.h"
 #include "BKE_anim.h"
 #include "BKE_animsys.h"
 #include "BKE_armature.h"
@@ -2082,7 +2083,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base
                        case OB_ARMATURE:
                                DAG_id_tag_update(&obn->id, OB_RECALC_DATA);
                                if (obn->pose)
-                                       obn->pose->flag |= POSE_RECALC;
+                                       BKE_pose_tag_recalc(bmain, obn->pose);
                                if (dupflag & USER_DUP_ARM) {
                                        ID_NEW_US2(obn->data)
                                        else {
index f214741467f88571a135e54facd926d46287382c..22db0936e39fe490311495a0ce8ef67cd937ce7a 100644 (file)
@@ -1194,9 +1194,9 @@ void ED_object_constraint_update(Object *ob)
                DAG_id_tag_update(&ob->id, OB_RECALC_OB);
 }
 
-static void object_pose_tag_update(Object *ob)
+static void object_pose_tag_update(Main *bmain, Object *ob)
 {
-       ob->pose->flag |= POSE_RECALC;    /* Checks & sort pose channels. */
+       BKE_pose_tag_recalc(bmain, ob->pose);    /* Checks & sort pose channels. */
        if (ob->proxy && ob->adt) {
                /* We need to make use of ugly POSE_ANIMATION_WORKAROUND here too, else anim data are not reloaded
                 * after calling `BKE_pose_rebuild()`, which causes T43872.
@@ -1212,7 +1212,7 @@ void ED_object_constraint_dependency_update(Main *bmain, Object *ob)
        ED_object_constraint_update(ob);
 
        if (ob->pose) {
-               object_pose_tag_update(ob);
+               object_pose_tag_update(bmain, ob);
        }
        DAG_relations_tag_update(bmain);
 }
@@ -1236,7 +1236,7 @@ void ED_object_constraint_dependency_tag_update(Main *bmain, Object *ob, bConstr
        ED_object_constraint_tag_update(ob, con);
 
        if (ob->pose) {
-               object_pose_tag_update(ob);
+               object_pose_tag_update(bmain, ob);
        }
        DAG_relations_tag_update(bmain);
 }
@@ -1484,8 +1484,8 @@ static int pose_constraint_copy_exec(bContext *C, wmOperator *op)
                        BKE_constraints_copy(&chan->constraints, &pchan->constraints, true);
                        /* update flags (need to add here, not just copy) */
                        chan->constflag |= pchan->constflag;
-                       
-                       ob->pose->flag |= POSE_RECALC;
+
+                       BKE_pose_tag_recalc(bmain, ob->pose);
                        DAG_id_tag_update((ID *)ob, OB_RECALC_DATA);
                }
        }
@@ -1796,7 +1796,7 @@ static int constraint_add_exec(bContext *C, wmOperator *op, Object *ob, ListBase
        DAG_relations_tag_update(bmain);
        
        if ((ob->type == OB_ARMATURE) && (pchan)) {
-               ob->pose->flag |= POSE_RECALC;  /* sort pose channels */
+               BKE_pose_tag_recalc(bmain, ob->pose);  /* sort pose channels */
                if (BKE_constraints_proxylocked_owner(ob, pchan) && ob->adt) {
                        /* We need to make use of ugly POSE_ANIMATION_WORKAROUND here too, else anim data are not reloaded
                         * after calling `BKE_pose_rebuild()`, which causes T43872.
index 0428f5d8a9fc4d6c3053e2d7882de6e912f48db3..3ff51423e9a29b048a0f337988018cd0ac77b6a9 100644 (file)
@@ -231,7 +231,7 @@ static void rna_Pose_ik_solver_update(Main *bmain, Scene *UNUSED(scene), Pointer
        Object *ob = ptr->id.data;
        bPose *pose = ptr->data;
 
-       pose->flag |= POSE_RECALC;  /* checks & sorts pose channels */
+       BKE_pose_tag_recalc(bmain, pose);  /* checks & sorts pose channels */
        DAG_relations_tag_update(bmain);
        
        BKE_pose_update_constraint_flags(pose);
@@ -356,7 +356,7 @@ static void rna_Itasc_update_rebuild(Main *bmain, Scene *scene, PointerRNA *ptr)
        Object *ob = ptr->id.data;
        bPose *pose = ob->pose;
 
-       pose->flag |= POSE_RECALC;  /* checks & sorts pose channels */
+       BKE_pose_tag_recalc(bmain, pose);  /* checks & sorts pose channels */
        rna_Itasc_update(bmain, scene, ptr);
 }