Merge branch 'master' into blender2.8
authorSergey Sharybin <sergey.vfx@gmail.com>
Wed, 4 Apr 2018 07:54:50 +0000 (09:54 +0200)
committerSergey Sharybin <sergey.vfx@gmail.com>
Wed, 4 Apr 2018 07:54:50 +0000 (09:54 +0200)
1  2 
source/blender/blenkernel/BKE_armature.h
source/blender/blenkernel/intern/armature_update.c
source/blender/blenloader/intern/readfile.c
source/blender/depsgraph/intern/builder/deg_builder_nodes.h
source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc
source/blender/makesdna/DNA_action_types.h

index 192690c074c3c7879d16a885288f4a3b927a6534,f6de39c897e14fa5cf50401effd97186eb3d170a..bf37224c85fb6930dc22b478503637bda74c5eef
@@@ -165,49 -165,45 +165,47 @@@ struct bPoseChannel *BKE_armature_splin
          struct bSplineIKConstraint *data);
  
  void BKE_pose_splineik_init_tree(struct Scene *scene, struct Object *ob, float ctime);
 -void BKE_splineik_execute_tree(struct Scene *scene, struct Object *ob, struct bPoseChannel *pchan_root, float ctime);
 +void BKE_splineik_execute_tree(
 +        const struct EvaluationContext *eval_ctx, struct Scene *scene,
 +        struct Object *ob, struct bPoseChannel *pchan_root, float ctime);
  
 -void BKE_pose_eval_init(struct EvaluationContext *eval_ctx,
 +void BKE_pose_eval_init(const struct EvaluationContext *eval_ctx,
                          struct Scene *scene,
-                         struct Object *ob,
-                         struct bPose *pose);
+                         struct Object *ob);
  
 -void BKE_pose_eval_init_ik(struct EvaluationContext *eval_ctx,
 +void BKE_pose_eval_init_ik(const struct EvaluationContext *eval_ctx,
                             struct Scene *scene,
-                            struct Object *ob,
-                            struct bPose *pose);
+                            struct Object *ob);
  
 -void BKE_pose_eval_bone(struct EvaluationContext *eval_ctx,
 +void BKE_pose_eval_bone(const struct EvaluationContext *eval_ctx,
                          struct Scene *scene,
                          struct Object *ob,
-                         struct bPoseChannel *pchan);
+                         int pchan_index);
  
 -void BKE_pose_constraints_evaluate(struct EvaluationContext *eval_ctx,
 +void BKE_pose_constraints_evaluate(const struct EvaluationContext *eval_ctx,
                                     struct Scene *scene,
                                     struct Object *ob,
-                                    struct bPoseChannel *pchan);
+                                    int pchan_index);
  
 -void BKE_pose_bone_done(struct EvaluationContext *eval_ctx,
 +void BKE_pose_bone_done(const struct EvaluationContext *eval_ctx,
-                         struct bPoseChannel *pchan);
+                         struct Object *ob,
+                         int pchan_index);
  
 -void BKE_pose_iktree_evaluate(struct EvaluationContext *eval_ctx,
 +void BKE_pose_iktree_evaluate(const struct EvaluationContext *eval_ctx,
                                struct Scene *scene,
                                struct Object *ob,
-                               struct bPoseChannel *rootchan);
+                               int rootchan_index);
  
 -void BKE_pose_splineik_evaluate(struct EvaluationContext *eval_ctx,
 +void BKE_pose_splineik_evaluate(const struct EvaluationContext *eval_ctx,
                                  struct Scene *scene,
                                  struct Object *ob,
-                                 struct bPoseChannel *rootchan);
+                                 int rootchan_index);
  
 -void BKE_pose_eval_flush(struct EvaluationContext *eval_ctx,
 +void BKE_pose_eval_flush(const struct EvaluationContext *eval_ctx,
                           struct Scene *scene,
-                          struct Object *ob,
-                          struct bPose *pose);
+                          struct Object *ob);
  
 -void BKE_pose_eval_proxy_copy(struct EvaluationContext *eval_ctx,
 +void BKE_pose_eval_proxy_copy(const struct EvaluationContext *eval_ctx,
                                struct Object *ob);
  
  #ifdef __cplusplus
index 8058dbef5772a47aa8d5266e700ba14d56f35363,95a26814e372745bdc9f6d9948a40609d754f4cc..54f1a353486a3a6a8505a327817e039ef728ce66
@@@ -558,12 -551,12 +558,12 @@@ void BKE_splineik_execute_tree
  
  /* *************** Depsgraph evaluation callbacks ************ */
  
 -void BKE_pose_eval_init(EvaluationContext *UNUSED(eval_ctx),
 +void BKE_pose_eval_init(const struct EvaluationContext *UNUSED(eval_ctx),
                          Scene *UNUSED(scene),
-                         Object *ob,
-                         bPose *pose)
+                         Object *ob)
  {
-       bPoseChannel *pchan;
+       bPose *pose = ob->pose;
+       BLI_assert(pose != NULL);
  
        DEG_debug_print_eval(__func__, ob->id.name, ob);
  
        }
  }
  
 -void BKE_pose_eval_init_ik(EvaluationContext *UNUSED(eval_ctx),
 +void BKE_pose_eval_init_ik(const struct EvaluationContext *eval_ctx,
                             Scene *scene,
-                            Object *ob,
-                            bPose *UNUSED(pose))
+                            Object *ob)
  {
        DEG_debug_print_eval(__func__, ob->id.name, ob);
        BLI_assert(ob->type == OB_ARMATURE);
        if (arm->flag & ARM_RESTPOS) {
                return;
        }
-       /* 2a. construct the IK tree (standard IK) */
+       /* construct the IK tree (standard IK) */
 -      BIK_initialize_tree(scene, ob, ctime);
 +      BIK_initialize_tree(eval_ctx, scene, ob, ctime);
-       /* 2b. construct the Spline IK trees
+       /* construct the Spline IK trees
         *  - this is not integrated as an IK plugin, since it should be able
-        *        to function in conjunction with standard IK
+        *    to function in conjunction with standard IK
         */
        BKE_pose_splineik_init_tree(scene, ob, ctime);
  }
  
 -void BKE_pose_eval_bone(EvaluationContext *UNUSED(eval_ctx),
 +void BKE_pose_eval_bone(const struct EvaluationContext *eval_ctx,
                          Scene *scene,
                          Object *ob,
-                         bPoseChannel *pchan)
+                         int pchan_index)
  {
+       BLI_assert(ob->pose != NULL);
+       bPoseChannel *pchan = ob->pose->chan_array[pchan_index];
        DEG_debug_print_eval_subdata(
                __func__, ob->id.name, ob, "pchan", pchan->name, pchan);
        BLI_assert(ob->type == OB_ARMATURE);
        }
  }
  
 -void BKE_pose_constraints_evaluate(EvaluationContext *UNUSED(eval_ctx),
 +void BKE_pose_constraints_evaluate(const struct EvaluationContext *eval_ctx,
                                     Scene *scene,
                                     Object *ob,
-                                    bPoseChannel *pchan)
+                                    int pchan_index)
  {
+       BLI_assert(ob->pose != NULL);
+       bPoseChannel *pchan = ob->pose->chan_array[pchan_index];
        DEG_debug_print_eval_subdata(
                __func__, ob->id.name, ob, "pchan", pchan->name, pchan);
        bArmature *arm = (bArmature *)ob->data;
        }
  }
  
 -void BKE_pose_bone_done(EvaluationContext *UNUSED(eval_ctx),
 +void BKE_pose_bone_done(const struct EvaluationContext *UNUSED(eval_ctx),
-                         bPoseChannel *pchan)
+                         struct Object *ob,
+                         int pchan_index)
  {
+       BLI_assert(ob->pose != NULL);
+       bPoseChannel *pchan = ob->pose->chan_array[pchan_index];
        float imat[4][4];
        DEG_debug_print_eval(__func__, pchan->name, pchan);
        if (pchan->bone) {
        }
  }
  
 -void BKE_pose_iktree_evaluate(EvaluationContext *UNUSED(eval_ctx),
 +void BKE_pose_iktree_evaluate(const struct EvaluationContext *eval_ctx,
                                Scene *scene,
                                Object *ob,
-                               bPoseChannel *rootchan)
+                               int rootchan_index)
  {
+       BLI_assert(ob->pose != NULL);
+       bPoseChannel *rootchan = ob->pose->chan_array[rootchan_index];
        DEG_debug_print_eval_subdata(
                __func__, ob->id.name, ob, "rootchan", rootchan->name, rootchan);
        BLI_assert(ob->type == OB_ARMATURE);
        if (arm->flag & ARM_RESTPOS) {
                return;
        }
 -      BIK_execute_tree(scene, ob, rootchan, ctime);
 +      BIK_execute_tree(eval_ctx, scene, ob, rootchan, ctime);
  }
  
 -void BKE_pose_splineik_evaluate(EvaluationContext *UNUSED(eval_ctx),
 +void BKE_pose_splineik_evaluate(const struct EvaluationContext *eval_ctx,
                                  Scene *scene,
                                  Object *ob,
-                                 bPoseChannel *rootchan)
+                                 int rootchan_index)
  
  {
+       BLI_assert(ob->pose != NULL);
+       bPoseChannel *rootchan = ob->pose->chan_array[rootchan_index];
        DEG_debug_print_eval_subdata(
                __func__, ob->id.name, ob, "rootchan", rootchan->name, rootchan);
        BLI_assert(ob->type == OB_ARMATURE);
        if (arm->flag & ARM_RESTPOS) {
                return;
        }
 -      BKE_splineik_execute_tree(scene, ob, rootchan, ctime);
 +      BKE_splineik_execute_tree(eval_ctx, scene, ob, rootchan, ctime);
  }
  
 -void BKE_pose_eval_flush(EvaluationContext *UNUSED(eval_ctx),
 +void BKE_pose_eval_flush(const struct EvaluationContext *UNUSED(eval_ctx),
                           Scene *scene,
-                          Object *ob,
-                          bPose *UNUSED(pose))
+                          Object *ob)
  {
+       bPose *pose = ob->pose;
+       BLI_assert(pose != NULL);
        float ctime = BKE_scene_frame_get(scene); /* not accurate... */
        DEG_debug_print_eval(__func__, ob->id.name, ob);
        BLI_assert(ob->type == OB_ARMATURE);
  
-       /* 6. release the IK tree */
+       /* release the IK tree */
        BIK_release_tree(scene, ob, ctime);
 -      ob->recalc &= ~OB_RECALC_ALL;
 -
+       BLI_assert(pose->chan_array != NULL);
+       MEM_freeN(pose->chan_array);
+       pose->chan_array = NULL;
  }
  
 -void BKE_pose_eval_proxy_copy(EvaluationContext *UNUSED(eval_ctx), Object *ob)
 +void BKE_pose_eval_proxy_copy(const struct EvaluationContext *UNUSED(eval_ctx), Object *ob)
  {
        BLI_assert(ID_IS_LINKED(ob) && ob->proxy_from != NULL);
        DEG_debug_print_eval(__func__, ob->id.name, ob);
index 49cccb60843939151887aa6f4f008a0c27a0ec56,17d2a4ad5583514d17f4a99ec4050247d5fde3c6..8dfbc4fa37ca04a0ead0a18687b07f0cd328a63e
@@@ -180,10 -132,9 +180,10 @@@ struct DepsgraphNodeBuilder 
        void build_object_data(Object *object);
        void build_object_transform(Object *object);
        void build_object_constraints(Object *object);
-       void build_pose_constraints(Object *object, bPoseChannel *pchan);
+       void build_pose_constraints(Object *object, bPoseChannel *pchan, int pchan_index);
        void build_rigidbody(Scene *scene);
        void build_particles(Object *object);
 +      void build_particle_settings(ParticleSettings *part);
        void build_cloth(Object *object);
        void build_animdata(ID *id);
        void build_driver(ID *id, FCurve *fcurve);
index aabcbd1c6d4c0009d7f7b0af23ac16c97e89fd89,0c7c3d13d9390bb49cfcc42da6697ceee07524da..328d23a2ced8ca2959cda45877df8dd461a70d61
@@@ -73,9 -72,9 +74,9 @@@ void DepsgraphNodeBuilder::build_pose_c
        add_operation_node(&object->id, DEG_NODE_TYPE_BONE, pchan->name,
                           function_bind(BKE_pose_constraints_evaluate,
                                         _1,
 -                                       scene_,
 -                                       object,
 +                                       get_cow_datablock(scene_),
 +                                       get_cow_datablock(object),
-                                        pchan),
+                                        pchan_index),
                           DEG_OPCODE_BONE_CONSTRAINTS);
  }
  
