Orange: preparation commit for Output nodes type "Render" and "File".
authorTon Roosendaal <ton@blender.org>
Tue, 24 Jan 2006 17:09:04 +0000 (17:09 +0000)
committerTon Roosendaal <ton@blender.org>
Tue, 24 Jan 2006 17:09:04 +0000 (17:09 +0000)
They dont work yet, but i accidentally committed parts of it with a bugfix.

source/blender/blenkernel/BKE_node.h
source/blender/blenkernel/intern/node.c
source/blender/blenkernel/intern/node_composit.c

index 88012978cd269c5bf095b27bd4eeb304d0bc36af..3ecfbb8ef29921d849cf64631c429e6f33876ce5 100644 (file)
@@ -83,6 +83,7 @@ typedef struct bNodeType {
 #define NODE_CLASS_GENERATOR   2
 #define NODE_CLASS_OPERATOR            3
 #define NODE_CLASS_GROUP               4
+#define NODE_CLASS_FILE                        5
 
 /* ************** GENERIC API, TREES *************** */
 
@@ -181,7 +182,9 @@ void                        set_node_shader_lamp_loop(void (*lamp_loop_func)(struct ShadeInput *, str
 /* ************** COMPOSIT NODES *************** */
 
 /* note: types are needed to restore callbacks, don't change values */
-#define CMP_NODE_OUTPUT                201
+#define CMP_NODE_OUTPUT                        201
+#define CMP_NODE_OUTPUT_RENDER 202
+#define CMP_NODE_OUTPUT_FILE   203
 
 #define CMP_NODE_RGB           202
 #define CMP_NODE_VALUE         203
index fc23758c4b35f214d60cd6f816802429be6401ae..1b755a84efbab1ea742098b2a01ef2301cafed06 100644 (file)
@@ -1179,18 +1179,22 @@ void ntreeSolveOrder(bNodeTree *ntree)
        
        MEM_freeN(nodesort);
        
-       /* find the active outputs, tree type dependant, might become handler */
-       if(ntree->type==NTREE_SHADER || ntree->type==NTREE_COMPOSIT) {
-               /* shader/composit nodes only accepts one output */
-               int output= 0;
-               
-               for(node= ntree->nodes.first; node; node= node->next) {
-                       if(node->typeinfo->nclass==NODE_CLASS_OUTPUT) {
-                               if(output==0)
-                                       node->flag |= NODE_DO_OUTPUT;
-                               else
-                                       node->flag &= ~NODE_DO_OUTPUT;
-                               output= 1;
+       /* find the active outputs, might become tree type dependant handler */
+       for(node= ntree->nodes.first; node; node= node->next) {
+               if(node->typeinfo->nclass==NODE_CLASS_OUTPUT) {
+                       bNode *tnode;
+                       int output= 0;
+                       /* there is more types having output class, each one is checked */
+                       for(tnode= ntree->nodes.first; tnode; tnode= tnode->next) {
+                               if(tnode->typeinfo->nclass==NODE_CLASS_OUTPUT) {
+                                       if(tnode->type==node->type) {
+                                               if(output==0)
+                                                       tnode->flag |= NODE_DO_OUTPUT;
+                                               else
+                                                       tnode->flag &= ~NODE_DO_OUTPUT;
+                                               output= 1;
+                                       }
+                               }
                        }
                }
        }
index b7d70b167baaa4383ab56b7134313b729c103ddc..4659b587e6103aac1c235fb510ac984c7ae7544e 100644 (file)
@@ -442,7 +442,7 @@ static void node_composit_exec_output(void *data, bNode *node, bNodeStack **in,
                        
                        cbuf= alloc_compbuf(rectx, recty, CB_RGBA, 0);  // no alloc
                        cbuf->rect= ima->ibuf->rect_float;
-               
+                       
                        /* when no alpha, we can simply copy */
                        if(in[1]->data==NULL)
                                composit1_pixel_processor(node, cbuf, in[0]->data, in[0]->vec, do_copy_rgba);
@@ -462,7 +462,7 @@ static void node_composit_exec_output(void *data, bNode *node, bNodeStack **in,
                        ima->ibuf->y= cbuf->y;
                        cbuf->rect= NULL;
                }
-               
+
        }
        else if(in[0]->data)
                generate_preview(node, in[0]->data);
@@ -480,6 +480,82 @@ static bNodeType cmp_node_output= {
        
 };
 
+/* **************** OUTPUT RENDER ******************** */
+static bNodeSocketType cmp_node_output_render_in[]= {
+       {       SOCK_RGBA, 1, "Image",          0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
+       {       SOCK_VALUE, 1, "Alpha",         1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+       {       -1, 0, ""       }
+};
+
+
+static void node_composit_exec_output_render(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
+{
+       /* image assigned to output */
+       /* stack order input sockets: col, alpha */
+       
+       if(node->flag & NODE_DO_OUTPUT) {       /* only one works on out */
+               RenderResult *rr= RE_GetResult(RE_GetRender("Render"));
+               if(rr) {
+                       RenderLayer *rl= rr->layers.first;
+                       CompBuf *outbuf= alloc_compbuf(rr->rectx, rr->recty, CB_RGBA, 0);       /* no alloc */
+                       
+                       outbuf->rect= rl->rectf;
+                       
+                       if(in[1]->data==NULL)
+                               composit1_pixel_processor(node, outbuf, in[0]->data, in[0]->vec, do_copy_rgba);
+                       else
+                               composit2_pixel_processor(node, outbuf, in[0]->data, in[0]->vec, in[1]->data, in[1]->vec, do_copy_a_rgba);
+                       
+                       free_compbuf(outbuf);
+               }
+       }
+       else if(in[0]->data)
+               generate_preview(node, in[0]->data);
+}
+
+static bNodeType cmp_node_output_render= {
+       /* type code   */       CMP_NODE_OUTPUT_RENDER,
+       /* name        */       "Render Output",
+       /* width+range */       80, 60, 200,
+       /* class+opts  */       NODE_CLASS_OUTPUT, NODE_PREVIEW,
+       /* input sock  */       cmp_node_output_render_in,
+       /* output sock */       NULL,
+       /* storage     */       "",
+       /* execfunc    */       node_composit_exec_output_render
+       
+};
+
+/* **************** OUTPUT FILE ******************** */
+static bNodeSocketType cmp_node_output_file_in[]= {
+       {       SOCK_RGBA, 1, "Image",          0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
+       {       SOCK_VALUE, 1, "Alpha",         1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+       {       -1, 0, ""       }
+};
+
+
+static void node_composit_exec_output_file(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
+{
+       /* image assigned to output */
+       /* stack order input sockets: col, alpha */
+       
+       if(node->id && (node->flag & NODE_DO_OUTPUT)) { /* only one works on out */
+       }
+       else if(in[0]->data)
+               generate_preview(node, in[0]->data);
+}
+
+static bNodeType cmp_node_output_file= {
+       /* type code   */       CMP_NODE_OUTPUT_FILE,
+       /* name        */       "File Output",
+       /* width+range */       80, 60, 200,
+       /* class+opts  */       NODE_CLASS_FILE, NODE_PREVIEW,
+       /* input sock  */       cmp_node_output_file_in,
+       /* output sock */       NULL,
+       /* storage     */       "",
+       /* execfunc    */       node_composit_exec_output_file
+       
+};
+
 /* **************** IMAGE ******************** */
 static bNodeSocketType cmp_node_image_out[]= {
        {       SOCK_RGBA, 0, "Image",          0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
@@ -862,7 +938,10 @@ static void do_filter3(CompBuf *out, CompBuf *in, float *filter, float fac)
                        row1= in->rect + 4*(y-2)*rowlen;
                        row2= row1 + 4*rowlen;
                        row3= row2 + 4*rowlen;
-                       fp= out->rect + 4*(y-1)*rowlen + 4;
+                       
+                       fp= out->rect + 4*(y-1)*rowlen;
+                       QUATCOPY(fp, row2);
+                       fp+= 4;
                        
                        for(x=2; x<rowlen; x++) {
                                for(c=0; c<4; c++) {
@@ -1339,6 +1418,8 @@ static bNodeType cmp_node_blur= {
 bNodeType *node_all_composit[]= {
        &node_group_typeinfo,
        &cmp_node_output,
+       &cmp_node_output_render,
+       &cmp_node_output_file,
        &cmp_node_value,
        &cmp_node_rgb,
        &cmp_node_mix_rgb,