[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [20041] trunk/blender/source/blender: Bugfix 18671 revisted
Ton Roosendaal
ton at blender.org
Sun May 3 15:22:26 CEST 2009
Revision: 20041
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=20041
Author: ton
Date: 2009-05-03 15:22:26 +0200 (Sun, 03 May 2009)
Log Message:
-----------
Bugfix 18671 revisted
Node editor didn't support editing non-material texture node trees.
Campbell pointed me to fact it's been used already, like for brush
painting. However, this only worked via linking the texture to a
material... hackish stuff.
Now the Node Editor supports all other Textures too, with three extra
icon buttons to define which.
- Active Object: for textures linked to Materials or Lamps
- World: textures from Scene world.
- Brush: textures from active Brush
The latter can only be set and used when in Paint or Sculpt mode:
- Paint mode: in Image window, Paint Tool panel, set active brush
- Sculpt mode: in EditButtons, Texture panel, select empty slot, add texture.
Note that refreshes of previews in Node Editor is not always happening on
switching contextes. Just click a socket to refresh view.
Modified Paths:
--------------
trunk/blender/source/blender/makesdna/DNA_space_types.h
trunk/blender/source/blender/src/buttons_shading.c
trunk/blender/source/blender/src/editnode.c
trunk/blender/source/blender/src/header_node.c
Modified: trunk/blender/source/blender/makesdna/DNA_space_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_space_types.h 2009-05-03 13:17:37 UTC (rev 20040)
+++ trunk/blender/source/blender/makesdna/DNA_space_types.h 2009-05-03 13:22:26 UTC (rev 20041)
@@ -356,7 +356,8 @@
float xof, yof; /* offset for drawing the backdrop */
struct bNodeTree *nodetree, *edittree;
- int treetype, pad; /* treetype: as same nodetree->type */
+ int treetype; /* treetype: as same nodetree->type */
+ short texfrom, pad; /* texfrom object, world or brush */
struct bGPdata *gpd; /* grease-pencil data */
} SpaceNode;
@@ -366,6 +367,11 @@
#define SNODE_BACKDRAW 2
#define SNODE_DISPGP 4
+/* snode->texfrom */
+#define SNODE_TEX_OBJECT 0
+#define SNODE_TEX_WORLD 1
+#define SNODE_TEX_BRUSH 2
+
typedef struct SpaceImaSel {
SpaceLink *next, *prev;
int spacetype;
Modified: trunk/blender/source/blender/src/buttons_shading.c
===================================================================
--- trunk/blender/source/blender/src/buttons_shading.c 2009-05-03 13:17:37 UTC (rev 20040)
+++ trunk/blender/source/blender/src/buttons_shading.c 2009-05-03 13:22:26 UTC (rev 20041)
@@ -1705,8 +1705,7 @@
uiDefButS(block, MENU, B_TEXTYPE, textypes, 160, 125, 140, 25, &tex->type, 0,0,0,0, "Select texture type");
}
- if(ma)
- uiDefButC(block, TOG, B_TEX_USENODES, "Nodes", 160, 100, 140, 25, &tex->use_nodes, 0.0f, 0.0f, 0, 0, "");
+ uiDefButC(block, TOG, B_TEX_USENODES, "Nodes", 160, 100, 140, 25, &tex->use_nodes, 0.0f, 0.0f, 0, 0, "");
}
else {
Modified: trunk/blender/source/blender/src/editnode.c
===================================================================
--- trunk/blender/source/blender/src/editnode.c 2009-05-03 13:17:37 UTC (rev 20040)
+++ trunk/blender/source/blender/src/editnode.c 2009-05-03 13:22:26 UTC (rev 20041)
@@ -35,6 +35,7 @@
#include "MEM_guardedalloc.h"
#include "DNA_action_types.h"
+#include "DNA_brush_types.h"
#include "DNA_color_types.h"
#include "DNA_image_types.h"
#include "DNA_ipo_types.h"
@@ -583,14 +584,42 @@
snode->nodetree= G.scene->nodetree;
}
else if(snode->treetype==NTREE_TEXTURE) {
- if(ob) {
- Tex *tx= give_current_texture(ob, ob->actcol);
- if(tx) {
- snode->from= (ID*)ob; /* please check this; i have no idea what 'from' is. */
- snode->id= &tx->id;
- snode->nodetree= tx->nodetree;
+ Tex *tx= NULL;
+
+ if(snode->texfrom==SNODE_TEX_OBJECT) {
+ if(ob) {
+ tx= give_current_texture(ob, ob->actcol);
+ snode->from= (ID *)ob;
}
}
+ else if(snode->texfrom==SNODE_TEX_WORLD) {
+ tx= give_current_world_texture();
+ snode->from= (ID *)G.scene->world;
+ }
+ else {
+ MTex *mtex= NULL;
+
+ if(G.f & G_SCULPTMODE) {
+ SculptData *sd= &G.scene->sculptdata;
+ if(sd->texact != -1)
+ mtex= sd->mtex[sd->texact];
+ }
+ else {
+ Brush *br= G.scene->toolsettings->imapaint.brush;
+ if(br)
+ mtex= br->mtex[br->texact];
+ }
+
+ if(mtex) {
+ snode->from= (ID *)G.scene;
+ tx= mtex->tex;
+ }
+ }
+
+ if(tx) {
+ snode->id= &tx->id;
+ snode->nodetree= tx->nodetree;
+ }
}
/* find editable group */
Modified: trunk/blender/source/blender/src/header_node.c
===================================================================
--- trunk/blender/source/blender/src/header_node.c 2009-05-03 13:17:37 UTC (rev 20040)
+++ trunk/blender/source/blender/src/header_node.c 2009-05-03 13:22:26 UTC (rev 20041)
@@ -756,8 +756,26 @@
uiDefIconButI(block, ROW, B_REDR, ICON_TEXTURE_DEHLT, xco,2,XIC,YIC-2,
&(snode->treetype), 2, 2, 0, 0, "Texture Nodes");
xco+= 2*XIC;
+
uiBlockEndAlign(block);
+ if(snode->treetype==NTREE_TEXTURE) {
+
+ uiBlockBeginAlign(block);
+ uiDefIconButS(block, ROW, B_REDR, ICON_OBJECT, xco,2,XIC,YIC-2,
+ &(snode->texfrom), 3, SNODE_TEX_OBJECT, 0, 0, "Texture Nodes from Object");
+ xco+= XIC;
+ uiDefIconButS(block, ROW, B_REDR, ICON_WORLD_DEHLT, xco,2,XIC,YIC-2,
+ &(snode->texfrom), 3, SNODE_TEX_WORLD, 0, 0, "Texture Nodes from World");
+ xco+= XIC;
+ uiDefIconButS(block, ROW, B_REDR, ICON_TPAINT_DEHLT, xco,2,XIC,YIC-2,
+ &(snode->texfrom), 3, SNODE_TEX_BRUSH, 0, 0, "Texture Nodes from Active Brush or Sculpt Data");
+ xco+= 2*XIC;
+
+ uiBlockEndAlign(block);
+
+ }
+
/* find and set the context */
snode_set_context(snode);
@@ -785,8 +803,9 @@
else if(snode->treetype==NTREE_TEXTURE) {
if(snode->from) {
+ /* can't use unlink etc here, code requires buttons context */
xco= std_libbuttons(block, xco, 0, 0, NULL, B_TEXBROWSE, ID_TE, 1, snode->id, snode->from, &(snode->menunr),
- B_TEXALONE, B_TEXLOCAL, B_TEXDELETE, B_AUTOTEXNAME, B_KEEPDATA);
+ 0, 0, 0, B_AUTOTEXNAME, B_KEEPDATA);
if(snode->id) {
Tex *tx= (Tex *)snode->id;
More information about the Bf-blender-cvs
mailing list