Merge branch 'master' into blender2.8
authorBastien Montagne <montagne29@wanadoo.fr>
Fri, 1 Jun 2018 15:26:36 +0000 (17:26 +0200)
committerBastien Montagne <montagne29@wanadoo.fr>
Fri, 1 Jun 2018 15:26:36 +0000 (17:26 +0200)
 Conflicts:
source/blender/editors/io/io_collada.c
source/blender/editors/object/object_bake.c
source/blender/editors/object/object_edit.c
source/blender/editors/render/render_internal.c
source/blender/makesrna/intern/rna_object_api.c
source/blenderplayer/bad_level_call_stubs/stubs.c

14 files changed:
1  2 
CMakeLists.txt
build_files/cmake/macros.cmake
build_files/cmake/platform/platform_win32.cmake
intern/cycles/blender/blender_mesh.cpp
source/blender/editors/include/ED_object.h
source/blender/editors/io/io_collada.c
source/blender/editors/object/object_bake_api.c
source/blender/editors/object/object_edit.c
source/blender/editors/space_outliner/outliner_select.c
source/blender/editors/space_sequencer/sequencer_add.c
source/blender/editors/space_sequencer/sequencer_edit.c
source/blender/editors/util/ed_util.c
source/blender/makesrna/intern/CMakeLists.txt
source/blender/makesrna/intern/rna_object_api.c

diff --cc CMakeLists.txt
Simple merge
Simple merge
index b3a2f6f7ca657dd033f93705a32cc018ae38668d,75b98caaedb13c9f3f99e9bdd8a135dbf0361012..e3458bcb278846ff5ea09585341ce861d3ecef2d
@@@ -123,15 -116,11 +123,15 @@@ enum 
        EM_FREEDATA         = (1 << 0),
        EM_WAITCURSOR       = (1 << 1),
        EM_IGNORE_LAYER     = (1 << 3),
 +      EM_NO_CONTEXT       = (1 << 4),
  };
 -bool ED_object_editmode_exit_ex(struct Scene *scene, struct Object *obedit, int flag);
 +bool ED_object_editmode_exit_ex(
 +        struct Scene *scene, struct Object *obedit, int flag);
  bool ED_object_editmode_exit(struct bContext *C, int flag);
- bool ED_object_editmode_enter_ex(struct Scene *scene, struct Object *ob, int flag);
 +
++bool ED_object_editmode_enter_ex(struct Main *bmain, struct Scene *scene, struct Object *ob, int flag);
  bool ED_object_editmode_enter(struct bContext *C, int flag);
- bool ED_object_editmode_load(struct Object *obedit);
+ bool ED_object_editmode_load(struct Main *bmain, struct Object *obedit);
  
  bool ED_object_editmode_calc_active_center(struct Object *obedit, const bool select_only, float r_center[3]);
  
