Merge branch 'master' into blender2.8
authorBastien Montagne <montagne29@wanadoo.fr>
Thu, 7 Jun 2018 11:04:16 +0000 (13:04 +0200)
committerBastien Montagne <montagne29@wanadoo.fr>
Thu, 7 Jun 2018 11:04:16 +0000 (13:04 +0200)
 Conflicts:
source/blender/editors/animation/anim_deps.c
source/blender/editors/animation/keyframing.c
source/blender/editors/animation/keyingsets.c
source/blender/editors/armature/pose_edit.c
source/blender/editors/armature/pose_transform.c
source/blender/editors/gpencil/gpencil_convert.c
source/blender/editors/include/ED_anim_api.h
source/blender/editors/include/ED_keyframing.h
source/blender/editors/interface/interface_anim.c
source/blender/editors/space_action/action_edit.c
source/blender/editors/space_graph/graph_edit.c
source/blender/editors/space_outliner/outliner_draw.c
source/blender/editors/transform/transform_conversions.c
source/blender/makesrna/intern/rna_armature.c
source/blender/makesrna/intern/rna_pose.c
source/blender/python/intern/bpy_rna_anim.c
source/blenderplayer/bad_level_call_stubs/stubs.c
source/gameengine/Converter/KX_BlenderSceneConverter.cpp

26 files changed:
1  2 
source/blender/collada/AnimationImporter.cpp
source/blender/collada/DocumentImporter.cpp
source/blender/editors/animation/anim_channels_defines.c
source/blender/editors/animation/anim_deps.c
source/blender/editors/animation/anim_filter.c
source/blender/editors/animation/keyframing.c
source/blender/editors/animation/keyingsets.c
source/blender/editors/armature/armature_naming.c
source/blender/editors/armature/armature_relations.c
source/blender/editors/armature/pose_edit.c
source/blender/editors/armature/pose_lib.c
source/blender/editors/gpencil/gpencil_convert.c
source/blender/editors/include/ED_anim_api.h
source/blender/editors/include/ED_armature.h
source/blender/editors/include/ED_keyframing.h
source/blender/editors/interface/interface_anim.c
source/blender/editors/object/object_constraint.c
source/blender/editors/object/object_relations.c
source/blender/editors/space_action/action_edit.c
source/blender/editors/space_graph/graph_edit.c
source/blender/editors/space_outliner/outliner_draw.c
source/blender/editors/transform/transform_conversions.c
source/blender/editors/transform/transform_generics.c
source/blender/makesrna/intern/rna_armature.c
source/blender/makesrna/intern/rna_pose.c
source/blender/python/intern/bpy_rna_anim.c

  
  #include "BKE_animsys.h"
  #include "BKE_action.h"
 -#include "BKE_depsgraph.h"
+ #include "BKE_context.h"
  #include "BKE_fcurve.h"
  #include "BKE_gpencil.h"
- #include "BKE_context.h"
- #include "BKE_global.h"
+ #include "BKE_main.h"
  #include "BKE_node.h"
  #include "BKE_sequencer.h"
  
  #include "DNA_object_types.h"
  #include "DNA_rigidbody_types.h"
  
- #include "BKE_animsys.h"
  #include "BKE_action.h"
+ #include "BKE_animsys.h"
  #include "BKE_armature.h"
 -#include "BKE_depsgraph.h"
+ #include "BKE_context.h"
  #include "BKE_fcurve.h"
- #include "BKE_idcode.h"
- #include "BKE_nla.h"
  #include "BKE_global.h"
- #include "BKE_context.h"
- #include "BKE_report.h"
+ #include "BKE_idcode.h"
  #include "BKE_key.h"
+ #include "BKE_main.h"
  #include "BKE_material.h"
+ #include "BKE_nla.h"
+ #include "BKE_report.h"
  
 +#include "DEG_depsgraph.h"
 +#include "DEG_depsgraph_build.h"
 +#include "DEG_depsgraph_query.h"
 +
  #include "ED_anim_api.h"
  #include "ED_keyframing.h"
  #include "ED_keyframes_edit.h"
