Merge branch 'master' into blender2.8
authorBastien Montagne <montagne29@wanadoo.fr>
Mon, 14 Aug 2017 15:07:30 +0000 (17:07 +0200)
committerBastien Montagne <montagne29@wanadoo.fr>
Mon, 14 Aug 2017 15:07:30 +0000 (17:07 +0200)
1  2 
release/scripts/startup/bl_operators/clip.py
source/blender/blenkernel/intern/library.c
source/blender/blenkernel/intern/node.c

index d0e551597333f88e91b520fe7e14975030a50809,f63b0495d021ee67674c5563c3d123d82c5f223a..ea68641f68b09eddf8d3cd0f27a73c148820c50a
@@@ -210,7 -210,7 +210,7 @@@ class CLIP_OT_set_active_clip(bpy.types
      @classmethod
      def poll(cls, context):
          space = context.space_data
-         return space.type == 'CLIP_EDITOR'
+         return space.type == 'CLIP_EDITOR' and space.clip
  
      def execute(self, context):
          clip = context.space_data.clip
@@@ -235,7 -235,7 +235,7 @@@ class CLIP_OT_track_to_empty(Operator)
          ob = None
  
          ob = bpy.data.objects.new(name=track.name, object_data=None)
 -        ob.select = True
 +        ob.select_set(action='SELECT')
          context.scene.objects.link(ob)
          context.scene.objects.active = ob
  
          constraint.object = tracking_object.name
          constraint.camera = CLIP_camera_for_clip(context, clip)
  
+     @classmethod
+     def poll(cls, context):
+         space = context.space_data
+         return space.type == 'CLIP_EDITOR' and space.clip
      def execute(self, context):
          sc = context.space_data
          clip = sc.clip
@@@ -509,7 -514,7 +514,7 @@@ object's movement caused by this constr
          # XXX, should probably use context.selected_editable_objects
          # since selected objects can be from a lib or in hidden layer!
          for ob in scene.objects:
 -            if ob.select:
 +            if ob.select_set(action='SELECT'):
                  self._bake_object(scene, ob)
  
          return {'FINISHED'}
index 15a0f1191f8c9fdaa002def80778a79fe2ba9216,d5dfc63b3179d7295511d384cd1207d755563b22..71fbb3d726acca80c0ecdfb12f62c198774b2aba
@@@ -62,7 -62,6 +62,7 @@@
  #include "DNA_mask_types.h"
  #include "DNA_node_types.h"
  #include "DNA_object_types.h"
 +#include "DNA_lightprobe_types.h"
  #include "DNA_scene_types.h"
  #include "DNA_screen_types.h"
  #include "DNA_speaker_types.h"
@@@ -71,7 -70,6 +71,7 @@@
  #include "DNA_vfont_types.h"
  #include "DNA_windowmanager_types.h"
  #include "DNA_world_types.h"
 +#include "DNA_workspace_types.h"
  
  #include "BLI_blenlib.h"
  #include "BLI_utildefines.h"
@@@ -93,6 -91,7 +93,6 @@@
  #include "BKE_cachefile.h"
  #include "BKE_context.h"
  #include "BKE_curve.h"
 -#include "BKE_depsgraph.h"
  #include "BKE_font.h"
  #include "BKE_global.h"
  #include "BKE_group.h"
  #include "BKE_paint.h"
  #include "BKE_particle.h"
  #include "BKE_packedFile.h"
 +#include "BKE_lightprobe.h"
  #include "BKE_sound.h"
  #include "BKE_speaker.h"
  #include "BKE_scene.h"
@@@ -420,9 -418,6 +420,9 @@@ bool id_make_local(Main *bmain, ID *id
                case ID_SPK:
                        if (!test) BKE_speaker_make_local(bmain, (Speaker *)id, lib_local);
                        return true;
 +              case ID_LP:
 +                      if (!test) BKE_lightprobe_make_local(bmain, (LightProbe *)id, lib_local);
 +                      return true;
                case ID_WO:
                        if (!test) BKE_world_make_local(bmain, (World *)id, lib_local);
                        return true;
                case ID_CF:
                        if (!test) BKE_cachefile_make_local(bmain, (CacheFile *)id, lib_local);
                        return true;
 +              case ID_WS:
                case ID_SCR:
 +                      /* A bit special: can be appended but not linked. Return false
 +                       * since supporting make-local doesn't make much sense. */
 +                      return false;
                case ID_LI:
                case ID_KE:
                case ID_WM:
  
  struct IDCopyLibManagementData {
        const ID *id_src;
+       ID *id_dst;
        int flag;
  };
  
  /* Increases usercount as required, and remap self ID pointers. */
- static int id_copy_libmanagement_cb(void *user_data, ID *id_self, ID **id_pointer, int cb_flag)
+ static int id_copy_libmanagement_cb(void *user_data, ID *UNUSED(id_self), ID **id_pointer, int cb_flag)
  {
        struct IDCopyLibManagementData *data = user_data;
        ID *id = *id_pointer;
  
        /* Remap self-references to new copied ID. */
        if (id == data->id_src) {
-               id = *id_pointer = id_self;
+               /* We cannot use id_self here, it is not *always* id_dst (thanks to $£!+@#&/? nodetrees). */
+               id = *id_pointer = data->id_dst;
        }
  
        /* Increase used IDs refcount if needed and required. */
@@@ -586,9 -579,6 +588,9 @@@ bool BKE_id_copy_ex(Main *bmain, const 
                case ID_SPK:
                        BKE_speaker_copy_data(bmain, (Speaker *)*r_newid, (Speaker *)id, flag);
                        break;
 +              case ID_LP:
 +                      BKE_lightprobe_copy_data(bmain, (LightProbe *)*r_newid, (LightProbe *)id, flag);
 +                      break;
                case ID_CA:
                        BKE_camera_copy_data(bmain, (Camera *)*r_newid, (Camera *)id, flag);
                        break;
                case ID_LI:
                case ID_SCR:
                case ID_WM:
 +              case ID_WS:
                case ID_IP:
                        BLI_assert(0);  /* Should have been rejected at start of function! */
                        break;
        }
  
        /* Update ID refcount, remap pointers to self in new ID. */
-       struct IDCopyLibManagementData data = {.id_src = id, .flag = flag};
+       struct IDCopyLibManagementData data = {.id_src = id, .id_dst = *r_newid, .flag = flag};
        BKE_library_foreach_ID_link(bmain, *r_newid, id_copy_libmanagement_cb, &data, IDWALK_NOP);
  
        /* Do not make new copy local in case we are copying outside of main...
@@@ -842,8 -831,6 +844,8 @@@ ListBase *which_libbase(Main *mainlib, 
                        return &(mainlib->text);
                case ID_SPK:
                        return &(mainlib->speaker);
 +              case ID_LP:
 +                      return &(mainlib->lightprobe);
                case ID_SO:
                        return &(mainlib->sound);
                case ID_GR:
                        return &(mainlib->paintcurves);
                case ID_CF:
                        return &(mainlib->cachefiles);
 +              case ID_WS:
 +                      return &(mainlib->workspaces);
        }
        return NULL;
  }
@@@ -961,11 -946,11 +963,11 @@@ void BKE_main_lib_objects_recalc_all(Ma
        /* flag for full recalc */
        for (ob = bmain->object.first; ob; ob = ob->id.next) {
                if (ID_IS_LINKED_DATABLOCK(ob)) {
 -                      DAG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME);
 +                      DEG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME);
                }
        }
  
 -      DAG_id_type_tag(bmain, ID_OB);
 +      DEG_id_type_tag(bmain, ID_OB);
  }
  
  /**
@@@ -1014,7 -999,6 +1016,7 @@@ int set_listbasepointers(Main *main, Li
        lb[INDEX_ID_BR]  = &(main->brush);
        lb[INDEX_ID_PA]  = &(main->particle);
        lb[INDEX_ID_SPK] = &(main->speaker);
 +      lb[INDEX_ID_LP]  = &(main->lightprobe);
  
        lb[INDEX_ID_WO]  = &(main->world);
        lb[INDEX_ID_MC]  = &(main->movieclip);
        lb[INDEX_ID_OB]  = &(main->object);
        lb[INDEX_ID_LS]  = &(main->linestyle); /* referenced by scenes */
        lb[INDEX_ID_SCE] = &(main->scene);
 +      lb[INDEX_ID_WS]  = &(main->workspaces); /* before wm, so it's freed after it! */
        lb[INDEX_ID_WM]  = &(main->wm);
        lb[INDEX_ID_MSK] = &(main->mask);
        
