Fix T62048: crash when turning off curve path animation with Spline IK.
authorAlexander Gavrilov <angavrilov@gmail.com>
Sat, 13 Apr 2019 14:36:57 +0000 (17:36 +0300)
committerAlexander Gavrilov <angavrilov@gmail.com>
Sat, 13 Apr 2019 14:36:57 +0000 (17:36 +0300)
Both fix missing depsgraph flag, and gracefully give up on missing data.

source/blender/blenkernel/intern/armature_update.c
source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc

index 5cd8280..1e9febd 100644 (file)
@@ -71,7 +71,7 @@ typedef struct tSplineIK_Tree {
 /* ----------- */
 
 /* Tag the bones in the chain formed by the given bone for IK */
-static void splineik_init_tree_from_pchan(Scene *scene, Object *UNUSED(ob), bPoseChannel *pchan_tip)
+static void splineik_init_tree_from_pchan(Scene *UNUSED(scene), Object *UNUSED(ob), bPoseChannel *pchan_tip)
 {
        bPoseChannel *pchan, *pchanRoot = NULL;
        bPoseChannel *pchanChain[255];
@@ -102,28 +102,14 @@ static void splineik_init_tree_from_pchan(Scene *scene, Object *UNUSED(ob), bPos
                return;
 
        /* make sure that the constraint targets are ok
-        *     - this is a workaround for a depsgraph bug...
+        *     - this is a workaround for a depsgraph bug or dependency cycle...
         */
        if (ikData->tar) {
-               /* note: when creating constraints that follow path, the curve gets the CU_PATH set now,
-                *       currently for paths to work it needs to go through the bevlist/displist system (ton)
-                */
+               CurveCache *cache = ikData->tar->runtime.curve_cache;
 
-               /* TODO: Make sure this doesn't crash. */
-#if 0
-               /* only happens on reload file, but violates depsgraph still... fix! */
-               if (ELEM(NULL,  ikData->tar->curve_cache, ikData->tar->curve_cache->path, ikData->tar->curve_cache->path->data)) {
-                       BKE_displist_make_curveTypes(depsgraph, scene, ikData->tar, 0);
-
-                       /* path building may fail in EditMode after removing verts [#33268]*/
-                       if (ELEM(NULL, ikData->tar->curve_cache->path, ikData->tar->curve_cache->path->data)) {
-                               /* BLI_assert(cu->path != NULL); */
-                               return;
-                       }
+               if (ELEM(NULL, cache, cache->path, cache->path->data)) {
+                       return;
                }
-#else
-               (void) scene;
-#endif
        }
 
        /* find the root bone and the chain of bones from the root to the tip
index 35652eb..c9f8665 100644 (file)
@@ -262,6 +262,7 @@ void DepsgraphRelationBuilder::build_splineik_pose(Object *object,
        if (data->tar != NULL) {
                ComponentKey target_key(&data->tar->id, NodeType::GEOMETRY);
                add_relation(target_key, init_ik_key, "Curve.Path -> Spline IK");
+               add_special_eval_flag(&data->tar->id, DAG_EVAL_NEED_CURVE_PATH);
        }
        pchan->flag |= POSE_DONE;
        OperationKey final_transforms_key(