@@@ -102,9 -102,9 +104,9 @@@ void DepsgraphNodeBuilder::build_ik_pos
        add_operation_node(&object->id, DEG_NODE_TYPE_EVAL_POSE, rootchan->name,
                           function_bind(BKE_pose_iktree_evaluate,
                                         _1,
 -                                       scene_,
 -                                       object,
 +                                       get_cow_datablock(scene_),
 +                                       get_cow_datablock(object),
-                                        rootchan),
+                                        rootchan_index),
                           DEG_OPCODE_POSE_IK_SOLVER);
  }
  
@@@ -119,15 -119,15 +121,16 @@@ void DepsgraphNodeBuilder::build_spline
        bPoseChannel *rootchan = BKE_armature_splineik_solver_find_root(pchan, data);
  
        /* Operation node for evaluating/running Spline IK Solver.
 -       * Store the "root bone" of this chain in the solver, so it knows where to start.
 +       * Store the "root bone" of this chain in the solver, so it knows where to
 +       * start.
         */
+       int rootchan_index = BLI_findindex(&object->pose->chanbase, rootchan);
        add_operation_node(&object->id, DEG_NODE_TYPE_EVAL_POSE, rootchan->name,
                           function_bind(BKE_pose_splineik_evaluate,
                                         _1,
 -                                       scene_,
 -                                       object,
 +                                       get_cow_datablock(scene_),
 +                                       get_cow_datablock(object),
-                                        rootchan),
+                                        rootchan_index),
                           DEG_OPCODE_POSE_SPLINE_IK_SOLVER);
  }
  
