2.5 / Nodes
authorNathan Letwory <nathan@letworyinteractive.com>
Mon, 12 Jan 2009 01:02:52 +0000 (01:02 +0000)
committerNathan Letwory <nathan@letworyinteractive.com>
Mon, 12 Jan 2009 01:02:52 +0000 (01:02 +0000)
* [Use nodes] added. For future improvements: a panel which enumerates
  materials, textures and scenes for selection and editing in the opened
  node-editor without having to set it in Buttons (or 'global' scene).

source/blender/editors/space_node/node_edit.c
source/blender/editors/space_node/node_header.c
source/blender/editors/space_node/node_intern.h
source/blender/editors/space_node/node_ops.c
source/blender/editors/space_node/node_select.c
source/blender/editors/space_node/node_state.c
source/blender/editors/space_node/space_node.c

index a99afbab63fef29e28e52d37ae1f516f9af9778c..6e026dc08d9e75f4552afcc7e81fba29ed40a433 100644 (file)
@@ -488,7 +488,7 @@ static void texture_node_event(SpaceNode *snode, short event)
        }
 }
 
-
+#endif /* 0  */
 /* assumes nothing being done in ntree yet, sets the default in/out node */
 /* called from shading buttons or header */
 void node_shader_default(Material *ma)
@@ -548,7 +548,7 @@ void node_composit_default(Scene *sce)
        
        ntreeSolveOrder(sce->nodetree); /* needed for pointers */
        
-       ntreeCompositForceHidden(sce->nodetree);
+       // XXX ntreeCompositForceHidden(sce->nodetree);
 }
 
 /* assumes nothing being done in ntree yet, sets the default in/out node */
@@ -580,7 +580,6 @@ void node_texture_default(Tex *tx)
        ntreeSolveOrder(tx->nodetree);  /* needed for pointers */
        ntreeTexUpdatePreviews(tx->nodetree);
 }
-#endif
 
 /* Here we set the active tree(s), even called for each redraw now, so keep it fast :) */
 void snode_set_context(SpaceNode *snode, Scene *scene)
index 7ae0c8141f7124d0b52c2f5d871ba65cec0da07a..7d333d9b1c0f1c65bdd774b8f30c7b0172277aed 100644 (file)
@@ -650,7 +650,52 @@ static uiBlock *node_viewmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_
 
 static void do_node_buttons(bContext *C, void *arg, int event)
 {
+       // NODE_FIX_ME : instead of using "current material/texture/scene" a la old buttons/G.scene
+       // have a panel from which enumerates textures, materials and scenes.
+       SpaceNode *snode= (SpaceNode*)CTX_wm_space_data(C);
+       Scene *scene= CTX_data_scene(C);
+       Material *ma;
+       Tex *tx;
+       
        switch(event) {
+               case B_NODE_USEMAT:
+                       ma= (Material *)snode->id;
+                       if(ma) {
+                               if(ma->use_nodes && ma->nodetree==NULL) {
+                                       node_shader_default(ma);
+                                       snode_set_context(snode, scene);
+                               }
+                               /* BIF_preview_changed(ID_MA);
+                               allqueue(REDRAWNODE, 0);
+                               allqueue(REDRAWBUTSSHADING, 0);
+                               allqueue(REDRAWIPO, 0);*/
+                       }               
+                       break;
+                       
+               case B_NODE_USESCENE:
+                       if(scene->use_nodes) {
+                               if(scene->nodetree==NULL)
+                                       node_composit_default(scene);
+                               // addqueue(curarea->win, UI_BUT_EVENT, B_NODE_TREE_EXEC);
+                       }
+                       snode_set_context(snode, scene);
+                       // allqueue(REDRAWNODE, 0);
+                       break;
+                       
+               case B_NODE_USETEX:
+                       tx = (Tex *)snode->id;
+                       if(tx) {
+                               tx->type = 0;
+                               if(tx->use_nodes && tx->nodetree==NULL) {
+                                       node_texture_default(tx);
+                                       snode_set_context(snode, scene);
+                               }
+                               /* BIF_preview_changed(ID_TE);
+                               allqueue(REDRAWNODE, 0);
+                               allqueue(REDRAWBUTSSHADING, 0);
+                               allqueue(REDRAWIPO, 0);*/
+                       }
+                       break;
        }
 }
 
index 8b7722b9c741f683f1f81509716db124ae1ec3f2..94a79d505539a5170d7ae02320a27ed4bc30fd55 100644 (file)
@@ -75,6 +75,9 @@ void snode_make_group_editable(SpaceNode *snode, bNode *gnode);
 void snode_home(ScrArea *sa, ARegion *ar, SpaceNode *snode);
 void node_set_active(SpaceNode *snode, bNode *node);
 void node_deselectall(SpaceNode *snode, int swap);
+void node_shader_default(Material *ma);
+void node_composit_default(Scene *sce);
+void node_texture_default(Tex *tx);
 
 // XXXXXX
 
index 0d034d4b24f0ffc3c5873ad5a9cb9a9f7dbecf15..abf7c134cb2ed2694c284fb0d1c6cb9e025ad94b 100644 (file)
@@ -27,6 +27,8 @@
  */
 
 #include "DNA_node_types.h"
+#include "DNA_material_types.h"
+#include "DNA_texture_types.h"
 #include "DNA_scene_types.h"
 #include "DNA_space_types.h"
 
index 1c91b8c3aadc06783d430b778b2995e73c6fbc1d..66db399bdf856693fbd47dbb9d319a161010fbe1 100644 (file)
@@ -29,6 +29,8 @@
 #include <stdio.h>
 
 #include "DNA_node_types.h"
+#include "DNA_material_types.h"
+#include "DNA_texture_types.h"
 #include "DNA_scene_types.h"
 #include "DNA_screen_types.h"
 #include "DNA_space_types.h"
index cda25c6798d7b01a3f99aa16d80387edd19d9c68..3472cc77dcd30427add8f550528301aa2cd63898 100644 (file)
@@ -29,6 +29,8 @@
 #include <stdio.h>
 
 #include "DNA_node_types.h"
+#include "DNA_material_types.h"
+#include "DNA_texture_types.h"
 #include "DNA_scene_types.h"
 #include "DNA_screen_types.h"
 #include "DNA_space_types.h"
index b632506558464ef41d298ec6034eedcfac92f249..c54f4ede898d164f9d03a42125c3373a9972f6e8 100644 (file)
@@ -31,6 +31,8 @@
 
 #include "DNA_node_types.h"
 #include "DNA_object_types.h"
+#include "DNA_material_types.h"
+#include "DNA_texture_types.h"
 #include "DNA_space_types.h"
 #include "DNA_scene_types.h"
 #include "DNA_screen_types.h"