Merge branch 'master' into blender2.8
authorCampbell Barton <ideasman42@gmail.com>
Tue, 13 Feb 2018 14:06:41 +0000 (01:06 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 13 Feb 2018 14:06:41 +0000 (01:06 +1100)
1  2 
intern/cycles/blender/blender_curves.cpp
source/blender/editors/include/ED_object.h
source/blender/editors/object/object_edit.c
source/blender/editors/render/render_preview.c
source/blender/nodes/shader/nodes/node_shader_tex_environment.c
source/blender/nodes/shader/nodes/node_shader_tex_image.c
tests/python/CMakeLists.txt

index 94ee228f4f841912a0ecf86ae094848cc20dd775,8456c15c79d908ee0bc518736f9192f3968e9084..757a463f171a962dfe85bebbadc45f6c977594a1
@@@ -126,6 -120,7 +126,8 @@@ void ED_object_toggle_modes(struct bCon
  #define EM_WAITCURSOR   4
  #define EM_DO_UNDO      8
  #define EM_IGNORE_LAYER 16
 -void ED_object_editmode_exit_ex(struct bContext *C, struct Scene *scene, struct Object *obedit, int flag);
++void ED_object_editmode_exit_ex(
++        struct bContext *C, struct WorkSpace *workspace, struct Scene *scene, struct Object *obedit, int flag);
  void ED_object_editmode_exit(struct bContext *C, int flag);
  void ED_object_editmode_enter(struct bContext *C, int flag);
  bool ED_object_editmode_load(struct Object *obedit);
index a74af68ca7d899fec3ce74a6f5282d9460304449,dc010ac40ec0fb5b14f3e3a0a1b9ec34b816ba35..03c497bcef08f4f389056795ca4239598d664f56
@@@ -260,21 -441,25 +260,23 @@@ bool ED_object_editmode_load(Object *ob
        return ED_object_editmode_load_ex(G.main, obedit, false);
  }
  
- void ED_object_editmode_exit(bContext *C, int flag)
+ /**
+  * \param C: Can be NULL, only if #EM_DO_UNDO isn't set.
+  * \param flag:
+  * - Only in exceptional cases should #EM_DO_UNDO NOT be in the flag.
+  * - If #EM_FREEDATA isn't in the flag, use ED_object_editmode_load directly.
+  */
 -void ED_object_editmode_exit_ex(bContext *C, Scene *scene, Object *obedit, int flag)
++void ED_object_editmode_exit_ex(bContext *C, WorkSpace *workspace, Scene *scene, Object *obedit, int flag)
  {
-       /* Note! only in exceptional cases should 'EM_DO_UNDO' NOT be in the flag */
-       /* Note! if 'EM_FREEDATA' isn't in the flag, use ED_object_editmode_load directly */
-       WorkSpace *workspace = CTX_wm_workspace(C);
-       Scene *scene = CTX_data_scene(C);
-       Object *obedit = CTX_data_edit_object(C);
+       BLI_assert(C || !(flag & EM_DO_UNDO));
        const bool freedata = (flag & EM_FREEDATA) != 0;
  
        if (flag & EM_WAITCURSOR) waitcursor(1);
  
-       if (ED_object_editmode_load_ex(CTX_data_main(C), obedit, freedata) == false) {
+       if (ED_object_editmode_load_ex(G.main, obedit, freedata) == false) {
                /* in rare cases (background mode) its possible active object
                 * is flagged for editmode, without 'obedit' being set [#35489] */
 -              if (UNLIKELY(scene->basact && (scene->basact->object->mode & OB_MODE_EDIT))) {
 -                      scene->basact->object->mode &= ~OB_MODE_EDIT;
 -              }
 +              workspace->object_mode &= ~OB_MODE_EDIT;
                if (flag & EM_WAITCURSOR) waitcursor(0);
                return;
        }
                if (flag & EM_DO_UNDO)
                        ED_undo_push(C, "Editmode");
  
-               WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_MODE_OBJECT, scene);
+               if (C != NULL) {
+                       WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_MODE_OBJECT, scene);
+               }
+               else {
+                       WM_main_add_notifier(NC_SCENE | ND_MODE | NS_MODE_OBJECT, scene);
+               }
  
 -              obedit->mode &= ~OB_MODE_EDIT;
 +              workspace->object_mode &= ~OB_MODE_EDIT;
        }
  
        if (flag & EM_WAITCURSOR) waitcursor(0);
 +
 +      /* This way we ensure scene's obedit is copied into all CoW scenes.  */
 +      DEG_id_tag_update(&scene->id, 0);
  }
  
 -      ED_object_editmode_exit_ex(C, scene, obedit, flag);
+ void ED_object_editmode_exit(bContext *C, int flag)
+ {
++      WorkSpace *workspace = CTX_wm_workspace(C);
+       Scene *scene = CTX_data_scene(C);
+       Object *obedit = CTX_data_edit_object(C);
++      ED_object_editmode_exit_ex(C, workspace, scene, obedit, flag);
+ }
  
  void ED_object_editmode_enter(bContext *C, int flag)
  {
index 2e3091268a9af6c0356655fbf5a7008b247b484b,e52dd7c65c8e1fbe3e973376f2de723fc64d2d94..c76a6aa175af39a9372c5a58eb63b3980767a47e
@@@ -454,22 -382,26 +454,27 @@@ static Scene *preview_prepare_scene(Mai
                                        }
                                }
                                else {
-                                       if (mat->pr_type == MA_SPHERE_A) {
 +                                      /* use current scene world to light sphere */
 -                                              sce->world = scene->world;
+                                       if (mat->pr_type == MA_SPHERE_A && sp->pr_method == PR_BUTS_RENDER) {
+                                               /* Use current scene world to light sphere. */
 +                                              sce->world = preview_get_localized_world(sp, scene->world);
                                        }
+                                       else if (sce->world) {
+                                               /* Use a default world color. Using the current
+                                                * scene world can be slow if it has big textures. */
+                                               sce->world->use_nodes = false;
+                                               sce->world->horr = 0.5f;
+                                               sce->world->horg = 0.5f;
+                                               sce->world->horb = 0.5f;
+                                       }
                                }
                                
                                if (sp->pr_method == PR_ICON_RENDER) {
                                        if (mat->material_type == MA_TYPE_HALO) {
 -                                              sce->lay = 1 << MA_FLAT;
 +                                              set_preview_layer(view_layer, MA_FLAT);
                                        }
                                        else {
 -                                              sce->lay = 1 << MA_SPHERE_A;
 +                                              set_preview_layer(view_layer, MA_SPHERE_A);
-                                               /* same as above, use current scene world to light sphere */
-                                               if (BKE_scene_use_new_shading_nodes(scene))
-                                                       sce->world = preview_get_localized_world(sp, scene->world);
                                        }
                                }
                                else {
                                }
                        }
                        else {
 +                              set_preview_layer(view_layer, MA_LAMP);
++
+                               if (sce->world) {
+                                       /* Only use lighting from the lamp. */
+                                       sce->world->use_nodes = false;
+                                       sce->world->horr = 0.0f;
+                                       sce->world->horg = 0.0f;
+                                       sce->world->horb = 0.0f;
+                               }
                        }
                                
 -                      for (base = sce->base.first; base; base = base->next) {
 +                      for (Base *base = view_layer->object_bases.first; base; base = base->next) {
                                if (base->object->id.name[2] == 'p') {
                                        if (base->object->type == OB_LAMP)
                                                base->object->data = la;
Simple merge