Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2010-01-29 19:32:06 +0300
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2010-01-29 19:32:06 +0300
commit812e5140b0b0a8e1569ceac3fac1852274ea3a2c (patch)
treef21c7a1c0ea8bac569516aee277c610e2dcf2fcd
parente803c033088a4b17b9a0f142851801e26f3395ba (diff)
Fix #20549: selecting a texture node in a material node tree would
keep that texture locked as the current visible texture in the texture buttons.
-rw-r--r--release/scripts/ui/properties_texture.py10
-rw-r--r--source/blender/blenkernel/BKE_texture.h3
-rw-r--r--source/blender/blenkernel/intern/texture.c14
-rw-r--r--source/blender/editors/space_buttons/buttons_context.c24
-rw-r--r--source/blender/editors/space_node/node_edit.c6
-rw-r--r--source/blender/editors/space_node/node_select.c2
6 files changed, 46 insertions, 13 deletions
diff --git a/release/scripts/ui/properties_texture.py b/release/scripts/ui/properties_texture.py
index 3631fb40784..5f742ddcfb9 100644
--- a/release/scripts/ui/properties_texture.py
+++ b/release/scripts/ui/properties_texture.py
@@ -87,14 +87,13 @@ class TEXTURE_PT_context_texture(TextureButtonsPanel):
def draw(self, context):
layout = self.layout
-
+ slot = context.texture_slot
+ node = context.texture_node
space = context.space_data
tex = context.texture
wide_ui = context.region.width > narrowui
idblock = context_tex_datablock(context)
- tex_collection = space.pin_id == None and type(idblock) != bpy.types.Brush
-
-
+ tex_collection = space.pin_id == None and type(idblock) != bpy.types.Brush and not node
if tex_collection:
row = layout.row()
@@ -113,6 +112,8 @@ class TEXTURE_PT_context_texture(TextureButtonsPanel):
if tex_collection:
col.template_ID(idblock, "active_texture", new="texture.new")
+ elif node:
+ col.template_ID(node, "texture", new="texture.new")
elif idblock:
col.template_ID(idblock, "texture", new="texture.new")
@@ -129,7 +130,6 @@ class TEXTURE_PT_context_texture(TextureButtonsPanel):
split = layout.split(percentage=0.2)
if tex.use_nodes:
- slot = context.texture_slot
if slot:
split.label(text="Output:")
diff --git a/source/blender/blenkernel/BKE_texture.h b/source/blender/blenkernel/BKE_texture.h
index 95ada45f5d8..735a4e1dd71 100644
--- a/source/blender/blenkernel/BKE_texture.h
+++ b/source/blender/blenkernel/BKE_texture.h
@@ -31,6 +31,7 @@
#ifndef BKE_TEXTURE_H
#define BKE_TEXTURE_H
+struct bNode;
struct Brush;
struct ColorBand;
struct EnvMap;
@@ -75,6 +76,8 @@ struct Tex *give_current_lamp_texture(struct Lamp *la);
struct Tex *give_current_world_texture(struct World *world);
struct Tex *give_current_brush_texture(struct Brush *br);
+struct bNode *give_current_material_texture_node(struct Material *ma);
+
int give_active_mtex(struct ID *id, struct MTex ***mtex_ar, short *act);
void set_active_mtex(struct ID *id, short act);
diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c
index c60001db314..634d9e6ce0d 100644
--- a/source/blender/blenkernel/intern/texture.c
+++ b/source/blender/blenkernel/intern/texture.c
@@ -858,6 +858,16 @@ void set_current_lamp_texture(Lamp *la, Tex *newtex)
}
}
+bNode *give_current_material_texture_node(Material *ma)
+{
+ bNode *node;
+
+ if(ma && ma->use_nodes && ma->nodetree)
+ return nodeGetActiveID(ma->nodetree, ID_TE);
+
+ return NULL;
+}
+
Tex *give_current_material_texture(Material *ma)
{
MTex *mtex= NULL;
@@ -865,6 +875,9 @@ Tex *give_current_material_texture(Material *ma)
bNode *node;
if(ma && ma->use_nodes && ma->nodetree) {
+ /* first check texture, then material, this works together
+ with a hack that clears the active ID flag for textures on
+ making a material node active */
node= nodeGetActiveID(ma->nodetree, ID_TE);
if(node) {
@@ -877,6 +890,7 @@ Tex *give_current_material_texture(Material *ma)
ma= (Material*)node->id;
}
}
+
if(ma) {
mtex= ma->mtex[(int)(ma->texact)];
if(mtex) tex= mtex->tex;
diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c
index 5fe738d7250..fcfd8b907eb 100644
--- a/source/blender/editors/space_buttons/buttons_context.c
+++ b/source/blender/editors/space_buttons/buttons_context.c
@@ -35,6 +35,7 @@
#include "DNA_lamp_types.h"
#include "DNA_material_types.h"
#include "DNA_modifier_types.h"
+#include "DNA_node_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
@@ -399,7 +400,6 @@ static int buttons_context_path_texture(const bContext *C, ButsContextPath *path
return 1;
}
}
- /* TODO: material nodes */
/* no path to a texture possible */
return 0;
@@ -648,13 +648,29 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r
return 1;
}
+ else if(CTX_data_equals(member, "texture_node")) {
+ PointerRNA *ptr;
+
+ if((ptr=get_pointer_type(path, &RNA_Material))) {
+ Material *ma= ptr->data;
+
+ if(ma) {
+ bNode *node= give_current_material_texture_node(ma);
+ CTX_data_pointer_set(result, &ma->id, &RNA_Node, node);
+ }
+ }
+
+ return 1;
+ }
else if(CTX_data_equals(member, "texture_slot")) {
PointerRNA *ptr;
if((ptr=get_pointer_type(path, &RNA_Material))) {
- Material *ma= ptr->data; /* should this be made a different option? */
- Material *ma_node= give_node_material(ma);
- ma= ma_node?ma_node:ma;
+ Material *ma= ptr->data;
+
+ /* if we have a node material, get slot from material in material node */
+ if(ma && ma->use_nodes && ma->nodetree)
+ ma= give_node_material(ma);
if(ma)
CTX_data_pointer_set(result, &ma->id, &RNA_MaterialTextureSlot, ma->mtex[(int)ma->texact]);
diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c
index f77eeec9cc8..89fb40367e8 100644
--- a/source/blender/editors/space_node/node_edit.c
+++ b/source/blender/editors/space_node/node_edit.c
@@ -433,12 +433,12 @@ void node_set_active(SpaceNode *snode, bNode *node)
if(node->type!=NODE_GROUP) {
/* tree specific activate calls */
if(snode->treetype==NTREE_SHADER) {
- // XXX
-#if 0
-
/* when we select a material, active texture is cleared, for buttons */
if(node->id && GS(node->id->name)==ID_MA)
nodeClearActiveID(snode->edittree, ID_TE);
+
+ // XXX
+#if 0
if(node->id)
; // XXX BIF_preview_changed(-1); /* temp hack to force texture preview to update */
diff --git a/source/blender/editors/space_node/node_select.c b/source/blender/editors/space_node/node_select.c
index 518901bcbec..f10fff56ec5 100644
--- a/source/blender/editors/space_node/node_select.c
+++ b/source/blender/editors/space_node/node_select.c
@@ -122,7 +122,7 @@ static int node_select_exec(bContext *C, wmOperator *op)
/* WATCH THIS, there are a few other ways to change the active material */
if(node) {
- if (node->id && GS(node->id->name)== ID_MA) {
+ if (node->id && ELEM(GS(node->id->name), ID_MA, ID_TE)) {
WM_event_add_notifier(C, NC_MATERIAL|ND_SHADING_DRAW, node->id);
}
}