Merge branch 'master' into blender2.8
[blender.git] / source / blender / nodes / texture / node_texture_tree.c
index abaaf33..551d955 100644 (file)
 #include "NOD_texture.h"
 #include "node_texture_util.h"
 
+#include "DEG_depsgraph.h"
+
 #include "RNA_access.h"
 
 #include "RE_shader_ext.h"
 
-
-static void texture_get_from_context(const bContext *C, bNodeTreeType *UNUSED(treetype), bNodeTree **r_ntree, ID **r_id, ID **r_from)
+static void texture_get_from_context(
+        const bContext *C, bNodeTreeType *UNUSED(treetype), bNodeTree **r_ntree, ID **r_id, ID **r_from)
 {
        SpaceNode *snode = CTX_wm_space_node(C);
        Scene *scene = CTX_data_scene(C);
-       Object *ob = OBACT;
+       ViewLayer *view_layer = CTX_data_view_layer(C);
+       Object *ob = OBACT(view_layer);
        Tex *tx = NULL;
 
-       if (snode->texfrom == SNODE_TEX_OBJECT) {
-               if (ob) {
-                       tx = give_current_object_texture(ob);
-                       if (tx) {
-                               if (ob->type == OB_LAMP)
-                                       *r_from = (ID *)ob->data;
-                               else
-                                       *r_from = (ID *)give_current_material(ob, ob->actcol);
-
-                               /* from is not set fully for material nodes, should be ID + Node then */
-                               *r_id = &tx->id;
-                               *r_ntree = tx->nodetree;
-                       }
-               }
-       }
-       else if (snode->texfrom == SNODE_TEX_WORLD) {
-               if (scene->world) {
-                       *r_from = (ID *)scene->world;
-                       tx = give_current_world_texture(scene->world);
-                       if (tx) {
-                               *r_id = &tx->id;
-                               *r_ntree = tx->nodetree;
-                       }
-               }
-       }
-       else if (snode->texfrom == SNODE_TEX_BRUSH) {
+       if (snode->texfrom == SNODE_TEX_BRUSH) {
                struct Brush *brush = NULL;
 
                if (ob && (ob->mode & OB_MODE_SCULPT))
@@ -108,7 +86,7 @@ static void texture_get_from_context(const bContext *C, bNodeTreeType *UNUSED(tr
                }
        }
        else if (snode->texfrom == SNODE_TEX_LINESTYLE) {
-               FreestyleLineStyle *linestyle = BKE_linestyle_active_from_scene(scene);
+               FreestyleLineStyle *linestyle = BKE_linestyle_active_from_view_layer(view_layer);
                if (linestyle) {
                        *r_from = (ID *)linestyle;
                        tx = give_current_linestyle_texture(linestyle);
@@ -186,7 +164,7 @@ void register_node_tree_type_tex(void)
 
        tt->type = NTREE_TEXTURE;
        strcpy(tt->idname, "TextureNodeTree");
-       strcpy(tt->ui_name, "Texture");
+       strcpy(tt->ui_name, "Texture Editor");
        tt->ui_icon = 0;    /* defined in drawnode.c */
        strcpy(tt->ui_description, "Texture nodes");
 
@@ -321,7 +299,6 @@ int ntreeTexExecTree(
         short which_output,
         int cfra,
         int preview,
-        ShadeInput *shi,
         MTex *mtex)
 {
        TexCallData data;
@@ -336,12 +313,11 @@ int ntreeTexExecTree(
        data.osatex = osatex;
        data.target = texres;
        data.do_preview = preview;
-       data.do_manage = (shi) ? shi->do_manage : true;
+       data.do_manage = true;
        data.thread = thread;
        data.which_output = which_output;
        data.cfra = cfra;
        data.mtex = mtex;
-       data.shi = shi;
 
        /* ensure execdata is only initialized once */
        if (!exec) {