@@@ -219,9 -200,8 +222,8 @@@ void DepsgraphNodeBuilder::build_rig(Ob
                                     DEG_NODE_TYPE_EVAL_POSE,
                                     function_bind(BKE_pose_eval_init,
                                                   _1,
 -                                                 scene_,
 -                                                 object),
 +                                                 scene_cow,
-                                                  object_cow,
-                                                  object_cow->pose),
++                                                 object_cow),
                                     DEG_OPCODE_POSE_INIT);
        op_node->set_as_entry();
  
                                     DEG_NODE_TYPE_EVAL_POSE,
                                     function_bind(BKE_pose_eval_init_ik,
                                                   _1,
 -                                                 scene_,
 -                                                 object),
 +                                                 scene_cow,
-                                                  object_cow,
-                                                  object_cow->pose),
++                                                 object_cow),
                                     DEG_OPCODE_POSE_INIT_IK);
  
        op_node = add_operation_node(&object->id,
                                     DEG_NODE_TYPE_EVAL_POSE,
                                     function_bind(BKE_pose_eval_flush,
                                                   _1,
 -                                                 scene_,
 -                                                 object),
 +                                                 scene_cow,
-                                                  object_cow,
-                                                  object_cow->pose),
++                                                 object_cow),
                                     DEG_OPCODE_POSE_DONE);
        op_node->set_as_exit();
  
        /* bones */
 -      LISTBASE_FOREACH (bPoseChannel *, pchan, &object->pose->chanbase) {
+       int pchan_index = 0;
 +      LISTBASE_FOREACH (bPoseChannel *, pchan, &object_cow->pose->chanbase) {
                /* Node for bone evaluation. */
                op_node = add_operation_node(&object->id, DEG_NODE_TYPE_BONE, pchan->name, NULL,
                                             DEG_OPCODE_BONE_LOCAL);
                op_node->set_as_entry();
  
                add_operation_node(&object->id, DEG_NODE_TYPE_BONE, pchan->name,
 -                                 function_bind(BKE_pose_eval_bone, _1, scene_, object, pchan_index),
 +                                 function_bind(BKE_pose_eval_bone, _1,
 +                                               scene_cow,
 +                                               object_cow,
-                                                pchan),
++                                               pchan_index),
                                   DEG_OPCODE_BONE_POSE_PARENT);
  
 +              /* NOTE: Dedicated noop for easier relationship construction. */
                add_operation_node(&object->id, DEG_NODE_TYPE_BONE, pchan->name,
 -                                 NULL, /* NOTE: dedicated noop for easier relationship construction */
 +                                 NULL,
                                   DEG_OPCODE_BONE_READY);
  
                op_node = add_operation_node(&object->id, DEG_NODE_TYPE_BONE, pchan->name,
                                           DEG_OPCODE_PARAMETERS_EVAL,
                                           pchan->name);
                }
 -              /* Constraints. */
 +              /* Build constraints. */
                if (pchan->constraints.first != NULL) {
-                       build_pose_constraints(object, pchan);
+                       build_pose_constraints(object, pchan, pchan_index);
                }
                /**
                 * IK Solvers.
                                        break;
                        }
                }
 +              /* Custom shape. */
 +              /* NOTE: Custom shape datablock is already remapped to CoW version. */
 +              if (pchan->custom != NULL) {
 +                      build_object(NULL,
 +                                   get_orig_datablock(pchan->custom),
 +                                   DEG_ID_LINKED_INDIRECTLY);
 +              }
++
+               pchan_index++;
        }
  }