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>2006-11-17 00:50:35 +0300
committerTon Roosendaal <ton@blender.org>2006-11-17 00:50:35 +0300
commitf89b0522623929580d59c2d518837d216cc51961 (patch)
tree672946af488f5ab1109bbc092b50f362bc1a03a9
parentd59224377c15d671e5030b5de2690fc68b9c5d6d (diff)
New Compo node: the Split-Viewer, showing two images halves to compare.
Works internally already with masks, so we can have several builtin types.
-rw-r--r--source/blender/blenkernel/BKE_node.h3
-rw-r--r--source/blender/blenkernel/intern/node.c2
-rw-r--r--source/blender/blenkernel/intern/node_composite.c94
-rw-r--r--source/blender/src/editnode.c4
4 files changed, 100 insertions, 3 deletions
diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h
index 5197e32d4e4..94884caaa25 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -242,6 +242,9 @@ void set_node_shader_lamp_loop(void (*lamp_loop_func)(struct ShadeInput *, str
#define CMP_NODE_LUMA 238
#define CMP_NODE_FLIP 239
+
+#define CMP_NODE_SPLITVIEWER 240
+
/* filter types */
diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c
index 82613151113..fb97669b1ad 100644
--- a/source/blender/blenkernel/intern/node.c
+++ b/source/blender/blenkernel/intern/node.c
@@ -1974,7 +1974,7 @@ static int setExecutableNodes(bNodeTree *ntree, ThreadData *thd)
/* test the inputs */
for(a=0, sock= node->inputs.first; sock; sock= sock->next, a++) {
/* skip viewer nodes in bg render or group edit */
- if(node->type==CMP_NODE_VIEWER && (G.background || group_edit))
+ if( ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER) && (G.background || group_edit))
node->need_exec= 0;
/* is sock in use? */
else if(sock->link) {
diff --git a/source/blender/blenkernel/intern/node_composite.c b/source/blender/blenkernel/intern/node_composite.c
index 48dd2654db8..9d022f9d924 100644
--- a/source/blender/blenkernel/intern/node_composite.c
+++ b/source/blender/blenkernel/intern/node_composite.c
@@ -609,6 +609,99 @@ static bNodeType cmp_node_viewer= {
};
+/* **************** SPLIT VIEWER ******************** */
+static bNodeSocketType cmp_node_splitviewer_in[]= {
+ { SOCK_RGBA, 1, "Image", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
+ { SOCK_RGBA, 1, "Image", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
+ { -1, 0, "" }
+};
+
+static void do_copy_split_rgba(bNode *node, float *out, float *in1, float *in2, float *fac)
+{
+ if(*fac==0.0f) {
+ QUATCOPY(out, in1);
+ }
+ else {
+ QUATCOPY(out, in2);
+ }
+}
+
+static void node_composit_exec_splitviewer(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
+{
+ /* image assigned to output */
+ /* stack order input sockets: image image */
+
+ if(in[0]->data==NULL || in[1]->data==NULL)
+ return;
+
+ if(node->id && (node->flag & NODE_DO_OUTPUT)) { /* only one works on out */
+ Image *ima= (Image *)node->id;
+ CompBuf *cbuf, *buf1, *buf2, *mask;
+ int x, y;
+
+ buf1= typecheck_compbuf(in[0]->data, CB_RGBA);
+ buf2= typecheck_compbuf(in[1]->data, CB_RGBA);
+
+ if(ima->ibuf==NULL)
+ ima->ibuf= IMB_allocImBuf(buf1->x, buf1->y, 32, 0, 0);
+
+ /* cleanup of viewer image */
+ if(ima->ibuf->rect) {
+ MEM_freeN(ima->ibuf->rect);
+ ima->ibuf->rect= NULL;
+ ima->ibuf->mall &= ~IB_rect;
+ }
+ if(ima->ibuf->zbuf_float) {
+ MEM_freeN(ima->ibuf->zbuf_float);
+ ima->ibuf->zbuf_float= NULL;
+ ima->ibuf->mall &= ~IB_zbuffloat;
+ }
+ if(ima->ibuf->rect_float)
+ MEM_freeN(ima->ibuf->rect_float);
+
+ ima->ibuf->x= buf1->x;
+ ima->ibuf->y= buf1->y;
+ ima->ibuf->mall |= IB_rectfloat;
+ ima->ibuf->rect_float= MEM_mallocN(4*buf1->x*buf1->y*sizeof(float), "viewer rect");
+
+ /* output buf */
+ cbuf= alloc_compbuf(buf1->x, buf1->y, CB_RGBA, 0); /* no alloc*/
+ cbuf->rect= ima->ibuf->rect_float;
+
+ /* mask buf */
+ mask= alloc_compbuf(buf1->x, buf1->y, CB_VAL, 1);
+ for(y=0; y<buf1->y; y++) {
+ float *fac= mask->rect + y*buf1->x;
+ for(x=buf1->x/2; x>0; x--, fac++)
+ *fac= 1.0f;
+ }
+
+ composit3_pixel_processor(node, cbuf, buf1, in[0]->vec, buf2, in[1]->vec, mask, NULL, do_copy_split_rgba, CB_RGBA, CB_RGBA, CB_VAL);
+
+ generate_preview(node, cbuf);
+ free_compbuf(cbuf);
+ free_compbuf(mask);
+
+ if(in[0]->data != buf1)
+ free_compbuf(buf1);
+ if(in[1]->data != buf2)
+ free_compbuf(buf2);
+ }
+}
+
+static bNodeType cmp_node_splitviewer= {
+ /* type code */ CMP_NODE_SPLITVIEWER,
+ /* name */ "SplitViewer",
+ /* width+range */ 80, 60, 200,
+ /* class+opts */ NODE_CLASS_OUTPUT, NODE_PREVIEW,
+ /* input sock */ cmp_node_splitviewer_in,
+ /* output sock */ NULL,
+ /* storage */ "",
+ /* execfunc */ node_composit_exec_splitviewer
+
+};
+
+
/* **************** COMPOSITE ******************** */
static bNodeSocketType cmp_node_composite_in[]= {
{ SOCK_RGBA, 1, "Image", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
@@ -4210,6 +4303,7 @@ bNodeType *node_all_composit[]= {
&cmp_node_rotate,
&cmp_node_scale,
&cmp_node_luma,
+ &cmp_node_splitviewer,
NULL
};
diff --git a/source/blender/src/editnode.c b/source/blender/src/editnode.c
index 416de1e7b69..d3135f5b412 100644
--- a/source/blender/src/editnode.c
+++ b/source/blender/src/editnode.c
@@ -429,12 +429,12 @@ static void node_set_active(SpaceNode *snode, bNode *node)
}
else if(snode->treetype==NTREE_COMPOSIT) {
/* make active viewer, currently only 1 supported... */
- if(node->type==CMP_NODE_VIEWER) {
+ if( ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) {
bNode *tnode;
int was_output= node->flag & NODE_DO_OUTPUT;
for(tnode= snode->edittree->nodes.first; tnode; tnode= tnode->next)
- if(tnode->type==CMP_NODE_VIEWER)
+ if( ELEM(tnode->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER))
tnode->flag &= ~NODE_DO_OUTPUT;
node->flag |= NODE_DO_OUTPUT;