Fix T52835: When driven IK influence change, ik animation have 1 frame delay
authorSergey Sharybin <sergey.vfx@gmail.com>
Mon, 25 Sep 2017 13:48:38 +0000 (18:48 +0500)
committerSergey Sharybin <sergey.vfx@gmail.com>
Mon, 25 Sep 2017 13:48:55 +0000 (18:48 +0500)
source/blender/blenkernel/BKE_armature.h
source/blender/blenkernel/intern/armature_update.c
source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc
source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc
source/blender/depsgraph/intern/depsgraph_type_defines.cc
source/blender/depsgraph/intern/depsgraph_types.h

index 1cc42f788d55b0c5cc3e7dc7d604f65362e396c5..60fb79d75d58ef98e2e0b6ef5d43e5da518ad7e3 100644 (file)
@@ -172,6 +172,11 @@ void BKE_pose_eval_init(struct EvaluationContext *eval_ctx,
                         struct Object *ob,
                         struct bPose *pose);
 
+void BKE_pose_eval_init_ik(struct EvaluationContext *eval_ctx,
+                           struct Scene *scene,
+                           struct Object *ob,
+                           struct bPose *pose);
+
 void BKE_pose_eval_bone(struct EvaluationContext *eval_ctx,
                         struct Scene *scene,
                         struct Object *ob,
index a4714041edff5622bf3c56598b673b215a9cce2d..45d1d36aeca495f8e15142b4f0404aea9e58dbbc 100644 (file)
@@ -559,11 +559,10 @@ void BKE_splineik_execute_tree(Scene *scene, Object *ob, bPoseChannel *pchan_roo
 /* *************** Depsgraph evaluation callbacks ************ */
 
 void BKE_pose_eval_init(EvaluationContext *UNUSED(eval_ctx),
-                        Scene *scene,
+                        Scene *UNUSED(scene),
                         Object *ob,
                         bPose *pose)
 {
-       float ctime = BKE_scene_frame_get(scene); /* not accurate... */
        bPoseChannel *pchan;
 
        DEBUG_PRINT("%s on %s\n", __func__, ob->id.name);
@@ -581,6 +580,16 @@ void BKE_pose_eval_init(EvaluationContext *UNUSED(eval_ctx),
        for (pchan = pose->chanbase.first; pchan != NULL; pchan = pchan->next) {
                pchan->flag &= ~(POSE_DONE | POSE_CHAIN | POSE_IKTREE | POSE_IKSPLINE);
        }
+}
+
+void BKE_pose_eval_init_ik(EvaluationContext *UNUSED(eval_ctx),
+                           Scene *scene,
+                           Object *ob,
+                           bPose *UNUSED(pose))
+{
+       float ctime = BKE_scene_frame_get(scene); /* not accurate... */
+
+       DEBUG_PRINT("%s on %s\n", __func__, ob->id.name);
 
        /* 2a. construct the IK tree (standard IK) */
        BIK_initialize_tree(scene, ob, ctime);
index fe7ccaa7fc02ae837b1c7eb5fea52366b05d1a3f..ceb2fd25f94128cca394377fb4ff63eb25434ec9 100644 (file)
@@ -180,6 +180,11 @@ void DepsgraphNodeBuilder::build_rig(Scene *scene, Object *ob)
                                     DEG_OPCODE_POSE_INIT);
        op_node->set_as_entry();
 
+       op_node = add_operation_node(&ob->id,
+                                    DEG_NODE_TYPE_EVAL_POSE,
+                                    function_bind(BKE_pose_eval_init_ik, _1, scene, ob, ob->pose),
+                                    DEG_OPCODE_POSE_INIT_IK);
+
        op_node = add_operation_node(&ob->id,
                                     DEG_NODE_TYPE_EVAL_POSE,
                                     function_bind(BKE_pose_eval_flush, _1, scene, ob, ob->pose),
index be666165a0bf3b8aeccbc72762db2d9547cb8ce8..ca548ed33d0e6741715d06e34cbd92802445be54 100644 (file)
@@ -83,7 +83,15 @@ void DepsgraphRelationBuilder::build_ik_pose(Object *ob,
         * - see notes on direction of rel below...
         */
        bPoseChannel *rootchan = BKE_armature_ik_solver_find_root(pchan, data);
-       OperationKey solver_key(&ob->id, DEG_NODE_TYPE_EVAL_POSE, rootchan->name, DEG_OPCODE_POSE_IK_SOLVER);
+       OperationKey pchan_local_key(&ob->id, DEG_NODE_TYPE_BONE,
+                                    pchan->name, DEG_OPCODE_BONE_LOCAL);
+       OperationKey init_ik_key(&ob->id, DEG_NODE_TYPE_EVAL_POSE, DEG_OPCODE_POSE_INIT_IK);
+       OperationKey solver_key(&ob->id, DEG_NODE_TYPE_EVAL_POSE,
+                               rootchan->name,
+                               DEG_OPCODE_POSE_IK_SOLVER);
+
+       add_relation(pchan_local_key, init_ik_key, "IK Constraint -> Init IK Tree");
+       add_relation(init_ik_key, solver_key, "Init IK -> IK Solver");
 
        /* IK target */
        // XXX: this should get handled as part of the constraint code
@@ -300,9 +308,11 @@ void DepsgraphRelationBuilder::build_rig(Scene *scene, Object *ob)
 
        /* attach links between pose operations */
        OperationKey init_key(&ob->id, DEG_NODE_TYPE_EVAL_POSE, DEG_OPCODE_POSE_INIT);
+       OperationKey init_ik_key(&ob->id, DEG_NODE_TYPE_EVAL_POSE, DEG_OPCODE_POSE_INIT_IK);
        OperationKey flush_key(&ob->id, DEG_NODE_TYPE_EVAL_POSE, DEG_OPCODE_POSE_DONE);
 
-       add_relation(init_key, flush_key, "[Pose Init -> Pose Cleanup]");
+       add_relation(init_key, init_ik_key, "Pose Init -> Pose Init IK");
+       add_relation(init_ik_key, flush_key, "Pose Init IK -> Pose Cleanup");
 
        /* Make sure pose is up-to-date with armature updates. */
        OperationKey armature_key(&arm->id,
index f4f071cd611b70c58f35a79abe61b19ef9583713..e177c8c8ec06d871f0c55689e87f577b81fc7ab0 100644 (file)
@@ -109,6 +109,7 @@ static const char *stringify_opcode(eDepsOperation_Code opcode)
                STRINGIFY_OPCODE(OBJECT_UBEREVAL);
                STRINGIFY_OPCODE(GEOMETRY_UBEREVAL);
                STRINGIFY_OPCODE(POSE_INIT);
+               STRINGIFY_OPCODE(POSE_INIT_IK);
                STRINGIFY_OPCODE(POSE_DONE);
                STRINGIFY_OPCODE(POSE_IK_SOLVER);
                STRINGIFY_OPCODE(POSE_SPLINE_IK_SOLVER);
index 1c461423e035b4af4f3ec1fb79cd60ed419f3a62..ef7b32a8d8338321a3b1fe027dbcf8a6a6423a44 100644 (file)
@@ -178,9 +178,12 @@ typedef enum eDepsOperation_Code {
 
        /* Pose -------------------------------------------- */
 
-       /* Init IK Trees, etc. */
+       /* Init pose, clear flags, etc. */
        DEG_OPCODE_POSE_INIT,
 
+       /* Initialize IK solver related pose stuff. */
+       DEG_OPCODE_POSE_INIT_IK,
+
        /* Free IK Trees + Compute Deform Matrices */
        DEG_OPCODE_POSE_DONE,