@@@ -1075,7 -1058,6 +1077,7 @@@ size_t BKE_libblock_get_alloc_info(shor
                CASE_RETURN(ID_VF,  VFont);
                CASE_RETURN(ID_TXT, Text);
                CASE_RETURN(ID_SPK, Speaker);
 +              CASE_RETURN(ID_LP,  LightProbe);
                CASE_RETURN(ID_SO,  bSound);
                CASE_RETURN(ID_GR,  Group);
                CASE_RETURN(ID_AR,  bArmature);
                CASE_RETURN(ID_PAL, Palette);
                CASE_RETURN(ID_PC,  PaintCurve);
                CASE_RETURN(ID_CF,  CacheFile);
 +              CASE_RETURN(ID_WS,  WorkSpace);
        }
        return 0;
  #undef CASE_RETURN
@@@ -1148,7 -1129,7 +1150,7 @@@ void *BKE_libblock_alloc(Main *bmain, s
  
                        /* TODO to be removed from here! */
                        if ((flag & LIB_ID_CREATE_NO_DEG_TAG) == 0) {
 -                              DAG_id_type_tag(bmain, type);
 +                              DEG_id_type_tag(bmain, type);
                        }
                }
                else {
@@@ -1207,9 -1188,6 +1209,9 @@@ void BKE_libblock_init_empty(ID *id
                case ID_SPK:
                        BKE_speaker_init((Speaker *)id);
                        break;
 +              case ID_LP:
 +                      BKE_lightprobe_init((LightProbe *)id);
 +                      break;
                case ID_CA:
                        BKE_camera_init((Camera *)id);
                        break;
@@@ -1334,7 -1312,7 +1336,7 @@@ void BKE_libblock_copy_ex(Main *bmain, 
        id_copy_animdata(bmain, new_id, (flag & LIB_ID_COPY_ACTIONS) != 0 && (flag & LIB_ID_CREATE_NO_MAIN) == 0);
  
        if ((flag & LIB_ID_CREATE_NO_DEG_TAG) == 0 && (flag & LIB_ID_CREATE_NO_MAIN) == 0) {
 -              DAG_id_type_tag(bmain, GS(new_id->name));
 +              DEG_id_type_tag(bmain, GS(new_id->name));
        }
  
        *r_newid = new_id;
index d33b1ce7d06c73946e931fc24c8a58e9fc914349,3836d154a7b3c04d1aa3a50c2f45e4ff89cc45ad..346d107792e536207e174aac87252f2bfb4fd589
@@@ -1221,17 -1221,12 +1221,12 @@@ bNodeTree *ntreeAddTree(Main *bmain, co
   */
  void BKE_node_tree_copy_data(Main *UNUSED(bmain), bNodeTree *ntree_dst, const bNodeTree *ntree_src, const int flag)
  {
-       bNode *node_src;
        bNodeSocket *sock_dst, *sock_src;
        bNodeLink *link_dst;
  
        /* We never handle usercount here for own data. */
        const int flag_subdata = flag | LIB_ID_CREATE_NO_USER_REFCOUNT;
  
-       if ((flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0) {
-               id_us_plus((ID *)ntree_dst->gpd);
-       }
        /* in case a running nodetree is copied */
        ntree_dst->execdata = NULL;
  
        BLI_listbase_clear(&ntree_dst->nodes);
        BLI_listbase_clear(&ntree_dst->links);
  
-       for (node_src = ntree_src->nodes.first; node_src; node_src = node_src->next) {
+       for (bNode *node_src = ntree_src->nodes.first; node_src; node_src = node_src->next) {
                BKE_node_copy_ex(ntree_dst, node_src, flag_subdata);
        }
  
        }
  
        /* update node->parent pointers */
-       for (node_src = ntree_dst->nodes.first; node_src; node_src = node_src->next) {
-               if (node_src->parent) {
-                       node_src->parent = node_src->parent->new_node;
+       for (bNode *node_dst = ntree_dst->nodes.first, *node_src = ntree_src->nodes.first; node_dst; node_dst = node_dst->next, node_src = node_src->next) {
+               if (node_dst->parent) {
+                       node_dst->parent = node_dst->parent->new_node;
                }
        }
  
@@@ -2028,7 -2023,7 +2023,7 @@@ bNodeTree *ntreeLocalize(bNodeTree *ntr
  
                for (node = ntree->nodes.first; node; node = node->next) {
                        /* store new_node pointer to original */
 -                      node->new_node->new_node = node;
 +                      node->new_node->original = node;
                }
  
                if (ntree->typeinfo->localize)
@@@ -3599,12 -3594,9 +3594,12 @@@ static void registerShaderNodes(void
        register_node_type_sh_add_shader();
        register_node_type_sh_uvmap();
        register_node_type_sh_uvalongstroke();
 +      register_node_type_sh_eevee_metallic();
 +      register_node_type_sh_eevee_specular();
  
        register_node_type_sh_output_lamp();
        register_node_type_sh_output_material();
 +      register_node_type_sh_output_eevee_material();
        register_node_type_sh_output_world();
        register_node_type_sh_output_linestyle();
  
@@@ -3794,20 -3786,3 +3789,20 @@@ bool BKE_node_tree_iter_step(struct Nod
  
        return true;
  }
 +
 +/* -------------------------------------------------------------------- */
 +/* NodeTree kernel functions */
 +
 +void BKE_nodetree_remove_layer_n(bNodeTree *ntree, Scene *scene, const int layer_index)
 +{
 +      for (bNode *node = ntree->nodes.first; node; node = node->next) {
 +              if (node->type == CMP_NODE_R_LAYERS && (Scene *)node->id == scene) {
 +                      if (node->custom1 == layer_index) {
 +                              node->custom1 = 0;
 +                      }
 +                      else if (node->custom1 > layer_index) {
 +                              node->custom1--;
 +                      }
 +              }
 +      }
 +}