[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [14014] trunk/blender/source/blender: Long on the wishlist, quite simple even, and there it finally is:
Ton Roosendaal
ton at blender.org
Sat Mar 8 20:02:19 CET 2008
Revision: 14014
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=14014
Author: ton
Date: 2008-03-08 20:02:08 +0100 (Sat, 08 Mar 2008)
Log Message:
-----------
Long on the wishlist, quite simple even, and there it finally is:
Compositor:
Muting option to temporary disable/enable nodes.
Hotkey: press M on selection. It toggles.
Note: no menu entry yet, and drawing style could be tweakered...
Modified Paths:
--------------
trunk/blender/source/blender/blenkernel/intern/node.c
trunk/blender/source/blender/makesdna/DNA_node_types.h
trunk/blender/source/blender/nodes/intern/CMP_util.c
trunk/blender/source/blender/nodes/intern/CMP_util.h
trunk/blender/source/blender/src/drawnode.c
trunk/blender/source/blender/src/editnode.c
Modified: trunk/blender/source/blender/blenkernel/intern/node.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/node.c 2008-03-08 11:12:05 UTC (rev 14013)
+++ trunk/blender/source/blender/blenkernel/intern/node.c 2008-03-08 19:02:08 UTC (rev 14014)
@@ -64,6 +64,8 @@
#include "RE_render_ext.h" /* <- ibuf_sample() */
#include "CMP_node.h"
+#include "intern/CMP_util.h" /* stupid include path... */
+
#include "SHD_node.h"
/* not very important, but the stack solver likes to know a maximum */
@@ -1990,7 +1992,28 @@
/* ***************************** threaded version for execute composite nodes ************* */
+/* these are nodes without input, only giving values */
+/* or nodes with only value inputs */
+static int node_only_value(bNode *node)
+{
+ bNodeSocket *sock;
+
+ if(ELEM3(node->type, CMP_NODE_TIME, CMP_NODE_VALUE, CMP_NODE_RGB))
+ return 1;
+
+ /* doing this for all node types goes wrong. memory free errors */
+ if(node->inputs.first && node->type==CMP_NODE_MAP_VALUE) {
+ int retval= 1;
+ for(sock= node->inputs.first; sock; sock= sock->next) {
+ if(sock->link)
+ retval &= node_only_value(sock->link->fromnode);
+ }
+ return retval;
+ }
+ return 0;
+}
+
/* not changing info, for thread callback */
typedef struct ThreadData {
bNodeStack *stack;
@@ -2006,7 +2029,14 @@
node_get_stack(node, thd->stack, nsin, nsout);
- if(node->typeinfo->execfunc) {
+ if((node->flag & NODE_MUTED) && (!node_only_value(node))) {
+ /* viewers we execute, for feedback to user */
+ if(ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER))
+ node->typeinfo->execfunc(thd->rd, node, nsin, nsout);
+ else
+ node_compo_pass_on(node, nsin, nsout);
+ }
+ else if(node->typeinfo->execfunc) {
node->typeinfo->execfunc(thd->rd, node, nsin, nsout);
}
else if(node->type==NODE_GROUP && node->id) {
@@ -2017,27 +2047,6 @@
return 0;
}
-/* these are nodes without input, only giving values */
-/* or nodes with only value inputs */
-static int node_only_value(bNode *node)
-{
- bNodeSocket *sock;
-
- if(ELEM3(node->type, CMP_NODE_TIME, CMP_NODE_VALUE, CMP_NODE_RGB))
- return 1;
-
- /* doing this for all node types goes wrong. memory free errors */
- if(node->inputs.first && node->type==CMP_NODE_MAP_VALUE) {
- int retval= 1;
- for(sock= node->inputs.first; sock; sock= sock->next) {
- if(sock->link)
- retval &= node_only_value(sock->link->fromnode);
- }
- return retval;
- }
- return 0;
-}
-
/* return total of executable nodes, for timecursor */
/* only compositor uses it */
static int setExecutableNodes(bNodeTree *ntree, ThreadData *thd)
Modified: trunk/blender/source/blender/makesdna/DNA_node_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_node_types.h 2008-03-08 11:12:05 UTC (rev 14013)
+++ trunk/blender/source/blender/makesdna/DNA_node_types.h 2008-03-08 19:02:08 UTC (rev 14014)
@@ -144,6 +144,8 @@
#define NODE_GROUP_EDIT 128
/* free test flag, undefined */
#define NODE_TEST 256
+ /* composite: don't do node but pass on buffer(s) */
+#define NODE_MUTED 512
typedef struct bNodeLink {
struct bNodeLink *next, *prev;
Modified: trunk/blender/source/blender/nodes/intern/CMP_util.c
===================================================================
--- trunk/blender/source/blender/nodes/intern/CMP_util.c 2008-03-08 11:12:05 UTC (rev 14013)
+++ trunk/blender/source/blender/nodes/intern/CMP_util.c 2008-03-08 19:02:08 UTC (rev 14014)
@@ -122,6 +122,48 @@
}
+/* used for disabling node (similar code in drawnode.c for disable line) */
+void node_compo_pass_on(bNode *node, bNodeStack **nsin, bNodeStack **nsout)
+{
+ CompBuf *valbuf= NULL, *colbuf= NULL, *vecbuf= NULL;
+ bNodeSocket *sock;
+ int a;
+
+ /* connect the first value buffer in with first value out */
+ /* connect the first RGBA buffer in with first RGBA out */
+
+ /* test the inputs */
+ for(a=0, sock= node->inputs.first; sock; sock= sock->next, a++) {
+ if(nsin[a]->data) {
+ CompBuf *cbuf= nsin[a]->data;
+ if(cbuf->type==1 && valbuf==NULL) valbuf= cbuf;
+ if(cbuf->type==3 && vecbuf==NULL) vecbuf= cbuf;
+ if(cbuf->type==4 && colbuf==NULL) colbuf= cbuf;
+ }
+ }
+
+ /* outputs */
+ if(valbuf || colbuf || vecbuf) {
+ for(a=0, sock= node->outputs.first; sock; sock= sock->next, a++) {
+ if(nsout[a]->hasoutput) {
+ if(sock->type==SOCK_VALUE && valbuf) {
+ nsout[a]->data= pass_on_compbuf(valbuf);
+ valbuf= NULL;
+ }
+ if(sock->type==SOCK_VECTOR && vecbuf) {
+ nsout[a]->data= pass_on_compbuf(vecbuf);
+ vecbuf= NULL;
+ }
+ if(sock->type==SOCK_RGBA && colbuf) {
+ nsout[a]->data= pass_on_compbuf(colbuf);
+ colbuf= NULL;
+ }
+ }
+ }
+ }
+}
+
+
CompBuf *get_cropped_compbuf(rcti *drect, float *rectf, int rectx, int recty, int type)
{
CompBuf *cbuf;
Modified: trunk/blender/source/blender/nodes/intern/CMP_util.h
===================================================================
--- trunk/blender/source/blender/nodes/intern/CMP_util.h 2008-03-08 11:12:05 UTC (rev 14013)
+++ trunk/blender/source/blender/nodes/intern/CMP_util.h 2008-03-08 19:02:08 UTC (rev 14014)
@@ -132,6 +132,7 @@
CompBuf *pass_on_compbuf(CompBuf *cbuf);
void free_compbuf(CompBuf *cbuf);
void print_compbuf(char *str, CompBuf *cbuf);
+void node_compo_pass_on(struct bNode *node, struct bNodeStack **nsin, struct bNodeStack **nsout);
CompBuf *get_cropped_compbuf(rcti *drect, float *rectf, int rectx, int recty, int type);
CompBuf *scalefast_compbuf(CompBuf *inbuf, int newx, int newy);
Modified: trunk/blender/source/blender/src/drawnode.c
===================================================================
--- trunk/blender/source/blender/src/drawnode.c 2008-03-08 11:12:05 UTC (rev 14013)
+++ trunk/blender/source/blender/src/drawnode.c 2008-03-08 19:02:08 UTC (rev 14014)
@@ -2694,6 +2694,168 @@
return TH_NODE;
}
+static void node_draw_link_bezier(float vec[][3], int th_col1, int th_col2, int do_shaded)
+{
+ float dist;
+
+ dist= 0.5f*ABS(vec[0][0] - vec[3][0]);
+
+ /* check direction later, for top sockets */
+ vec[1][0]= vec[0][0]+dist;
+ vec[1][1]= vec[0][1];
+
+ vec[2][0]= vec[3][0]-dist;
+ vec[2][1]= vec[3][1];
+
+ if( MIN4(vec[0][0], vec[1][0], vec[2][0], vec[3][0]) > G.v2d->cur.xmax); /* clipped */
+ else if ( MAX4(vec[0][0], vec[1][0], vec[2][0], vec[3][0]) < G.v2d->cur.xmin); /* clipped */
+ else {
+ float curve_res = 24, spline_step = 0.0f;
+
+ /* we can reuse the dist variable here to increment the GL curve eval amount*/
+ dist = 1.0f/curve_res;
+
+ glMap1f(GL_MAP1_VERTEX_3, 0.0, 1.0, 3, 4, vec[0]);
+ glBegin(GL_LINE_STRIP);
+ while (spline_step < 1.000001f) {
+ if(do_shaded)
+ BIF_ThemeColorBlend(th_col1, th_col2, spline_step);
+ glEvalCoord1f(spline_step);
+ spline_step += dist;
+ }
+ glEnd();
+ }
+
+}
+
+/* note; this is used for fake links in groups too */
+void node_draw_link(SpaceNode *snode, bNodeLink *link)
+{
+ float vec[4][3];
+ float mx=0.0f, my=0.0f;
+ int do_shaded= 1, th_col1= TH_WIRE, th_col2= TH_WIRE;
+
+ if(link->fromnode==NULL && link->tonode==NULL)
+ return;
+
+ /* this is dragging link */
+ if(link->fromnode==NULL || link->tonode==NULL) {
+ short mval[2];
+ getmouseco_areawin(mval);
+ areamouseco_to_ipoco(G.v2d, mval, &mx, &my);
+ BIF_ThemeColor(TH_WIRE);
+ do_shaded= 0;
+ }
+ else {
+ /* going to give issues once... */
+ if(link->tosock->flag & SOCK_UNAVAIL)
+ return;
+ if(link->fromsock->flag & SOCK_UNAVAIL)
+ return;
+
+ /* a bit ugly... but thats how we detect the internal group links */
+ if(link->fromnode==link->tonode) {
+ BIF_ThemeColorBlend(TH_BACK, TH_WIRE, 0.25f);
+ do_shaded= 0;
+ }
+ else {
+ /* check cyclic */
+ if(link->fromnode->level >= link->tonode->level && link->tonode->level!=0xFFF) {
+ if(link->fromnode->flag & SELECT)
+ th_col1= TH_EDGE_SELECT;
+ if(link->tonode->flag & SELECT)
+ th_col2= TH_EDGE_SELECT;
+ }
+ else {
+ BIF_ThemeColor(TH_REDALERT);
+ do_shaded= 0;
+ }
+ }
+ }
+
+ vec[0][2]= vec[1][2]= vec[2][2]= vec[3][2]= 0.0; /* only 2d spline, set the Z to 0*/
+
+ /* in v0 and v3 we put begin/end points */
+ if(link->fromnode) {
+ vec[0][0]= link->fromsock->locx;
+ vec[0][1]= link->fromsock->locy;
+ }
+ else {
+ vec[0][0]= mx;
+ vec[0][1]= my;
+ }
+ if(link->tonode) {
+ vec[3][0]= link->tosock->locx;
+ vec[3][1]= link->tosock->locy;
+ }
+ else {
+ vec[3][0]= mx;
+ vec[3][1]= my;
+ }
+
+ node_draw_link_bezier(vec, th_col1, th_col2, do_shaded);
+}
+
+
+/* note: in cmp_util.c is similar code, for node_compo_pass_on() */
+static void node_draw_mute_line(SpaceNode *snode, bNode *node)
+{
+ bNodeSocket *valsock= NULL, *colsock= NULL, *vecsock= NULL;
+ bNodeSocket *sock;
+ float vec[4][3];
+ int a;
+
+ vec[0][2]= vec[1][2]= vec[2][2]= vec[3][2]= 0.0; /* only 2d spline, set the Z to 0*/
+
+ /* connect the first value buffer in with first value out */
+ /* connect the first RGBA buffer in with first RGBA out */
+
+ /* test the inputs */
+ for(a=0, sock= node->inputs.first; sock; sock= sock->next, a++) {
+ if(nodeCountSocketLinks(snode->edittree, sock)) {
+ if(sock->type==SOCK_VALUE && valsock==NULL) valsock= sock;
+ if(sock->type==SOCK_VECTOR && vecsock==NULL) vecsock= sock;
+ if(sock->type==SOCK_RGBA && colsock==NULL) colsock= sock;
+ }
+ }
+
+ /* outputs, draw lines */
+ BIF_ThemeColor(TH_REDALERT);
+ glEnable(GL_BLEND);
+ glEnable( GL_LINE_SMOOTH );
+
+ if(valsock || colsock || vecsock) {
+ for(a=0, sock= node->outputs.first; sock; sock= sock->next, a++) {
+ if(nodeCountSocketLinks(snode->edittree, sock)) {
+ vec[3][0]= sock->locx;
+ vec[3][1]= sock->locy;
+
+ if(sock->type==SOCK_VALUE && valsock) {
+ vec[0][0]= valsock->locx;
+ vec[0][1]= valsock->locy;
+ node_draw_link_bezier(vec, TH_WIRE, TH_WIRE, 0);
+ valsock= NULL;
+ }
+ if(sock->type==SOCK_VECTOR && vecsock) {
+ vec[0][0]= vecsock->locx;
+ vec[0][1]= vecsock->locy;
+ node_draw_link_bezier(vec, TH_WIRE, TH_WIRE, 0);
+ vecsock= NULL;
+ }
+ if(sock->type==SOCK_RGBA && colsock) {
+ vec[0][0]= colsock->locx;
+ vec[0][1]= colsock->locy;
+ node_draw_link_bezier(vec, TH_WIRE, TH_WIRE, 0);
+ colsock= NULL;
+ }
+ }
+ }
+ }
+ glDisable(GL_BLEND);
+ glDisable( GL_LINE_SMOOTH );
+}
+
+
static void node_draw_basis(ScrArea *sa, SpaceNode *snode, bNode *node)
{
bNodeSocket *sock;
@@ -2702,7 +2864,7 @@
rctf *rct= &node->totr;
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list