index a3cbdb57fed89d605e7b25609b0875b6923d2f18,7e69aa62896b29a49b45a8524e252b84f6102c57..7fe252309dea2a172a22fe0bbc7111abe302a623
@@@ -164,11 -163,13 +164,13 @@@ static int wm_collada_export_exec(bCont
        limit_precision = RNA_boolean_get(op->ptr, "limit_precision");
        keep_bind_info = RNA_boolean_get(op->ptr, "keep_bind_info");
  
+       Main *bmain = CTX_data_main(C);
        /* get editmode results */
-       ED_object_editmode_load(CTX_data_edit_object(C));
+       ED_object_editmode_load(bmain, CTX_data_edit_object(C));
  
 -      EvaluationContext *eval_ctx = bmain->eval_ctx;
        Scene *scene = CTX_data_scene(C);
 +
        ExportSettings export_settings;
  
        export_settings.filepath = filepath;
index 9af8169ae4192ac3e58af69d595d88bac106a902,d24fc96b007d38ad427f766cb05059a50d292d29..6dd6a76f129fc6950d6d49753678d20aef2373ff
@@@ -623,11 -619,11 +623,11 @@@ static size_t initialize_internal_image
  }
  
  /* create new mesh with edit mode changes and modifiers applied */
 -static Mesh *bake_mesh_new_from_object(Main *bmain, Scene *scene, Object *ob)
 +static Mesh *bake_mesh_new_from_object(Depsgraph *depsgraph, Main *bmain, Scene *scene, Object *ob)
  {
-       ED_object_editmode_load(ob);
+       ED_object_editmode_load(bmain, ob);
  
 -      Mesh *me = BKE_mesh_new_from_object(bmain, scene, ob, 1, 2, 0, 0);
 +      Mesh *me = BKE_mesh_new_from_object(depsgraph, bmain, scene, ob, 1, 0, 0);
        if (me->flag & ME_AUTOSMOOTH) {
                BKE_mesh_split_faces(me, true);
        }
index b27e0c9666067c8934aa70033abf196c4bf448ca,d0429fc2bcffaa0d71510037334847502d1d4302..5c7c56f9b182dc4210e7db1c16d517b06a3e33c5
@@@ -147,9 -135,195 +147,9 @@@ Object *ED_object_active_context(bConte
  }
  
  
 -/* ********* clear/set restrict view *********/
 -static int object_hide_view_clear_exec(bContext *C, wmOperator *op)
 -{
 -      Main *bmain = CTX_data_main(C);
 -      ScrArea *sa = CTX_wm_area(C);
 -      View3D *v3d = sa->spacedata.first;
 -      Scene *scene = CTX_data_scene(C);
 -      Base *base;
 -      bool changed = false;
 -      const bool select = RNA_boolean_get(op->ptr, "select");
 -      
 -      /* XXX need a context loop to handle such cases */
 -      for (base = FIRSTBASE; base; base = base->next) {
 -              if ((base->lay & v3d->lay) && base->object->restrictflag & OB_RESTRICT_VIEW) {
 -                      if (!(base->object->restrictflag & OB_RESTRICT_SELECT)) {
 -                              SET_FLAG_FROM_TEST(base->flag, select, SELECT);
 -                      }
 -                      base->object->flag = base->flag;
 -                      base->object->restrictflag &= ~OB_RESTRICT_VIEW; 
 -                      changed = true;
 -              }
 -      }
 -      if (changed) {
 -              DAG_id_type_tag(bmain, ID_OB);
 -              DAG_relations_tag_update(bmain);
 -              WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
 -      }
 -
 -      return OPERATOR_FINISHED;
 -}
 -
 -void OBJECT_OT_hide_view_clear(wmOperatorType *ot)
 -{
 -      
 -      /* identifiers */
 -      ot->name = "Clear Restrict View";
 -      ot->description = "Reveal the object by setting the hide flag";
 -      ot->idname = "OBJECT_OT_hide_view_clear";
 -      
 -      /* api callbacks */
 -      ot->exec = object_hide_view_clear_exec;
 -      ot->poll = ED_operator_view3d_active;
 -      
 -      /* flags */
 -      ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 -
 -      RNA_def_boolean(ot->srna, "select", true, "Select", "");
 -}
 -
 -static int object_hide_view_set_exec(bContext *C, wmOperator *op)
 -{
 -      Main *bmain = CTX_data_main(C);
 -      Scene *scene = CTX_data_scene(C);
 -      bool changed = false;
 -      const bool unselected = RNA_boolean_get(op->ptr, "unselected");
 -      
 -      CTX_DATA_BEGIN(C, Base *, base, visible_bases)
 -      {
 -              if (!unselected) {
 -                      if (base->flag & SELECT) {
 -                              base->flag &= ~SELECT;
 -                              base->object->flag = base->flag;
 -                              base->object->restrictflag |= OB_RESTRICT_VIEW;
 -                              changed = true;
 -                              if (base == BASACT) {
 -                                      ED_base_object_activate(C, NULL);
 -                              }
 -                      }
 -              }
 -              else {
 -                      if (!(base->flag & SELECT)) {
 -                              base->object->restrictflag |= OB_RESTRICT_VIEW;
 -                              changed = true;
 -                              if (base == BASACT) {
 -                                      ED_base_object_activate(C, NULL);
 -                              }
 -                      }
 -              }
 -      }
 -      CTX_DATA_END;
 -
 -      if (changed) {
 -              DAG_id_type_tag(bmain, ID_OB);
 -              DAG_relations_tag_update(bmain);
 -              
 -              WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
 -              
 -      }
 -
 -      return OPERATOR_FINISHED;
 -}
 -
 -void OBJECT_OT_hide_view_set(wmOperatorType *ot)
 -{
 -      /* identifiers */
 -      ot->name = "Set Restrict View";
 -      ot->description = "Hide the object by setting the hide flag";
 -      ot->idname = "OBJECT_OT_hide_view_set";
 -      
 -      /* api callbacks */
 -      ot->exec = object_hide_view_set_exec;
 -      ot->poll = ED_operator_view3d_active;
 -      
 -      /* flags */
 -      ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 -      
 -      RNA_def_boolean(ot->srna, "unselected", 0, "Unselected", "Hide unselected rather than selected objects");
 -      
 -}
 -
 -/* 99% same as above except no need for scene refreshing (TODO, update render preview) */
 -static int object_hide_render_clear_exec(bContext *C, wmOperator *UNUSED(op))
 -{
 -      bool changed = false;
 -
 -      /* XXX need a context loop to handle such cases */
 -      CTX_DATA_BEGIN(C, Object *, ob, selected_editable_objects)
 -      {
 -              if (ob->restrictflag & OB_RESTRICT_RENDER) {
 -                      ob->restrictflag &= ~OB_RESTRICT_RENDER;
 -                      changed = true;
 -              }
 -      }
 -      CTX_DATA_END;
 -
 -      if (changed)
 -              WM_event_add_notifier(C, NC_SPACE | ND_SPACE_OUTLINER, NULL);
 -
 -      return OPERATOR_FINISHED;
 -}
 -
 -void OBJECT_OT_hide_render_clear(wmOperatorType *ot)
 -{
 -
 -      /* identifiers */
 -      ot->name = "Clear Restrict Render";
 -      ot->description = "Reveal the render object by setting the hide render flag";
 -      ot->idname = "OBJECT_OT_hide_render_clear";
 -
 -      /* api callbacks */
 -      ot->exec = object_hide_render_clear_exec;
 -      ot->poll = ED_operator_view3d_active;
 -
 -      /* flags */
 -      ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 -}
 -
 -static int object_hide_render_set_exec(bContext *C, wmOperator *op)
 -{
 -      const bool unselected = RNA_boolean_get(op->ptr, "unselected");
 -
 -      CTX_DATA_BEGIN(C, Base *, base, visible_bases)
 -      {
 -              if (!unselected) {
 -                      if (base->flag & SELECT) {
 -                              base->object->restrictflag |= OB_RESTRICT_RENDER;
 -                      }
 -              }
 -              else {
 -                      if (!(base->flag & SELECT)) {
 -                              base->object->restrictflag |= OB_RESTRICT_RENDER;
 -                      }
 -              }
 -      }
 -      CTX_DATA_END;
 -      WM_event_add_notifier(C, NC_SPACE | ND_SPACE_OUTLINER, NULL);
 -      return OPERATOR_FINISHED;
 -}
 -
 -void OBJECT_OT_hide_render_set(wmOperatorType *ot)
 -{
 -      /* identifiers */
 -      ot->name = "Set Restrict Render";
 -      ot->description = "Hide the render object by setting the hide render flag";
 -      ot->idname = "OBJECT_OT_hide_render_set";
 -
 -      /* api callbacks */
 -      ot->exec = object_hide_render_set_exec;
 -      ot->poll = ED_operator_view3d_active;
 -
 -      /* flags */
 -      ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 -
 -      RNA_def_boolean(ot->srna, "unselected", 0, "Unselected", "Hide unselected rather than selected objects");
 -}
 -
  /* ******************* toggle editmode operator  ***************** */
  
- static bool mesh_needs_keyindex(const Mesh *me)
+ static bool mesh_needs_keyindex(Main *bmain, const Mesh *me)
  {
        if (me->key) {
                return false;  /* will be added */
@@@ -324,11 -500,38 +323,11 @@@ bool ED_object_editmode_exit(bContext *
        return ED_object_editmode_exit_ex(scene, obedit, flag);
  }
  
- bool ED_object_editmode_enter_ex(Scene *scene, Object *ob, int flag)
 -bool ED_object_editmode_enter(bContext *C, int flag)
++bool ED_object_editmode_enter_ex(Main *bmain, Scene *scene, Object *ob, int flag)
  {
 -      Main *bmain = CTX_data_main(C);
 -      Scene *scene = CTX_data_scene(C);
 -      Base *base = NULL;
 -      Object *ob;
 -      ScrArea *sa = CTX_wm_area(C);
 -      View3D *v3d = NULL;
        bool ok = false;
  
 -      if (ID_IS_LINKED(scene)) {
 -              return false;
 -      }
 -
 -      if (sa && sa->spacetype == SPACE_VIEW3D)
 -              v3d = sa->spacedata.first;
 -
 -      if ((flag & EM_IGNORE_LAYER) == 0) {
 -              base = CTX_data_active_base(C); /* active layer checked here for view3d */
 -
 -              if ((base == NULL) ||
 -                  (v3d && (base->lay & v3d->lay) == 0) ||
 -                  (!v3d && (base->lay & scene->lay) == 0))
 -              {
 -                      return false;
 -              }
 -      }
 -      else {
 -              base = scene->basact;
 -      }
 -
 -      if (ELEM(NULL, base, base->object, base->object->data)) {
 +      if (ELEM(NULL, ob, ob->data) || ID_IS_LINKED(ob)) {
                return false;
        }
  
        if (ob->type == OB_MESH) {
                BMEditMesh *em;
                ok = 1;
-               const bool use_key_index = mesh_needs_keyindex(ob->data);
 -              scene->obedit = ob;  /* context sees this */
+               const bool use_key_index = mesh_needs_keyindex(bmain, ob->data);
  
                EDBM_mesh_make(ob, scene->toolsettings->selectmode, use_key_index);
  
        return (ob->mode & OB_MODE_EDIT) != 0;
  }
  
-       return ED_object_editmode_enter_ex(scene, ob, flag);
 +bool ED_object_editmode_enter(bContext *C, int flag)
 +{
++      Main *bmain = CTX_data_main(C);
 +      Scene *scene = CTX_data_scene(C);
 +      ViewLayer *view_layer = CTX_data_view_layer(C);
 +      Object *ob;
 +
 +      if ((flag & EM_IGNORE_LAYER) == 0) {
 +              ob = CTX_data_active_object(C); /* active layer checked here for view3d */
 +      }
 +      else {
 +              ob = view_layer->basact->object;
 +      }
 +      if ((ob == NULL) || ID_IS_LINKED(ob)) {
 +              return false;
 +      }
++      return ED_object_editmode_enter_ex(bmain, scene, ob, flag);
 +}
 +
  static int editmode_toggle_exec(bContext *C, wmOperator *op)
  {
 +      struct wmMsgBus *mbus = CTX_wm_message_bus(C);
        const int mode_flag = OB_MODE_EDIT;
        const bool is_mode_set = (CTX_data_edit_object(C) != NULL);
++      Main *bmain = CTX_data_main(C);
        Scene *scene =  CTX_data_scene(C);
 +      ViewLayer *view_layer = CTX_data_view_layer(C);
 +      Object *obact = OBACT(view_layer);
  
        if (!is_mode_set) {
 -              Object *ob = CTX_data_active_object(C);
 -              if (!ED_object_mode_compat_set(C, ob, mode_flag, op->reports)) {
 +              if (!ED_object_mode_compat_set(C, obact, mode_flag, op->reports)) {
                        return OPERATOR_CANCELLED;
                }
        }
  
        if (!is_mode_set) {
                ED_object_editmode_enter(C, EM_WAITCURSOR);
-                                       ED_object_editmode_enter_ex(scene, ob, EM_WAITCURSOR | EM_NO_CONTEXT);
 +              if (obact->mode & mode_flag) {
 +                      FOREACH_SELECTED_OBJECT_BEGIN(view_layer, ob)
 +                      {
 +                              if ((ob != obact) && (ob->type == obact->type)) {
++                                      ED_object_editmode_enter_ex(bmain, scene, ob, EM_WAITCURSOR | EM_NO_CONTEXT);
 +                              }
 +                      }
 +                      FOREACH_SELECTED_OBJECT_END;
 +              }
        }
        else {
                ED_object_editmode_exit(C, EM_FREEDATA | EM_WAITCURSOR);
index 0e30c43998eb20a0f2ce4e9076759198d298dbe7,9c3b9c7b17996711412532c1524fb20d09cb52d8..5ad107c5d3b925e0acce503a2698d9160d118023
  
  #include "outliner_intern.h"
  
 -/* ****************************************************** */
 -/* Outliner Selection (gray-blue highlight for rows) */
 -
 -static int outliner_select(SpaceOops *soops, ListBase *lb, int *index, short *selecting)
 +static void do_outliner_activate_obdata(bContext *C, Scene *scene, ViewLayer *view_layer, Base *base)
  {
 -      TreeElement *te;
 -      TreeStoreElem *tselem;
 -      bool changed = false;
 -      
 -      for (te = lb->first; te && *index >= 0; te = te->next, (*index)--) {
 -              tselem = TREESTORE(te);
 -              
 -              /* if we've encountered the right item, set its 'Outliner' selection status */
 -              if (*index == 0) {
 -                      /* this should be the last one, so no need to do anything with index */
 -                      if ((te->flag & TE_ICONROW) == 0) {
 -                              /* -1 value means toggle testing for now... */
 -                              if (*selecting == -1) {
 -                                      if (tselem->flag & TSE_SELECTED) 
 -                                              *selecting = 0;
 -                                      else 
 -                                              *selecting = 1;
 -                              }
 -                              
 -                              /* set selection */
 -                              if (*selecting) 
 -                                      tselem->flag |= TSE_SELECTED;
 -                              else 
 -                                      tselem->flag &= ~TSE_SELECTED;
 -
 -                              changed |= true;
 +      Object *obact = OBACT(view_layer);
 +      bool use_all = false;
 +
 +      if (obact == NULL) {
 +              ED_object_base_activate(C, base);
 +              WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
 +              obact = base->object;
 +              use_all = true;
 +      }
 +      else if (obact->data == base->object->data) {
 +              use_all = true;
 +      }
 +
 +      if (use_all) {
 +              WM_operator_name_call(C, "OBJECT_OT_editmode_toggle", WM_OP_INVOKE_REGION_WIN, NULL);
 +      }
 +      else {
 +              Object *ob = base->object;
 +              if (ob->type == obact->type) {
 +                      bool ok;
 +                      if (BKE_object_is_in_editmode(ob)) {
 +                              ok = ED_object_editmode_exit_ex(scene, ob, EM_FREEDATA | EM_WAITCURSOR);
 +                      }
 +                      else {
-                               ok = ED_object_editmode_enter_ex(scene, ob, EM_WAITCURSOR | EM_NO_CONTEXT);
++                              ok = ED_object_editmode_enter_ex(CTX_data_main(C), scene, ob, EM_WAITCURSOR | EM_NO_CONTEXT);
 +                      }
 +                      if (ok) {
 +                              ED_object_base_select(base, (ob->mode & OB_MODE_EDIT) ? BA_SELECT : BA_DESELECT);
 +                              WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
                        }
 -              }
 -              else if (TSELEM_OPEN(tselem, soops)) {
 -                      /* Only try selecting sub-elements if we haven't hit the right element yet
 -                       *
 -                       * Hack warning:
 -                       *  Index must be reduced before supplying it to the sub-tree to try to do
 -                       *  selection, however, we need to increment it again for the next loop to
 -                       *  function correctly
 -                       */
 -                      (*index)--;
 -                      changed |= outliner_select(soops, &te->subtree, index, selecting);
 -                      (*index)++;
                }
        }
 +}
  
 -      return changed;
 +static void do_outliner_activate_pose(bContext *C, ViewLayer *view_layer, Base *base)
 +{
 +      Object *obact = OBACT(view_layer);
 +      bool use_all = false;
 +
 +      if (obact == NULL) {
 +              ED_object_base_activate(C, base);
 +              Scene *scene = CTX_data_scene(C);
 +              WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
 +              obact = base->object;
 +              use_all = true;
 +      }
 +      else if (obact->data == base->object->data) {
 +              use_all = true;
 +      }
 +
 +      if (use_all) {
 +              WM_operator_name_call(C, "OBJECT_OT_posemode_toggle", WM_OP_INVOKE_REGION_WIN, NULL);
 +      }
 +      else {
 +              Object *ob = base->object;
 +              if (ob->type == obact->type) {
 +                      struct Main *bmain = CTX_data_main(C);
 +                      bool ok = false;
 +                      if (ob->mode & OB_MODE_POSE) {
 +                              ok = ED_object_posemode_exit_ex(bmain, ob);
 +                      }
 +                      else {
 +                              ok = ED_object_posemode_enter_ex(bmain, ob);
 +                      }
 +                      if (ok) {
 +                              ED_object_base_select(base, (ob->mode & OB_MODE_POSE) ? BA_SELECT : BA_DESELECT);
 +
 +                              Scene *scene = CTX_data_scene(C);
 +                              WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_MODE_OBJECT, NULL);
 +                              WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
 +                      }
 +              }
 +      }
  }
  
  /* ****************************************************** */
Simple merge
index a01192dad68cba2c79762d416e49c8289515a2a8,7571194b2fd71b1005516b6c87b22471da5ae032..a837a2ff0320710a3a6d5134c6d3ce696be0e5ed
@@@ -445,10 -474,9 +445,10 @@@ void rna_Object_dm_info(struct Object *
  }
  #endif /* NDEBUG */
  
- static int rna_Object_update_from_editmode(Object *ob)
+ static int rna_Object_update_from_editmode(Object *ob, Main *bmain)
  {
-       return ED_object_editmode_load(ob);
 +      /* fail gracefully if we aren't in edit-mode. */
+       return ED_object_editmode_load(bmain, ob);
  }
  #else /* RNA_RUNTIME */