@@@ -158,11 -156,9 +159,11 @@@ bAction *verify_adt_action(Main *bmain
  
                /* tag depsgraph to be rebuilt to include time dependency */
                /* XXX: we probably should have bmain passed down, but that involves altering too many API's */
-               DEG_relations_tag_update(G.main);
 -              DAG_relations_tag_update(bmain);
++              DEG_relations_tag_update(bmain);
        }
  
 +      DEG_id_tag_update(&adt->action->id, DEG_TAG_COPY_ON_WRITE);
 +
        /* return the action */
        return adt->action;
  }
@@@ -1021,7 -1007,9 +1022,9 @@@ bool insert_keyframe_direct(Depsgraph *
   *
   *    index of -1 keys all array indices
   */
- short insert_keyframe(Depsgraph *depsgraph, ReportList *reports, ID *id, bAction *act, const char group[], const char rna_path[], int array_index, float cfra, eBezTriple_KeyframeType keytype, eInsertKeyFlags flag)
+ short insert_keyframe(
 -        Main *bmain, ReportList *reports, ID *id, bAction *act,
++        Main *bmain, Depsgraph *depsgraph, ReportList *reports, ID *id, bAction *act,
+         const char group[], const char rna_path[], int array_index, float cfra, eBezTriple_KeyframeType keytype, eInsertKeyFlags flag)
  {
        PointerRNA id_ptr, ptr;
        PropertyRNA *prop = NULL;
@@@ -1772,7 -1760,7 +1775,8 @@@ void ANIM_OT_keyframe_delete_v3d(wmOper
  
  static int insert_key_button_exec(bContext *C, wmOperator *op)
  {
 +      Depsgraph *depsgraph = CTX_data_depsgraph(C);
+       Main *bmain = CTX_data_main(C);
        Scene *scene = CTX_data_scene(C);
        ToolSettings *ts = scene->toolsettings;
        PointerRNA ptr = {{NULL}};
                                        index = -1;
                                }
  
-                               success = insert_keyframe(depsgraph, op->reports, ptr.id.data, NULL, group, path, index, cfra, ts->keyframe_type, flag);
 -                              success = insert_keyframe(bmain, op->reports, ptr.id.data, NULL, NULL, path, index, cfra, ts->keyframe_type, flag);
++                              success = insert_keyframe(bmain, depsgraph, op->reports, ptr.id.data, NULL, group, path, index, cfra, ts->keyframe_type, flag);
  
                                MEM_freeN(path);
                        }
@@@ -958,7 -957,7 +958,8 @@@ static short keyingset_apply_keying_fla
   */
  int ANIM_apply_keyingset(bContext *C, ListBase *dsources, bAction *act, KeyingSet *ks, short mode, float cfra)
  {
 +      Depsgraph *depsgraph = CTX_data_depsgraph(C);
+       Main *bmain = CTX_data_main(C);
        Scene *scene = CTX_data_scene(C);
        ReportList *reports = CTX_wm_reports(C);
        KS_Path *ksp;
                for (; i < arraylen; i++) {
                        /* action to take depends on mode */
                        if (mode == MODIFYKEY_MODE_INSERT)
-                               success += insert_keyframe(depsgraph, reports, ksp->id, act, groupname, ksp->rna_path, i, cfra, keytype, kflag2);
 -                              success += insert_keyframe(bmain, reports, ksp->id, act, groupname, ksp->rna_path, i, cfra, keytype, kflag2);
++                              success += insert_keyframe(bmain, depsgraph, reports, ksp->id, act, groupname, ksp->rna_path, i, cfra, keytype, kflag2);
                        else if (mode == MODIFYKEY_MODE_DELETE)
                                success += delete_keyframe(reports, ksp->id, act, groupname, ksp->rna_path, i, cfra, kflag2);
                }
@@@ -628,10 -620,10 +628,10 @@@ static int separate_armature_exec(bCont
  
  
        /* 4) fix links before depsgraph flushes */ // err... or after?
-       separated_armature_fix_links(oldob, newob);
+       separated_armature_fix_links(bmain, oldob, newob);
  
 -      DAG_id_tag_update(&oldob->id, OB_RECALC_DATA);  /* this is the original one */
 -      DAG_id_tag_update(&newob->id, OB_RECALC_DATA);  /* this is the separated one */
 +      DEG_id_tag_update(&oldob->id, OB_RECALC_DATA);  /* this is the original one */
 +      DEG_id_tag_update(&newob->id, OB_RECALC_DATA);  /* this is the separated one */
  
  
        /* 5) restore original conditions */
  #include "BKE_armature.h"
  #include "BKE_context.h"
  #include "BKE_deform.h"
 -#include "BKE_depsgraph.h"
+ #include "BKE_main.h"
  #include "BKE_object.h"
  #include "BKE_report.h"
 +#include "BKE_layer.h"
 +
 +#include "DEG_depsgraph.h"
  
  #include "RNA_access.h"
  #include "RNA_define.h"
@@@ -622,31 -605,35 +623,32 @@@ static void pose_copy_menu(Scene *scene
  
  static int pose_flip_names_exec(bContext *C, wmOperator *op)
  {
 -      Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
 -      bArmature *arm;
 -
 -      /* paranoia checks */
 -      if (ELEM(NULL, ob, ob->pose))
 -              return OPERATOR_CANCELLED;
 -
+       Main *bmain = CTX_data_main(C);
 +      ViewLayer *view_layer = CTX_data_view_layer(C);
        const bool do_strip_numbers = RNA_boolean_get(op->ptr, "do_strip_numbers");
  
 -      arm = ob->data;
 -
 -      ListBase bones_names = {NULL};
 -
 -      CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones)
 +      FOREACH_OBJECT_IN_MODE_BEGIN (view_layer, OB_MODE_POSE, ob)
        {
 -              BLI_addtail(&bones_names, BLI_genericNodeN(pchan->name));
 -      }
 -      CTX_DATA_END;
 +              bArmature *arm = ob->data;
 +              ListBase bones_names = {NULL};
  
 -      ED_armature_bones_flip_names(bmain, arm, &bones_names, do_strip_numbers);
 +              FOREACH_PCHAN_SELECTED_IN_OBJECT_BEGIN (ob, pchan)
 +              {
 +                      BLI_addtail(&bones_names, BLI_genericNodeN(pchan->name));
 +              }
 +              FOREACH_PCHAN_SELECTED_IN_OBJECT_END;
  
-               ED_armature_bones_flip_names(arm, &bones_names, do_strip_numbers);
 -      BLI_freelistN(&bones_names);
++              ED_armature_bones_flip_names(bmain, arm, &bones_names, do_strip_numbers);
  
 -      /* since we renamed stuff... */
 -      DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
 +              BLI_freelistN(&bones_names);
  
 -      /* note, notifier might evolve */
 -      WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
 +              /* since we renamed stuff... */
 +              DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
 +
 +              /* note, notifier might evolve */
 +              WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
 +      }
 +      FOREACH_OBJECT_IN_MODE_END;
  
        return OPERATOR_FINISHED;
  }
  #include "BKE_animsys.h"
  #include "BKE_action.h"
  #include "BKE_armature.h"
 -#include "BKE_depsgraph.h"
  #include "BKE_global.h"
  #include "BKE_idprop.h"
+ #include "BKE_main.h"
  #include "BKE_library.h"
  #include "BKE_object.h"
  
@@@ -64,8 -61,9 +64,9 @@@
  #include "BKE_fcurve.h"
  #include "BKE_global.h"
  #include "BKE_gpencil.h"
 +#include "BKE_layer.h"
  #include "BKE_library.h"
+ #include "BKE_main.h"
  #include "BKE_object.h"
  #include "BKE_report.h"
  #include "BKE_scene.h"
@@@ -455,7 -451,7 +456,8 @@@ static void gp_stroke_path_animation_ad
  
  static void gp_stroke_path_animation(bContext *C, ReportList *reports, Curve *cu, tGpTimingData *gtd)
  {
 +      Depsgraph *depsgraph = CTX_data_depsgraph(C);
+       Main *bmain = CTX_data_main(C);
        Scene *scene = CTX_data_scene(C);
        bAction *act;
        FCurve *fcu;
@@@ -81,9 -82,8 +82,10 @@@ typedef struct bAnimContext 
  
        struct bDopeSheet *ads; /* dopesheet data for editor (or which is being used) */
  
 +      struct Depsgraph *depsgraph; /* active dependency graph */
+       struct Main *bmain;     /* Current Main */
        struct Scene *scene;    /* active scene */
 +      struct ViewLayer *view_layer; /* active scene layer */
        struct Object *obact;   /* active object */
        ListBase *markers;      /* active set of markers */
  
@@@ -117,7 -115,9 +117,9 @@@ bool insert_keyframe_direct(struct Deps
   *    Use this to create any necessary animation data, and then insert a keyframe
   *    using the current value being keyframed, in the relevant place. Returns success.
   */
- short insert_keyframe(struct Depsgraph *depsgraph, struct ReportList *reports, struct ID *id, struct bAction *act, const char group[], const char rna_path[], int array_index, float cfra, eBezTriple_KeyframeType keytype, eInsertKeyFlags flag);
+ short insert_keyframe(
 -        struct Main *bmain, struct ReportList *reports, struct ID *id, struct bAction *act,
++        struct Main *bmain, struct Depsgraph *depsgraph, struct ReportList *reports, struct ID *id, struct bAction *act,
+         const char group[], const char rna_path[], int array_index, float cfra, eBezTriple_KeyframeType keytype, eInsertKeyFlags flag);
  
  /* Main Keyframing API call:
   *  Use this to delete keyframe on current frame for relevant channel. Will perform checks just in case.
  #include "BLI_utildefines.h"
  
  #include "BKE_context.h"
 -#include "BKE_depsgraph.h"
  #include "BKE_fcurve.h"
  #include "BKE_global.h"
+ #include "BKE_main.h"
  #include "BKE_nla.h"
  
 +#include "DEG_depsgraph.h"
 +#include "DEG_depsgraph_build.h"
 +
  #include "ED_keyframing.h"
  
  #include "UI_interface.h"
@@@ -277,8 -274,7 +279,8 @@@ void ui_but_anim_autokey(bContext *C, u
                         *       because a button may control all items of an array at once.
                         *       E.g., color wheels (see T42567). */
                        BLI_assert((fcu->array_index == but->rnaindex) || (but->rnaindex == -1));
-                       insert_keyframe(depsgraph, reports, id, action,
 -                      insert_keyframe(bmain, reports, id, action, ((fcu->grp) ? (fcu->grp->name) : (NULL)),
++                      insert_keyframe(bmain, depsgraph, reports, id, action,
 +                                      ((fcu->grp) ? (fcu->grp->name) : (NULL)),
                                        fcu->rna_path, but->rnaindex, cfra, ts->keyframe_type, flag);
  
                        WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
@@@ -718,7 -708,8 +719,8 @@@ static void insert_action_keys(bAnimCon
                 *                       (TODO: add the full-blown PointerRNA relative parsing case here...)
                 */
                if (ale->id && !ale->owner) {
-                       insert_keyframe(depsgraph, reports, ale->id, NULL, ((fcu->grp) ? (fcu->grp->name) : (NULL)), fcu->rna_path, fcu->array_index, cfra, ts->keyframe_type, flag);
 -                      insert_keyframe(ac->bmain, reports, ale->id, NULL, ((fcu->grp) ? (fcu->grp->name) : (NULL)),
++                      insert_keyframe(ac->bmain, depsgraph, reports, ale->id, NULL, ((fcu->grp) ? (fcu->grp->name) : (NULL)),
+                                       fcu->rna_path, fcu->array_index, cfra, ts->keyframe_type, flag);
                }
                else {
                        const float curval = evaluate_fcurve(fcu, cfra);
  
  #include "BLT_translation.h"
  
 -#include "BKE_depsgraph.h"
+ #include "BKE_context.h"
  #include "BKE_fcurve.h"
  #include "BKE_global.h"
+ #include "BKE_main.h"
  #include "BKE_nla.h"
- #include "BKE_context.h"
  #include "BKE_report.h"
  
 +#include "DEG_depsgraph_build.h"
 +
  #include "UI_view2d.h"
  
  #include "ED_anim_api.h"
@@@ -609,7 -608,8 +610,8 @@@ static void insert_graph_keys(bAnimCont
                         *                        up adding the keyframes on a new F-Curve in the action data instead.
                         */
                        if (ale->id && !ale->owner && !fcu->driver) {
-                               insert_keyframe(depsgraph, reports, ale->id, NULL, ((fcu->grp) ? (fcu->grp->name) : (NULL)), fcu->rna_path, fcu->array_index, cfra, ts->keyframe_type, flag);
 -                              insert_keyframe(ac->bmain, reports, ale->id, NULL, ((fcu->grp) ? (fcu->grp->name) : (NULL)),
++                              insert_keyframe(ac->bmain, depsgraph, reports, ale->id, NULL, ((fcu->grp) ? (fcu->grp->name) : (NULL)),
+                                               fcu->rna_path, fcu->array_index, cfra, ts->keyframe_type, flag);
                        }
                        else {
                                const float curval = evaluate_fcurve(fcu, cfra);
@@@ -340,8 -527,8 +340,8 @@@ static void namebutton_cb(bContext *C, 
                                                /* restore bone name */
                                                BLI_strncpy(newname, ebone->name, sizeof(ebone->name));
                                                BLI_strncpy(ebone->name, oldname, sizeof(ebone->name));
-                                               ED_armature_bone_rename(obedit->data, oldname, newname);
+                                               ED_armature_bone_rename(bmain, obedit->data, oldname, newname);
 -                                              WM_event_add_notifier(C, NC_OBJECT | ND_POSE, OBACT);
 +                                              WM_event_add_notifier(C, NC_OBJECT | ND_POSE, NULL);
                                        }
                                        break;
                                }
                                        /* restore bone name */
                                        BLI_strncpy(newname, bone->name, sizeof(bone->name));
                                        BLI_strncpy(bone->name, oldname, sizeof(bone->name));
-                                       ED_armature_bone_rename(arm, oldname, newname);
 -                                      ED_armature_bone_rename(bmain, ob->data, oldname, newname);
 -                                      WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
++                                      ED_armature_bone_rename(bmain, arm, oldname, newname);
 +                                      WM_event_add_notifier(C, NC_OBJECT | ND_POSE, NULL);
                                        break;
                                }
                                case TSE_POSE_CHANNEL:
                                        /* restore bone name */
                                        BLI_strncpy(newname, pchan->name, sizeof(pchan->name));
                                        BLI_strncpy(pchan->name, oldname, sizeof(pchan->name));
-                                       ED_armature_bone_rename(ob->data, oldname, newname);
+                                       ED_armature_bone_rename(bmain, ob->data, oldname, newname);
 -                                      WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
 +                                      WM_event_add_notifier(C, NC_OBJECT | ND_POSE, NULL);
                                        break;
                                }
                                case TSE_POSEGRP:
@@@ -5921,8 -5780,9 +5921,9 @@@ static void clear_trans_object_base_fla
   *  tmode: should be a transform mode
   */
  // NOTE: context may not always be available, so must check before using it as it's a luxury for a few cases
 -void autokeyframe_ob_cb_func(bContext *C, Scene *scene, View3D *v3d, Object *ob, int tmode)
 +void autokeyframe_ob_cb_func(bContext *C, Scene *scene, ViewLayer *view_layer, Object *ob, int tmode)
  {
+       Main *bmain = CTX_data_main(C);
        ID *id = &ob->id;
        FCurve *fcu;
  
                        if (adt && adt->action) {
                                for (fcu = adt->action->curves.first; fcu; fcu = fcu->next) {
                                        fcu->flag &= ~FCURVE_SELECTED;
-                                       insert_keyframe(depsgraph, reports, id, adt->action,
 -                                      insert_keyframe(bmain, reports, id, adt->action,
++                                      insert_keyframe(bmain, depsgraph, reports, id, adt->action,
                                                        (fcu->grp ? fcu->grp->name : NULL),
                                                        fcu->rna_path, fcu->array_index, cfra,
                                                        ts->keyframe_type, flag);
   *    targetless_ik: has targetless ik been done on any channels?
   */
  // NOTE: context may not always be available, so must check before using it as it's a luxury for a few cases
 -void autokeyframe_pose_cb_func(bContext *C, Scene *scene, View3D *v3d, Object *ob, int tmode, short targetless_ik)
 +void autokeyframe_pose_cb_func(bContext *C, Scene *scene, Object *ob, int tmode, short targetless_ik)
  {
+       Main *bmain = CTX_data_main(C);
        ID *id = &ob->id;
        AnimData *adt = ob->adt;
        bAction *act = (adt) ? adt->action : NULL;
                                                                 * NOTE: this will do constraints too, but those are ok to do here too?
                                                                 */
                                                                if (pchanName && STREQ(pchanName, pchan->name)) {
-                                                                       insert_keyframe(depsgraph, reports, id, act,
 -                                                                      insert_keyframe(bmain, reports, id, act,
++                                                                      insert_keyframe(bmain, depsgraph, reports, id, act,
                                                                                        ((fcu->grp) ? (fcu->grp->name) : (NULL)),
                                                                                        fcu->rna_path, fcu->array_index, cfra,
                                                                                        ts->keyframe_type, flag);
@@@ -386,7 -374,7 +386,7 @@@ static void recalcData_actedit(TransInf
                if ((saction->flag & SACTION_NOREALTIMEUPDATES) == 0) {
                        for (ale = anim_data.first; ale; ale = ale->next) {
                                /* set refresh tags for objects using this animation */
-                               ANIM_list_elem_update(t->scene, ale);
 -                              ANIM_list_elem_update(CTX_data_main(t->context), scene, ale);
++                              ANIM_list_elem_update(CTX_data_main(t->context), t->scene, ale);
                        }
                }
  
@@@ -44,6 -44,8 +44,7 @@@
  #ifdef RNA_RUNTIME
  
  #include "BKE_context.h"
 -#include "BKE_depsgraph.h"
+ #include "BKE_global.h"
  #include "BKE_idprop.h"
  #include "BKE_main.h"
  
@@@ -106,11 -106,10 +106,12 @@@ const EnumPropertyItem rna_enum_color_s
  
  #include "BKE_context.h"
  #include "BKE_constraint.h"
 -#include "BKE_depsgraph.h"
+ #include "BKE_global.h"
  #include "BKE_idprop.h"
  
 +#include "DEG_depsgraph.h"
 +#include "DEG_depsgraph_build.h"
 +
  #include "ED_object.h"
  #include "ED_armature.h"
  
@@@ -272,7 -271,7 +273,7 @@@ PyObject *pyrna_struct_keyframe_insert(
  
                BKE_reports_init(&reports, RPT_STORE);
  
-               result = insert_keyframe(depsgraph, &reports, (ID *)self->ptr.id.data, NULL, group_name, path_full, index, cfra, keytype, options);
 -              result = insert_keyframe(G.main, &reports, (ID *)self->ptr.id.data, NULL, group_name, path_full, index, cfra, keytype, options);
++              result = insert_keyframe(G.main, depsgraph, &reports, (ID *)self->ptr.id.data, NULL, group_name, path_full, index, cfra, keytype, options);
                MEM_freeN((void *)path_full);
  
                if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1)