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:
authorTon Roosendaal <ton@blender.org>2005-12-28 18:42:51 +0300
committerTon Roosendaal <ton@blender.org>2005-12-28 18:42:51 +0300
commit9df1460777cceed839721ea99fd9623aedbb26f5 (patch)
treef4ad7ebfb6294be13c01a3dba67e55354973818e /source/blender/blenloader
parent7837866b1e226925b2a50041e3f0f56ac9e82021 (diff)
Christmas coding work!
********* Node editor work: - To enable Nodes for Materials, you have to set the "Use Nodes" button, in the new Material buttons "Nodes" Panel or in header of the Node editor. Doing this will disable Material-Layers. - Nodes now execute materials ("shaders"), but still only using the previewrender code. - Nodes have (optional) previews for rendered images. - Node headers allow to hide buttons and/or preview image - Nodes can be dragged larger/smaller (right-bottom corner) - Nodes can be hidden (minimized) with hotkey H - CTRL+click on an Input Socket gives a popup with default values. - Changing Material/Texture or Mix node will adjust Node title. - Click-drag outside of a Node changes cursor to "Knife' and allows to draw a rect where to cut Links. - Added new node types RGBtoBW, Texture, In/Output, ColorRamp - Material Nodes have options to ouput diffuse or specular, or to use a negative normal. The input socket 'Normal' will force the material to use that normal, otherwise it uses the normal from the Material that has the node tree. - When drawing a link between two not-matching sockets, Blender inserts a converting node (now only for value/rgb combos) - When drawing a link to an input socket that's already in use, the old link will either disappear or flip to another unused socket. - A click on a Material Node will activate it, and show all its settings in the Material Buttons. Active Material Nodes draw the material icon in red. - A click on any node will show its options in the Node Panel in the Material buttons. - Multiple Output Nodes can be used, to sample contents of a tree, but only one Output is the real one, which is indicated in a different color and red material icon. - Added ThemeColors for node types - ALT+C will convert existing Material-Layers to Node... this currently only adds the material/mix nodes and connects them. Dunno if this is worth a lot of coding work to make perfect? - Press C to call another "Solve order", which will show all possible cyclic conflicts (if there are). - Technical: nodes now use "Type" structs which define the structure of nodes and in/output sockets. The Type structs store all fixed info, callbacks, and allow to reconstruct saved Nodes to match what is required by Blender. - Defining (new) nodes now is as simple as filling in a fixed Type struct, plus code some callbacks. A doc will be made! - Node preview images are by default float ********* Icon drawing: - Cleanup of how old icons were implemented in new system, making them 16x16 too, correctly centered *and* scaled. - Made drawing Icons use float coordinates - Moved BIF_calcpreview_image() into interface_icons.c, renamed it icon_from_image(). Removed a lot of unneeded Imbuf magic here! :) - Skipped scaling and imbuf copying when icons are OK size ********* Preview render: - Huge cleanup of code.... - renaming BIF_xxx calls that only were used internally - BIF_previewrender() now accepts an argument for rendering method, so it supports icons, buttonwindow previewrender and node editor - Only a single BIF_preview_changed() call now exists, supporting all signals as needed for buttos and node editor ********* More stuff: - glutil.c, glaDrawPixelsSafe() and glaDrawPixelsTex() now accept format argument for GL_FLOAT rects - Made the ColorBand become a built-in button for interface.c Was a load of cleanup work in buttons_shading.c... - removed a load of unneeded glBlendFunc() calls - Fixed bug in calculating text length for buttons (ancient!)
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r--source/blender/blenloader/intern/readfile.c88
-rw-r--r--source/blender/blenloader/intern/writefile.c37
2 files changed, 114 insertions, 11 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index bf6928b7b20..295ebc15a68 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -76,6 +76,7 @@
#include "DNA_meshdata_types.h"
#include "DNA_modifier_types.h"
#include "DNA_nla_types.h"
+#include "DNA_node_types.h"
#include "DNA_object_types.h"
#include "DNA_object_force.h"
#include "DNA_object_fluidsim.h" // NT
@@ -1205,6 +1206,61 @@ static void test_pointer_array(FileData *fd, void **mat)
}
}
+/* ************ READ NODE TREE *************** */
+
+/* ntree is not NULL */
+static void lib_link_nodetree(FileData *fd, ID *id, bNodeTree *ntree)
+{
+ bNode *node;
+
+ for(node= ntree->nodes.first; node; node= node->next)
+ node->id= newlibadr_us(fd, id->lib, node->id);
+}
+
+static bNodeTree *direct_link_nodetree(FileData *fd, bNodeTree *ntree)
+{
+ /* note: writing and reading goes in sync, for speed */
+ if(ntree) {
+ ntree= newdataadr(fd, ntree);
+
+ if(ntree) {
+ bNode *node;
+ bNodeSocket *sock;
+ bNodeLink *link;
+
+ ntree->init= 0; /* to set callbacks */
+ ntree->data= NULL; /* safety only */
+
+ link_list(fd, &ntree->nodes);
+ for(node= ntree->nodes.first; node; node= node->next) {
+ node->storage= newdataadr(fd, node->storage);
+ link_list(fd, &node->inputs);
+ link_list(fd, &node->outputs);
+ }
+ link_list(fd, &ntree->links);
+
+ /* and we connect the rest */
+ for(node= ntree->nodes.first; node; node= node->next) {
+ node->preview= NULL;
+ node->lasty= 0;
+ for(sock= node->inputs.first; sock; sock= sock->next)
+ sock->link= newdataadr(fd, sock->link);
+ }
+ for(link= ntree->links.first; link; link= link->next) {
+ link->fromnode= newdataadr(fd, link->fromnode);
+ link->tonode= newdataadr(fd, link->tonode);
+ link->fromsock= newdataadr(fd, link->fromsock);
+ link->tosock= newdataadr(fd, link->tosock);
+ }
+ /* right after read file, the save-undo will need it */
+ /* verify also does a full type checking. This is relative slow... so we
+ might move this later to the do_versions, and put ntreeInitTypes() only here */
+ ntreeVerifyTypes(ntree);
+ }
+ }
+ return ntree;
+}
+
/* ************ READ PACKEDFILE *************** */
static PackedFile *direct_link_packedfile(FileData *fd, PackedFile *oldpf)
@@ -1993,7 +2049,7 @@ static void lib_link_material(FileData *fd, Main *main)
ma->ipo= newlibadr_us(fd, ma->id.lib, ma->ipo);
ma->group= newlibadr_us(fd, ma->id.lib, ma->group);
-
+
for(a=0; a<MAX_MTEX; a++) {
mtex= ma->mtex[a];
if(mtex) {
@@ -2005,7 +2061,10 @@ static void lib_link_material(FileData *fd, Main *main)
for (ml=ma->layers.first; ml; ml=ml->next)
ml->mat= newlibadr_us(fd, ma->id.lib, ml->mat);
-
+
+ if(ma->nodetree)
+ lib_link_nodetree(fd, &ma->id, ma->nodetree);
+
ma->id.flag -= LIB_NEEDLINK;
}
ma= ma->id.next;
@@ -2026,7 +2085,8 @@ static void direct_link_material(FileData *fd, Material *ma)
direct_link_scriptlink(fd, &ma->scriptlink);
link_list(fd, &ma->layers);
-
+
+ ma->nodetree= direct_link_nodetree(fd, ma->nodetree);
}
/* ************ READ MESH ***************** */
@@ -2994,6 +3054,13 @@ void lib_link_screen_restore(Main *newmain, Scene *curscene)
ssound->sound= restore_pointer_by_name(newmain, (ID *)ssound->sound, 1);
}
+ else if(sl->spacetype==SPACE_NODE) {
+ SpaceNode *snode= (SpaceNode *)sl;
+
+ snode->nodetree= NULL;
+ snode->block= NULL;
+ snode->flag |= SNODE_DO_PREVIEW;
+ }
}
sa= sa->next;
}
@@ -3088,6 +3155,7 @@ static void direct_link_screen(FileData *fd, bScreen *sc)
SpaceNode *snode= (SpaceNode *)sl;
snode->nodetree= NULL;
snode->block= NULL;
+ snode->flag |= SNODE_DO_PREVIEW;
}
}
@@ -5115,11 +5183,8 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
ma->strand_sta= ma->strand_end= 1.0f;
ma->mode |= MA_TANGENT_STR;
}
- /* remove this test before 2.40 too! pad is set to denote check was done */
- if(ma->pad==0) {
- if(ma->mode & MA_TRACEBLE) ma->mode |= MA_SHADBUF;
- ma->pad= 1;
- }
+ if(ma->mode & MA_TRACEBLE) ma->mode |= MA_SHADBUF;
+
/* orange stuff, so should be done for 2.40 too */
if(ma->layers.first==NULL) {
ma->ml_flag= ML_RENDER;
@@ -5379,6 +5444,13 @@ static void expand_material(FileData *fd, Main *mainvar, Material *ma)
if(ml->mat)
expand_doit(fd, mainvar, ml->mat);
}
+
+ if(ma->nodetree) {
+ bNode *node;
+ for(node= ma->nodetree->nodes.first; node; node= node->next)
+ if(node->id)
+ expand_doit(fd, mainvar, node->id);
+ }
}
static void expand_lamp(FileData *fd, Main *mainvar, Lamp *la)
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index 23d9d04ce3b..704215aaa7e 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -124,6 +124,7 @@ Important to know is that 'streaming' has been added to files, for Blender Publi
#include "DNA_material_types.h"
#include "DNA_modifier_types.h"
#include "DNA_nla_types.h"
+#include "DNA_node_types.h"
#include "DNA_object_types.h"
#include "DNA_object_force.h"
#include "DNA_oops_types.h"
@@ -153,6 +154,7 @@ Important to know is that 'streaming' has been added to files, for Blender Publi
#include "BKE_global.h" // for G
#include "BKE_library.h" // for set_listbasepointers
#include "BKE_main.h" // G.main
+#include "BKE_node.h"
#include "BKE_packedFile.h" // for packAll
#include "BKE_screen.h" // for waitcursor
#include "BKE_scene.h" // for do_seq
@@ -317,7 +319,7 @@ static void writestruct(WriteData *wd, int filecode, char *structname, int nr, v
BHead bh;
short *sp;
- if(adr==0 || nr==0) return;
+ if(adr==NULL || nr==0) return;
/* init BHead */
bh.code= filecode;
@@ -326,7 +328,7 @@ static void writestruct(WriteData *wd, int filecode, char *structname, int nr, v
bh.SDNAnr= dna_findstruct_nr(wd->sdna, structname);
if(bh.SDNAnr== -1) {
- printf("error: can't find SDNA code %s\n", structname);
+ printf("error: can't find SDNA code <%s>\n", structname);
return;
}
sp= wd->sdna->structs[bh.SDNAnr];
@@ -360,6 +362,33 @@ static void writedata(WriteData *wd, int filecode, int len, void *adr) /* do not
if(len) mywrite(wd, adr, len);
}
+/* this is only direct data */
+static void write_nodetree(WriteData *wd, bNodeTree *ntree)
+{
+ bNode *node;
+ bNodeSocket *sock;
+ bNodeLink *link;
+
+ writestruct(wd, DATA, "bNodeTree", 1, ntree);
+
+ /* for link_list() speed, we write per list */
+
+ for(node= ntree->nodes.first; node; node= node->next)
+ writestruct(wd, DATA, "bNode", 1, node);
+
+ for(node= ntree->nodes.first; node; node= node->next) {
+ if(node->storage)
+ writestruct(wd, DATA, node->typeinfo->storagename, 1, node->storage);
+ for(sock= node->inputs.first; sock; sock= sock->next)
+ writestruct(wd, DATA, "bNodeSocket", 1, sock);
+ for(sock= node->outputs.first; sock; sock= sock->next)
+ writestruct(wd, DATA, "bNodeSocket", 1, sock);
+ }
+
+ for(link= ntree->links.first; link; link= link->next)
+ writestruct(wd, DATA, "bNodeLink", 1, link);
+}
+
static void write_scriptlink(WriteData *wd, ScriptLink *slink)
{
writedata(wd, DATA, sizeof(void *)*slink->totscript, slink->scripts);
@@ -1014,7 +1043,9 @@ static void write_materials(WriteData *wd, ListBase *idbase)
for (ml=ma->layers.first; ml; ml=ml->next)
writestruct(wd, DATA, "MaterialLayer", 1, ml);
-
+
+ if(ma->nodetree)
+ write_nodetree(wd, ma->nodetree);
}
ma= ma->id.next;
}