diff options
Diffstat (limited to 'source/blender/nodes')
23 files changed, 354 insertions, 272 deletions
diff --git a/source/blender/nodes/composite/node_composite_util.c b/source/blender/nodes/composite/node_composite_util.c index 8012057b393..ab3a363e703 100644 --- a/source/blender/nodes/composite/node_composite_util.c +++ b/source/blender/nodes/composite/node_composite_util.c @@ -884,9 +884,8 @@ static void FHT2D(fREAL *data, unsigned int Mx, unsigned int My, #define PRED(k) (((k & Nym) << Mx) + (k >> My)) for (j=PRED(i); j>i; j=PRED(j)); if (j < i) continue; - for (k=i, j=PRED(i); j!=i; k=j, j=PRED(j), stm--) { - t=data[j], data[j]=data[k], data[k]=t; - } + for (k=i, j=PRED(i); j!=i; k=j, j=PRED(j), stm--) + { t=data[j], data[j]=data[k], data[k]=t; } #undef PRED stm--; } @@ -1109,7 +1108,7 @@ void qd_getPixel(CompBuf* src, int x, int y, float* col) float bc[4]; src->rect_procedural(src, bc, (float)x/(float)src->xrad, (float)y/(float)src->yrad); - switch (src->type) { + switch(src->type) { /* these fallthrough to get all the channels */ case CB_RGBA: col[3]=bc[3]; case CB_VEC3: col[2]=bc[2]; @@ -1119,7 +1118,7 @@ void qd_getPixel(CompBuf* src, int x, int y, float* col) } else if ((x >= 0) && (x < src->x) && (y >= 0) && (y < src->y)) { float* bc = &src->rect[(x + y*src->x)*src->type]; - switch (src->type) { + switch(src->type) { /* these fallthrough to get all the channels */ case CB_RGBA: col[3]=bc[3]; case CB_VEC3: col[2]=bc[2]; @@ -1128,7 +1127,7 @@ void qd_getPixel(CompBuf* src, int x, int y, float* col) } } else { - switch (src->type) { + switch(src->type) { /* these fallthrough to get all the channels */ case CB_RGBA: col[3]=0.0; case CB_VEC3: col[2]=0.0; @@ -1143,7 +1142,7 @@ void qd_setPixel(CompBuf* src, int x, int y, float* col) { if ((x >= 0) && (x < src->x) && (y >= 0) && (y < src->y)) { float* bc = &src->rect[(x + y*src->x)*src->type]; - switch (src->type) { + switch(src->type) { /* these fallthrough to get all the channels */ case CB_RGBA: bc[3]=col[3]; case CB_VEC3: bc[2]=col[2]; diff --git a/source/blender/nodes/composite/nodes/node_composite_channelMatte.c b/source/blender/nodes/composite/nodes/node_composite_channelMatte.c index b3690b5d20f..132b1659fa5 100644 --- a/source/blender/nodes/composite/nodes/node_composite_channelMatte.c +++ b/source/blender/nodes/composite/nodes/node_composite_channelMatte.c @@ -71,7 +71,7 @@ static void do_channel_matte(bNode *node, float *out, float *in) NodeChroma *c=(NodeChroma *)node->storage; float alpha=0.0; - switch (c->algorithm) { + switch(c->algorithm) { case 0: { /* Alpha=key_channel-limit channel */ int key_channel=node->custom2-1; int limit_channel=c->channel-1; @@ -79,7 +79,7 @@ static void do_channel_matte(bNode *node, float *out, float *in) break; } case 1: { /* Alpha=G-MAX(R, B) */ - switch (node->custom2) { + switch(node->custom2) { case 1: { alpha=in[0]-MAX2(in[1],in[2]); break; @@ -139,7 +139,7 @@ static void node_composit_exec_channel_matte(void *data, bNode *node, bNodeStack outbuf=dupalloc_compbuf(cbuf); /*convert to colorspace*/ - switch (node->custom1) { + switch(node->custom1) { case CMP_NODE_CHANNEL_MATTE_CS_RGB: break; case CMP_NODE_CHANNEL_MATTE_CS_HSV: /*HSV*/ @@ -159,7 +159,7 @@ static void node_composit_exec_channel_matte(void *data, bNode *node, bNodeStack composit1_pixel_processor(node, outbuf, outbuf, in[1]->vec, do_channel_matte, CB_RGBA); /*convert back to RGB colorspace in place*/ - switch (node->custom1) { + switch(node->custom1) { case CMP_NODE_CHANNEL_MATTE_CS_RGB: /*RGB*/ break; case CMP_NODE_CHANNEL_MATTE_CS_HSV: /*HSV*/ diff --git a/source/blender/nodes/composite/nodes/node_composite_chromaMatte.c b/source/blender/nodes/composite/nodes/node_composite_chromaMatte.c index 2df8e1b6139..571720e5d3a 100644 --- a/source/blender/nodes/composite/nodes/node_composite_chromaMatte.c +++ b/source/blender/nodes/composite/nodes/node_composite_chromaMatte.c @@ -1,33 +1,33 @@ /* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2006 Blender Foundation. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ +* ***** BEGIN GPL LICENSE BLOCK ***** +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software Foundation, +* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +* +* The Original Code is Copyright (C) 2006 Blender Foundation. +* All rights reserved. +* +* The Original Code is: all of this file. +* +* Contributor(s): none yet. +* +* ***** END GPL LICENSE BLOCK ***** +*/ /** \file blender/nodes/composite/nodes/node_composite_chromaMatte.c - * \ingroup cmpnodes - */ +* \ingroup cmpnodes +*/ #include "node_composite_util.h" @@ -59,9 +59,9 @@ static void do_rgba_to_ycca_normalized(bNode *UNUSED(node), float *out, float *i out[1]=(out[1]*2.0f)-1.0f; out[2]=(out[2]*2.0f)-1.0f; -// out[0]=((out[0])-16)/255.0; -// out[1]=((out[1])-128)/255.0; -// out[2]=((out[2])-128)/255.0; + // out[0]=((out[0])-16)/255.0; + // out[1]=((out[1])-128)/255.0; + // out[2]=((out[2])-128)/255.0; out[3]=in[3]; } @@ -77,8 +77,8 @@ static void do_ycca_to_rgba_normalized(bNode *UNUSED(node), float *out, float *i in[2]=(in[2]*255.0f); // in[0]=(in[0]*255.0)+16; -// in[1]=(in[1]*255.0)+128; -// in[2]=(in[2]*255.0)+128; + // in[1]=(in[1]*255.0)+128; + // in[2]=(in[2]*255.0)+128; ycc_to_rgb(in[0],in[1],in[2], &out[0], &out[1], &out[2], BLI_YCC_ITU_BT601); out[3]=in[3]; } @@ -94,7 +94,7 @@ static void do_chroma_key(bNode *node, float *out, float *in) /* Algorithm from book "Video Demistified," does not include the spill reduction part */ - /* find theta, the angle that the color space should be rotated based on key*/ + /* find theta, the angle that the color space should be rotated based on key chroma values*/ theta=atan2(c->key[2], c->key[1]); /*rotate the cb and cr into x/z space */ @@ -107,13 +107,9 @@ static void do_chroma_key(bNode *node, float *out, float *in) /* if kfg is <0 then the pixel is outside of the key color */ kfg= x-(fabsf(z)/tanf(angle/2.0f)); - out[0]=in[0]; - out[1]=in[1]; - out[2]=in[2]; + copy_v3_v3(out, in); if (kfg>0.0f) { /* found a pixel that is within key color */ - alpha=(1.0f-kfg)*(c->fstrength); - beta=atan2(z,x); angle2=c->t2; /* t2 is radians. */ @@ -121,6 +117,9 @@ static void do_chroma_key(bNode *node, float *out, float *in) if (fabsf(beta) < (angle2/2.0f)) { alpha=0.0; } + else { + alpha=1.0f-(kfg/c->fstrength); + } /* don't make something that was more transparent less transparent */ if (alpha<in[3]) { @@ -130,11 +129,8 @@ static void do_chroma_key(bNode *node, float *out, float *in) out[3]=in[3]; } } - else { /*pixel is outside key color */ - out[0]=in[0]; - out[1]=in[1]; - out[2]=in[2]; - out[3]=in[3]; /* make pixel just as transparent as it was before */ + else { /* make pixel just as transparent as it was before */ + out[3]=in[3]; } } @@ -143,32 +139,32 @@ static void node_composit_exec_chroma_matte(void *data, bNode *node, bNodeStack CompBuf *cbuf; CompBuf *chromabuf; NodeChroma *c; - + if (in[0]->hasinput==0) return; if (in[0]->data==NULL) return; if (out[0]->hasoutput==0 && out[1]->hasoutput==0) return; - + cbuf= typecheck_compbuf(in[0]->data, CB_RGBA); - + chromabuf= dupalloc_compbuf(cbuf); - + c=node->storage; - + /*convert rgbbuf to normalized chroma space*/ composit1_pixel_processor(node, chromabuf, cbuf, in[0]->vec, do_rgba_to_ycca_normalized, CB_RGBA); /*convert key to normalized chroma color space */ do_rgba_to_ycca_normalized(node, c->key, in[1]->vec); - + /*per pixel chroma key*/ composit1_pixel_processor(node, chromabuf, chromabuf, in[0]->vec, do_chroma_key, CB_RGBA); - + /*convert back*/ composit1_pixel_processor(node, chromabuf, chromabuf, in[0]->vec, do_ycca_to_rgba_normalized, CB_RGBA); - + out[0]->data= chromabuf; if (out[1]->hasoutput) out[1]->data= valbuf_from_rgbabuf(chromabuf, CHAN_A); - + generate_preview(data, node, chromabuf); if (cbuf!=in[0]->data) diff --git a/source/blender/nodes/composite/nodes/node_composite_colorSpill.c b/source/blender/nodes/composite/nodes/node_composite_colorSpill.c index 0153a2bce34..46d7c620aa8 100644 --- a/source/blender/nodes/composite/nodes/node_composite_colorSpill.c +++ b/source/blender/nodes/composite/nodes/node_composite_colorSpill.c @@ -206,10 +206,12 @@ static void node_composit_exec_color_spill(void *UNUSED(data), bNode *node, bNod spillmap=alloc_compbuf(cbuf->x, cbuf->y, CB_VAL, 1); rgbbuf=dupalloc_compbuf(cbuf); - switch (node->custom1) { + switch(node->custom1) + { case 1: /*red spill*/ { - switch (node->custom2) { + switch(node->custom2) + { case 0: /* simple limit */ { if ((in[1]->data==NULL) && (in[1]->vec[0] >= 1.f)) { @@ -241,7 +243,8 @@ static void node_composit_exec_color_spill(void *UNUSED(data), bNode *node, bNod } case 2: /*green spill*/ { - switch (node->custom2) { + switch(node->custom2) + { case 0: /* simple limit */ { if ((in[1]->data==NULL) && (in[1]->vec[0] >= 1.f)) { @@ -273,7 +276,8 @@ static void node_composit_exec_color_spill(void *UNUSED(data), bNode *node, bNod } case 3: /*blue spill*/ { - switch (node->custom2) { + switch(node->custom2) + { case 0: /* simple limit */ { if ((in[1]->data==NULL) && (in[1]->vec[0] >= 1.f)) { diff --git a/source/blender/nodes/composite/nodes/node_composite_diffMatte.c b/source/blender/nodes/composite/nodes/node_composite_diffMatte.c index 027786d8b22..5dea0e1c067 100644 --- a/source/blender/nodes/composite/nodes/node_composite_diffMatte.c +++ b/source/blender/nodes/composite/nodes/node_composite_diffMatte.c @@ -1,33 +1,33 @@ /* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2006 Blender Foundation. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): Bob Holcomb - * - * ***** END GPL LICENSE BLOCK ***** - */ +* ***** BEGIN GPL LICENSE BLOCK ***** +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software Foundation, +* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +* +* The Original Code is Copyright (C) 2006 Blender Foundation. +* All rights reserved. +* +* The Original Code is: all of this file. +* +* Contributor(s): Bob Holcomb +* +* ***** END GPL LICENSE BLOCK ***** +*/ /** \file blender/nodes/composite/nodes/node_composite_diffMatte.c - * \ingroup cmpnodes - */ +* \ingroup cmpnodes +*/ #include "node_composite_util.h" @@ -49,39 +49,42 @@ static void do_diff_matte(bNode *node, float *outColor, float *inColor1, float * { NodeChroma *c= (NodeChroma *)node->storage; float tolerence=c->t1; - float falloff=c->t2; + float fper=c->t2; + /* get falloff amount over tolerence size */ + float falloff=(1.0f-fper) * tolerence; float difference; float alpha; + float maxInputAlpha; + /* average together the distances */ difference= fabs(inColor2[0]-inColor1[0]) + - fabs(inColor2[1]-inColor1[1]) + - fabs(inColor2[2]-inColor1[2]); - - /*average together the distances*/ + fabs(inColor2[1]-inColor1[1]) + + fabs(inColor2[2]-inColor1[2]); difference=difference/3.0f; copy_v3_v3(outColor, inColor1); - /*make 100% transparent*/ - if (difference < tolerence) { - outColor[3]=0.0; - } - /*in the falloff region, make partially transparent */ - else if (difference < falloff+tolerence) { - difference=difference-tolerence; - alpha=difference/falloff; - /*only change if more transparent than before */ - if (alpha < inColor1[3]) { + if (difference <= tolerence) { + if(difference<=falloff) { + alpha=0.0f; + } + else{ + /* alpha as percent (distance / tolerance), each modified by falloff amount (in pixels)*/ + alpha=(difference-falloff)/(tolerence-falloff); + } + + /*only change if more transparent than either image */ + maxInputAlpha=maxf(inColor1[3], inColor2[3]); + if (alpha < maxInputAlpha) { + /*clamp*/ + if(alpha<0.0f) alpha=0.0f; + if(alpha>1.0f) alpha=1.0f; outColor[3]=alpha; } else { /* leave as before */ - outColor[3]=inColor1[3]; + outColor[3]=maxInputAlpha; } } - else { - /*foreground object*/ - outColor[3]= inColor1[3]; - } } static void node_composit_exec_diff_matte(void *data, bNode *node, bNodeStack **in, bNodeStack **out) diff --git a/source/blender/nodes/composite/nodes/node_composite_distanceMatte.c b/source/blender/nodes/composite/nodes/node_composite_distanceMatte.c index 7aaaa7ed9b4..74e058292d3 100644 --- a/source/blender/nodes/composite/nodes/node_composite_distanceMatte.c +++ b/source/blender/nodes/composite/nodes/node_composite_distanceMatte.c @@ -1,33 +1,33 @@ /* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2006 Blender Foundation. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): Bob Holcomb - * - * ***** END GPL LICENSE BLOCK ***** - */ +* ***** BEGIN GPL LICENSE BLOCK ***** +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software Foundation, +* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +* +* The Original Code is Copyright (C) 2006 Blender Foundation. +* All rights reserved. +* +* The Original Code is: all of this file. +* +* Contributor(s): Bob Holcomb +* +* ***** END GPL LICENSE BLOCK ***** +*/ /** \file blender/nodes/composite/nodes/node_composite_distanceMatte.c - * \ingroup cmpnodes - */ +* \ingroup cmpnodes +*/ #include "node_composite_util.h" @@ -51,34 +51,88 @@ static void do_distance_matte(bNode *node, float *out, float *in) { NodeChroma *c= (NodeChroma *)node->storage; float tolerence=c->t1; - float falloff=c->t2; + float fper=c->t2; + /* get falloff amount over tolerence size */ + float falloff=(1.0f-fper) * tolerence; float distance; float alpha; distance=sqrt((c->key[0]-in[0])*(c->key[0]-in[0]) + - (c->key[1]-in[1])*(c->key[1]-in[1]) + - (c->key[2]-in[2])*(c->key[2]-in[2])); + (c->key[1]-in[1])*(c->key[1]-in[1]) + + (c->key[2]-in[2])*(c->key[2]-in[2])); copy_v3_v3(out, in); - /*make 100% transparent */ - if (distance < tolerence) { - out[3]=0.0; - } - /*in the falloff region, make partially transparent */ - else if (distance < falloff+tolerence) { - distance=distance-tolerence; - alpha=distance/falloff; + if (distance <= tolerence) { + if(distance<=falloff) { + alpha=0.0f; + } + else{ + /* alpha as percent (distance / tolerance), each modified by falloff amount (in pixels)*/ + alpha=(distance-falloff)/(tolerence-falloff); + } + /*only change if more transparent than before */ if (alpha < in[3]) { + /*clamp*/ + if(alpha<0.0f) alpha=0.0f; + if(alpha>1.0f) alpha=1.0f; out[3]=alpha; } else { /* leave as before */ out[3]=in[3]; } } - else { - out[3]=in[3]; +} + +static void do_chroma_distance_matte(bNode *node, float *out, float *in) +{ + NodeChroma *c= (NodeChroma *)node->storage; + float tolerence=c->t1; + float fper=c->t2; + /* get falloff amount over tolerence size */ + float falloff=(1.0f-fper) * tolerence; + float y_key, cb_key, cr_key; + float y_pix, cb_pix, cr_pix; + float distance; + float alpha; + + /*convert key to chroma colorspace */ + rgb_to_ycc(c->key[0], c->key[1], c->key[2], &y_key, &cb_key, &cr_key, BLI_YCC_JFIF_0_255); + /* normalize the values */ + cb_key=cb_key/255.0f; + cr_key=cr_key/255.0f; + + /*convert pixel to chroma colorspace */ + rgb_to_ycc(in[0], in[1], in[2], &y_pix, &cb_pix, &cr_pix, BLI_YCC_JFIF_0_255); + /*normalize the values */ + cb_pix=cb_pix/255.0f; + cr_pix=cr_pix/255.0f; + + distance=sqrt((cb_key-cb_pix)*(cb_key-cb_pix) + + (cr_key-cr_pix)*(cr_key-cr_pix)); + + copy_v3_v3(out, in); + + if (distance <= tolerence) { + if(distance<=falloff) { + alpha=0.0f; + } + else{ + /* alpha as percent (distance / tolerance), each modified by falloff amount (in pixels)*/ + alpha=(distance-falloff)/(tolerence-falloff); + } + + /*only change if more transparent than before */ + if (alpha < in[3]) { + /*clamp*/ + if(alpha<0.0f) alpha=0.0f; + if(alpha>1.0f) alpha=1.0f; + out[3]=alpha; + } + else { /* leave as before */ + out[3]=in[3]; + } } } @@ -91,26 +145,34 @@ static void node_composit_exec_distance_matte(void *data, bNode *node, bNodeStac CompBuf *workbuf; CompBuf *inbuf; NodeChroma *c; - + /*is anything connected?*/ if (out[0]->hasoutput==0 && out[1]->hasoutput==0) return; /*must have an image imput*/ if (in[0]->data==NULL) return; - + inbuf=typecheck_compbuf(in[0]->data, CB_RGBA); - + c=node->storage; workbuf=dupalloc_compbuf(inbuf); - + /*use the input color*/ c->key[0]= in[1]->vec[0]; c->key[1]= in[1]->vec[1]; c->key[2]= in[1]->vec[2]; - - /* note, processor gets a keyvals array passed on as buffer constant */ - composit1_pixel_processor(node, workbuf, workbuf, in[0]->vec, do_distance_matte, CB_RGBA); - - + + /* work in RGB color space */ + if(c->channel==1) { + /* note, processor gets a keyvals array passed on as buffer constant */ + composit1_pixel_processor(node, workbuf, workbuf, in[0]->vec, do_distance_matte, CB_RGBA); + } + /* work in YCbCr color space */ + else { + composit1_pixel_processor(node, workbuf, workbuf, in[0]->vec, do_chroma_distance_matte, CB_RGBA); + } + + + out[0]->data=workbuf; if (out[1]->hasoutput) out[1]->data=valbuf_from_rgbabuf(workbuf, CHAN_A); @@ -124,6 +186,7 @@ static void node_composit_init_distance_matte(bNodeTree *UNUSED(ntree), bNode* n { NodeChroma *c= MEM_callocN(sizeof(NodeChroma), "node chroma"); node->storage= c; + c->channel=1; c->t1= 0.1f; c->t2= 0.1f; } diff --git a/source/blender/nodes/composite/nodes/node_composite_filter.c b/source/blender/nodes/composite/nodes/node_composite_filter.c index d6cb54eb944..6d470467cb0 100644 --- a/source/blender/nodes/composite/nodes/node_composite_filter.c +++ b/source/blender/nodes/composite/nodes/node_composite_filter.c @@ -189,7 +189,7 @@ static void node_composit_exec_filter(void *data, bNode *node, bNodeStack **in, stackbuf->xof= cbuf->xof; stackbuf->yof= cbuf->yof; - switch (node->custom1) { + switch(node->custom1) { case CMP_FILT_SOFT: do_filter3(stackbuf, cbuf, soft, in[0]->vec[0]); break; diff --git a/source/blender/nodes/composite/nodes/node_composite_image.c b/source/blender/nodes/composite/nodes/node_composite_image.c index 62179cfa471..6a156c390a7 100644 --- a/source/blender/nodes/composite/nodes/node_composite_image.c +++ b/source/blender/nodes/composite/nodes/node_composite_image.c @@ -442,14 +442,11 @@ static void node_composit_exec_image(void *data, bNode *node, bNodeStack **UNUSE /* preview policy: take first 'Combined' pass if available, * otherwise just use the first layer. */ - if (!firstbuf) { + if (!firstbuf) firstbuf = stackbuf; - } if (!combinedbuf && - (strcmp(sock->name, "Combined") == 0 || strcmp(sock->name, "Image") == 0)) - { + (strcmp(sock->name, "Combined")==0 || strcmp(sock->name, "Image")==0)) combinedbuf = stackbuf; - } } } } diff --git a/source/blender/nodes/composite/nodes/node_composite_levels.c b/source/blender/nodes/composite/nodes/node_composite_levels.c index 32b07582140..ec6d2006296 100644 --- a/source/blender/nodes/composite/nodes/node_composite_levels.c +++ b/source/blender/nodes/composite/nodes/node_composite_levels.c @@ -64,7 +64,7 @@ static void fill_bins(bNode* node, CompBuf* in, int* bins) qd_getPixel(in, x, y, value); if (value[3] > 0.0f) { /* don't count transparent pixels */ - switch (node->custom1) { + switch(node->custom1) { case 1: { /* all colors */ rgb_tobw(value[0],value[1],value[2], &value[0]); value[0]=value[0]*255; /* scale to 0-255 range */ @@ -122,7 +122,8 @@ static float brightness_mean(bNode* node, CompBuf* in) if (value[3] > 0.0f) { /* don't count transparent pixels */ numPixels++; - switch (node->custom1) { + switch(node->custom1) + { case 1: { rgb_tobw(value[0],value[1],value[2], &value[0]); @@ -173,7 +174,8 @@ static float brightness_standard_deviation(bNode* node, CompBuf* in, float mean) if (value[3] > 0.0f) { /* don't count transparent pixels */ numPixels++; - switch (node->custom1) { + switch(node->custom1) + { case 1: { rgb_tobw(value[0],value[1],value[2], &value[0]); diff --git a/source/blender/nodes/composite/nodes/node_composite_math.c b/source/blender/nodes/composite/nodes/node_composite_math.c index 4c9d1a66fb0..8362df1b691 100644 --- a/source/blender/nodes/composite/nodes/node_composite_math.c +++ b/source/blender/nodes/composite/nodes/node_composite_math.c @@ -46,7 +46,8 @@ static bNodeSocketTemplate cmp_node_math_out[]= { static void do_math(bNode *node, float *out, float *in, float *in2) { - switch (node->custom1) { + switch(node->custom1) + { case 0: /* Add */ out[0]= in[0] + in2[0]; break; diff --git a/source/blender/nodes/composite/nodes/node_composite_movieclip.c b/source/blender/nodes/composite/nodes/node_composite_movieclip.c index 2f017b52676..dd2c169fe9a 100644 --- a/source/blender/nodes/composite/nodes/node_composite_movieclip.c +++ b/source/blender/nodes/composite/nodes/node_composite_movieclip.c @@ -33,7 +33,7 @@ #include "node_composite_util.h" -static bNodeSocketTemplate cmp_node_movieclip_out[] = { +static bNodeSocketTemplate cmp_node_movieclip_out[]= { { SOCK_RGBA, 0, "Image"}, { SOCK_FLOAT, 1, "Offset X"}, { SOCK_FLOAT, 1, "Offset Y"}, @@ -49,50 +49,50 @@ static CompBuf *node_composit_get_movieclip(RenderData *rd, MovieClip *clip, Mov int type; float *rect; - int alloc = FALSE; + int alloc= FALSE; - orig_ibuf = BKE_movieclip_get_ibuf(clip, user); + orig_ibuf= BKE_movieclip_get_ibuf(clip, user); - if (orig_ibuf == NULL || (orig_ibuf->rect == NULL && orig_ibuf->rect_float == NULL)) { + if (orig_ibuf==NULL || (orig_ibuf->rect==NULL && orig_ibuf->rect_float==NULL)) { IMB_freeImBuf(orig_ibuf); return NULL; } - ibuf = IMB_dupImBuf(orig_ibuf); + ibuf= IMB_dupImBuf(orig_ibuf); IMB_freeImBuf(orig_ibuf); - if (ibuf->rect_float == NULL || (ibuf->userflags & IB_RECT_INVALID)) { + if (ibuf->rect_float == NULL || ibuf->userflags&IB_RECT_INVALID) { IMB_float_from_rect(ibuf); - ibuf->userflags &= ~IB_RECT_INVALID; + ibuf->userflags&= ~IB_RECT_INVALID; } /* now we need a float buffer from the image with matching color management */ if (ibuf->channels == 4) { - rect = node_composit_get_float_buffer(rd, ibuf, &alloc); + rect= node_composit_get_float_buffer(rd, ibuf, &alloc); } else { /* non-rgba passes can't use color profiles */ - rect = ibuf->rect_float; + rect= ibuf->rect_float; } /* done coercing into the correct color management */ if (!alloc) { - rect = MEM_dupallocN(rect); - alloc = TRUE; + rect= MEM_dupallocN(rect); + alloc= 1; } - type = ibuf->channels; + type= ibuf->channels; if (rd->scemode & R_COMP_CROP) { - stackbuf = get_cropped_compbuf(&rd->disprect, rect, ibuf->x, ibuf->y, type); + stackbuf= get_cropped_compbuf(&rd->disprect, rect, ibuf->x, ibuf->y, type); if (alloc) MEM_freeN(rect); } else { /* we put imbuf copy on stack, cbuf knows rect is from other ibuf when freed! */ - stackbuf = alloc_compbuf(ibuf->x, ibuf->y, type, FALSE); - stackbuf->rect = rect; - stackbuf->malloc = alloc; + stackbuf= alloc_compbuf(ibuf->x, ibuf->y, type, FALSE); + stackbuf->rect= rect; + stackbuf->malloc= alloc; } IMB_freeImBuf(ibuf); @@ -103,32 +103,32 @@ static CompBuf *node_composit_get_movieclip(RenderData *rd, MovieClip *clip, Mov static void node_composit_exec_movieclip(void *data, bNode *node, bNodeStack **UNUSED(in), bNodeStack **out) { if (node->id) { - RenderData *rd = data; - MovieClip *clip = (MovieClip *)node->id; - MovieClipUser *user = (MovieClipUser *)node->storage; - CompBuf *stackbuf = NULL; + RenderData *rd= data; + MovieClip *clip= (MovieClip *)node->id; + MovieClipUser *user= (MovieClipUser *)node->storage; + CompBuf *stackbuf= NULL; BKE_movieclip_user_set_frame(user, rd->cfra); - stackbuf = node_composit_get_movieclip(rd, clip, user); + stackbuf= node_composit_get_movieclip(rd, clip, user); if (stackbuf) { - MovieTrackingStabilization *stab = &clip->tracking.stabilization; + MovieTrackingStabilization *stab= &clip->tracking.stabilization; /* put image on stack */ - out[0]->data = stackbuf; + out[0]->data= stackbuf; - if (stab->flag & TRACKING_2D_STABILIZATION) { + if (stab->flag&TRACKING_2D_STABILIZATION) { float loc[2], scale, angle; BKE_tracking_stabilization_data(&clip->tracking, rd->cfra, stackbuf->x, stackbuf->y, loc, &scale, &angle); - out[1]->vec[0] = loc[0]; - out[2]->vec[0] = loc[1]; + out[1]->vec[0]= loc[0]; + out[2]->vec[0]= loc[1]; - out[3]->vec[0] = scale; - out[4]->vec[0] = angle; + out[3]->vec[0]= scale; + out[4]->vec[0]= angle; } /* generate preview */ @@ -139,10 +139,10 @@ static void node_composit_exec_movieclip(void *data, bNode *node, bNodeStack **U static void init(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp)) { - MovieClipUser *user = MEM_callocN(sizeof(MovieClipUser), "node movie clip user"); + MovieClipUser *user= MEM_callocN(sizeof(MovieClipUser), "node movie clip user"); - node->storage = user; - user->framenr = 1; + node->storage= user; + user->framenr= 1; } void register_node_type_cmp_movieclip(bNodeTreeType *ttype) diff --git a/source/blender/nodes/composite/nodes/node_composite_moviedistortion.c b/source/blender/nodes/composite/nodes/node_composite_moviedistortion.c index f6ffc783b08..d9f0da9b8aa 100644 --- a/source/blender/nodes/composite/nodes/node_composite_moviedistortion.c +++ b/source/blender/nodes/composite/nodes/node_composite_moviedistortion.c @@ -4,7 +4,7 @@ * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -37,12 +37,12 @@ /* **************** Translate ******************** */ -static bNodeSocketTemplate cmp_node_moviedistortion_in[] = { +static bNodeSocketTemplate cmp_node_moviedistortion_in[]= { { SOCK_RGBA, 1, "Image", 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f}, { -1, 0, "" } }; -static bNodeSocketTemplate cmp_node_moviedistortion_out[] = { +static bNodeSocketTemplate cmp_node_moviedistortion_out[]= { { SOCK_RGBA, 0, "Image"}, { -1, 0, "" } }; @@ -51,63 +51,63 @@ static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) { if (in[0]->data) { if (node->id) { - MovieClip *clip = (MovieClip *)node->id; - CompBuf *cbuf = typecheck_compbuf(in[0]->data, CB_RGBA); - CompBuf *stackbuf = alloc_compbuf(cbuf->x, cbuf->y, CB_RGBA, 0); + MovieClip *clip= (MovieClip *)node->id; + CompBuf *cbuf= typecheck_compbuf(in[0]->data, CB_RGBA); + CompBuf *stackbuf= alloc_compbuf(cbuf->x, cbuf->y, CB_RGBA, 0); ImBuf *ibuf; - ibuf = IMB_allocImBuf(cbuf->x, cbuf->y, 32, 0); + ibuf= IMB_allocImBuf(cbuf->x, cbuf->y, 32, 0); if (ibuf) { - RenderData *rd = data; + RenderData *rd= data; ImBuf *obuf; - MovieTracking *tracking = &clip->tracking; + MovieTracking *tracking= &clip->tracking; int width, height; - float overscan = 0.0f; - MovieClipUser user = {0}; + float overscan= 0.0f; + MovieClipUser user= {0}; BKE_movieclip_user_set_frame(&user, rd->cfra); - ibuf->rect_float = cbuf->rect; + ibuf->rect_float= cbuf->rect; BKE_movieclip_get_size(clip, &user, &width, &height); if (!node->storage) - node->storage = BKE_tracking_distortion_create(); + node->storage= BKE_tracking_distortion_create(); - if (node->custom1 == 0) + if (node->custom1==0) obuf= BKE_tracking_distortion_exec(node->storage, tracking, ibuf, width, height, overscan, 1); else obuf= BKE_tracking_distortion_exec(node->storage, tracking, ibuf, width, height, overscan, 0); - stackbuf->rect = obuf->rect_float; - stackbuf->malloc = TRUE; + stackbuf->rect= obuf->rect_float; + stackbuf->malloc= 1; - obuf->mall &= ~IB_rectfloat; - obuf->rect_float = NULL; + obuf->mall&= ~IB_rectfloat; + obuf->rect_float= NULL; IMB_freeImBuf(ibuf); IMB_freeImBuf(obuf); } /* pass on output and free */ - out[0]->data = stackbuf; + out[0]->data= stackbuf; - if (cbuf != in[0]->data) + if (cbuf!=in[0]->data) free_compbuf(cbuf); } else { - CompBuf *cbuf = in[0]->data; - CompBuf *stackbuf = pass_on_compbuf(cbuf); + CompBuf *cbuf= in[0]->data; + CompBuf *stackbuf= pass_on_compbuf(cbuf); - out[0]->data = stackbuf; + out[0]->data= stackbuf; } } } static const char *label(bNode *node) { - if (node->custom1 == 0) + if (node->custom1==0) return IFACE_("Undistortion"); else return IFACE_("Distortion"); @@ -124,7 +124,7 @@ static void storage_free(bNode *node) static void storage_copy(bNode *orig_node, bNode *new_node) { if (orig_node->storage) - new_node->storage = BKE_tracking_distortion_copy(orig_node->storage); + new_node->storage= BKE_tracking_distortion_copy(orig_node->storage); } void register_node_type_cmp_moviedistortion(bNodeTreeType *ttype) diff --git a/source/blender/nodes/composite/nodes/node_composite_rotate.c b/source/blender/nodes/composite/nodes/node_composite_rotate.c index 8268977658d..6952817248d 100644 --- a/source/blender/nodes/composite/nodes/node_composite_rotate.c +++ b/source/blender/nodes/composite/nodes/node_composite_rotate.c @@ -87,7 +87,7 @@ static void node_composit_exec_rotate(void *UNUSED(data), bNode *node, bNodeStac v=-s*x + c*y + centy; xo= x+(int)centx; - switch (node->custom1) { + switch(node->custom1) { case 0: neareast_interpolation(ibuf, obuf, u, v, xo, yo); break; diff --git a/source/blender/nodes/composite/nodes/node_composite_sepcombYCCA.c b/source/blender/nodes/composite/nodes/node_composite_sepcombYCCA.c index 6eff3dcd95b..b12f08bb13d 100644 --- a/source/blender/nodes/composite/nodes/node_composite_sepcombYCCA.c +++ b/source/blender/nodes/composite/nodes/node_composite_sepcombYCCA.c @@ -91,7 +91,8 @@ static void node_composit_exec_sepycca(void *UNUSED(data), bNode *node, bNodeSta if (in[0]->data==NULL) { float y, cb, cr; - switch (node->custom1) { + switch(node->custom1) + { case 1: rgb_to_ycc(in[0]->vec[0], in[0]->vec[1], in[0]->vec[2], &y, &cb, &cr, BLI_YCC_ITU_BT709); break; @@ -116,7 +117,8 @@ static void node_composit_exec_sepycca(void *UNUSED(data), bNode *node, bNodeSta CompBuf *cbuf2=typecheck_compbuf(cbuf, CB_RGBA); /* convert the RGB stackbuf to an HSV representation */ - switch (node->custom1) { + switch(node->custom1) + { case 1: composit1_pixel_processor(node, cbuf2, cbuf2, in[0]->vec, do_sepycca_709, CB_RGBA); break; @@ -238,7 +240,8 @@ static void node_composit_exec_combycca(void *UNUSED(data), bNode *node, bNodeSt float cb = in[1]->vec[0] * 255; float cr = in[2]->vec[0] * 255; - switch (node->custom1) { + switch(node->custom1) + { case 1: ycc_to_rgb(y, cb, cr, &out[0]->vec[0], &out[0]->vec[1], &out[0]->vec[2], BLI_YCC_ITU_BT709); break; @@ -267,7 +270,8 @@ static void node_composit_exec_combycca(void *UNUSED(data), bNode *node, bNodeSt stackbuf = alloc_compbuf(cbuf->x, cbuf->y, CB_RGBA, 1); /* allocs */ - switch (node->custom1) { + switch(node->custom1) + { case 1: composit4_pixel_processor(node, stackbuf, in[0]->data, in[0]->vec, in[1]->data, in[1]->vec, in[2]->data, in[2]->vec, in[3]->data, in[3]->vec, diff --git a/source/blender/nodes/composite/nodes/node_composite_stabilize2d.c b/source/blender/nodes/composite/nodes/node_composite_stabilize2d.c index e5d8fe16d51..0eac85c4030 100644 --- a/source/blender/nodes/composite/nodes/node_composite_stabilize2d.c +++ b/source/blender/nodes/composite/nodes/node_composite_stabilize2d.c @@ -48,20 +48,20 @@ static bNodeSocketTemplate cmp_node_stabilize2d_out[]= { static void node_composit_exec_stabilize2d(void *data, bNode *node, bNodeStack **in, bNodeStack **out) { if (in[0]->data && node->id) { - RenderData *rd = data; - MovieClip *clip = (MovieClip *)node->id; - CompBuf *cbuf = typecheck_compbuf(in[0]->data, CB_RGBA); + RenderData *rd= data; + MovieClip *clip= (MovieClip *)node->id; + CompBuf *cbuf= typecheck_compbuf(in[0]->data, CB_RGBA); CompBuf *stackbuf; float loc[2], scale, angle; BKE_tracking_stabilization_data(&clip->tracking, rd->cfra, cbuf->x, cbuf->y, loc, &scale, &angle); - stackbuf = node_composit_transform(cbuf, loc[0], loc[1], angle, scale, node->custom1); + stackbuf= node_composit_transform(cbuf, loc[0], loc[1], angle, scale, node->custom1); /* pass on output and free */ - out[0]->data = stackbuf; + out[0]->data= stackbuf; - if (cbuf != in[0]->data) + if (cbuf!=in[0]->data) free_compbuf(cbuf); } } diff --git a/source/blender/nodes/composite/nodes/node_composite_transform.c b/source/blender/nodes/composite/nodes/node_composite_transform.c index 2c2a352017a..a610d8a66c4 100644 --- a/source/blender/nodes/composite/nodes/node_composite_transform.c +++ b/source/blender/nodes/composite/nodes/node_composite_transform.c @@ -4,7 +4,7 @@ * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -34,7 +34,7 @@ /* **************** Transform ******************** */ -static bNodeSocketTemplate cmp_node_transform_in[] = { +static bNodeSocketTemplate cmp_node_transform_in[]= { { SOCK_RGBA, 1, "Image", 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f}, { SOCK_FLOAT, 1, "X", 0.0f, 0.0f, 0.0f, 0.0f, -10000.0f, 10000.0f}, { SOCK_FLOAT, 1, "Y", 0.0f, 0.0f, 0.0f, 0.0f, -10000.0f, 10000.0f}, @@ -43,17 +43,17 @@ static bNodeSocketTemplate cmp_node_transform_in[] = { { -1, 0, "" } }; -static bNodeSocketTemplate cmp_node_transform_out[] = { +static bNodeSocketTemplate cmp_node_transform_out[]= { { SOCK_RGBA, 0, "Image"}, { -1, 0, "" } }; CompBuf* node_composit_transform(CompBuf *cbuf, float x, float y, float angle, float scale, int filter_type) { - CompBuf *stackbuf = alloc_compbuf(cbuf->x, cbuf->y, CB_RGBA, TRUE); + CompBuf *stackbuf= alloc_compbuf(cbuf->x, cbuf->y, CB_RGBA, 1); ImBuf *ibuf, *obuf; float mat[4][4], lmat[4][4], rmat[4][4], smat[4][4], cmat[4][4], icmat[4][4]; - float svec[3] = {scale, scale, scale}, loc[2] = {x, y}; + float svec[3]= {scale, scale, scale}, loc[2]= {x, y}; unit_m4(rmat); unit_m4(lmat); @@ -61,8 +61,8 @@ CompBuf* node_composit_transform(CompBuf *cbuf, float x, float y, float angle, f unit_m4(cmat); /* image center as rotation center */ - cmat[3][0] = (float)cbuf->x/2.0f; - cmat[3][1] = (float)cbuf->y/2.0f; + cmat[3][0]= (float)cbuf->x/2.0f; + cmat[3][1]= (float)cbuf->y/2.0f; invert_m4_m4(icmat, cmat); size_to_mat4(smat, svec); /* scale matrix */ @@ -74,22 +74,22 @@ CompBuf* node_composit_transform(CompBuf *cbuf, float x, float y, float angle, f invert_m4(mat); - ibuf = IMB_allocImBuf(cbuf->x, cbuf->y, 32, 0); - obuf = IMB_allocImBuf(stackbuf->x, stackbuf->y, 32, 0); + ibuf= IMB_allocImBuf(cbuf->x, cbuf->y, 32, 0); + obuf= IMB_allocImBuf(stackbuf->x, stackbuf->y, 32, 0); if (ibuf && obuf) { int i, j; - ibuf->rect_float = cbuf->rect; - obuf->rect_float = stackbuf->rect; + ibuf->rect_float= cbuf->rect; + obuf->rect_float= stackbuf->rect; - for (j = 0; j < cbuf->y; j++) { - for (i = 0; i < cbuf->x; i++) { - float vec[3] = {i, j, 0}; + for (j=0; j<cbuf->y; j++) { + for (i=0; i<cbuf->x;i++) { + float vec[3]= {i, j, 0}; mul_v3_m4v3(vec, mat, vec); - switch (filter_type) { + switch(filter_type) { case 0: neareast_interpolation(ibuf, obuf, vec[0], vec[1], i, j); break; @@ -114,15 +114,15 @@ CompBuf* node_composit_transform(CompBuf *cbuf, float x, float y, float angle, f static void node_composit_exec_transform(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out) { if (in[0]->data) { - CompBuf *cbuf = typecheck_compbuf(in[0]->data, CB_RGBA); + CompBuf *cbuf= typecheck_compbuf(in[0]->data, CB_RGBA); CompBuf *stackbuf; - stackbuf = node_composit_transform(cbuf, in[1]->vec[0], in[2]->vec[0], in[3]->vec[0], in[4]->vec[0], node->custom1); + stackbuf= node_composit_transform(cbuf, in[1]->vec[0], in[2]->vec[0], in[3]->vec[0], in[4]->vec[0], node->custom1); /* pass on output and free */ - out[0]->data = stackbuf; + out[0]->data= stackbuf; - if (cbuf != in[0]->data) + if (cbuf!=in[0]->data) free_compbuf(cbuf); } } diff --git a/source/blender/nodes/intern/node_common.c b/source/blender/nodes/intern/node_common.c index 362ed59a38e..6e61dc483b4 100644 --- a/source/blender/nodes/intern/node_common.c +++ b/source/blender/nodes/intern/node_common.c @@ -551,7 +551,8 @@ static bNodeSocket *group_verify_socket(bNodeTree *ntree, ListBase *lb, int in_o sock->groupsock = gsock; BLI_strncpy(sock->name, gsock->name, sizeof(sock->name)); - sock->type= gsock->type; + if(gsock->type != sock->type) + nodeSocketSetType(sock, gsock->type); /* XXX hack: group socket input/output roles are inverted internally, * need to change the limit value when making actual node sockets from them. diff --git a/source/blender/nodes/shader/node_shader_util.c b/source/blender/nodes/shader/node_shader_util.c index 9a9a27603dc..90c62bc47ac 100644 --- a/source/blender/nodes/shader/node_shader_util.c +++ b/source/blender/nodes/shader/node_shader_util.c @@ -101,7 +101,7 @@ void ntreeShaderGetTexcoMode(bNodeTree *ntree, int r_mode, short *texco, int *mo /* note; sockets always exist for the given type! */ for (a=0, sock= node->outputs.first; sock; sock= sock->next, a++) { if (sock->flag & SOCK_IN_USE) { - switch (a) { + switch(a) { case GEOM_OUT_GLOB: *texco |= TEXCO_GLOB|NEED_UV; break; case GEOM_OUT_VIEW: @@ -137,7 +137,7 @@ void nodeShaderSynchronizeID(bNode *node, int copyto) for (a=0, sock= node->inputs.first; sock; sock= sock->next, a++) { if (!nodeSocketIsHidden(sock)) { if (copyto) { - switch (a) { + switch(a) { case MAT_IN_COLOR: copy_v3_v3(&ma->r, ((bNodeSocketValueRGBA*)sock->default_value)->value); break; case MAT_IN_SPEC: @@ -161,7 +161,7 @@ void nodeShaderSynchronizeID(bNode *node, int copyto) } } else { - switch (a) { + switch(a) { case MAT_IN_COLOR: copy_v3_v3(((bNodeSocketValueRGBA*)sock->default_value)->value, &ma->r); break; case MAT_IN_SPEC: diff --git a/source/blender/nodes/shader/nodes/node_shader_common.c b/source/blender/nodes/shader/nodes/node_shader_common.c index f75cecfe83b..df369482a2e 100644 --- a/source/blender/nodes/shader/nodes/node_shader_common.c +++ b/source/blender/nodes/shader/nodes/node_shader_common.c @@ -73,6 +73,9 @@ static void *group_initexec(bNode *node) bNodeTree *ngroup= (bNodeTree*)node->id; bNodeTreeExec *exec; + if (!ngroup) + return NULL; + /* initialize the internal node tree execution */ exec = ntreeShaderBeginExecTree(ngroup, 0); @@ -121,6 +124,9 @@ static void group_execute(void *data, int thread, struct bNode *node, void *node bNodeTreeExec *exec= (bNodeTreeExec*)nodedata; bNodeThreadStack *nts; + if (!exec) + return; + /* XXX same behavior as trunk: all nodes inside group are executed. * it's stupid, but just makes it work. compo redesign will do this better. */ diff --git a/source/blender/nodes/shader/nodes/node_shader_math.c b/source/blender/nodes/shader/nodes/node_shader_math.c index db2b57ab51b..44df496f5d6 100644 --- a/source/blender/nodes/shader/nodes/node_shader_math.c +++ b/source/blender/nodes/shader/nodes/node_shader_math.c @@ -48,7 +48,7 @@ static bNodeSocketTemplate sh_node_math_out[]= { static void node_shader_exec_math(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out) { - switch (node->custom1) { + switch(node->custom1) { case 0: /* Add */ out[0]->vec[0]= in[0]->vec[0] + in[1]->vec[0]; diff --git a/source/blender/nodes/texture/nodes/node_texture_common.c b/source/blender/nodes/texture/nodes/node_texture_common.c index 9a66ecb5ffb..1eaf9b2b0fe 100644 --- a/source/blender/nodes/texture/nodes/node_texture_common.c +++ b/source/blender/nodes/texture/nodes/node_texture_common.c @@ -58,6 +58,9 @@ static void *group_initexec(bNode *node) bNodeTree *ngroup= (bNodeTree*)node->id; void *exec; + if (!ngroup) + return NULL; + /* initialize the internal node tree execution */ exec = ntreeTexBeginExecTree(ngroup, 0); @@ -107,6 +110,9 @@ static void group_execute(void *data, int thread, struct bNode *node, void *node bNodeTreeExec *exec= (bNodeTreeExec*)nodedata; bNodeThreadStack *nts; + if (!exec) + return; + /* XXX same behavior as trunk: all nodes inside group are executed. * it's stupid, but just makes it work. compo redesign will do this better. */ diff --git a/source/blender/nodes/texture/nodes/node_texture_math.c b/source/blender/nodes/texture/nodes/node_texture_math.c index 54c9645fac3..29d154df884 100644 --- a/source/blender/nodes/texture/nodes/node_texture_math.c +++ b/source/blender/nodes/texture/nodes/node_texture_math.c @@ -51,7 +51,7 @@ static void valuefn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor float in0 = tex_input_value(in[0], p, thread); float in1 = tex_input_value(in[1], p, thread); - switch (node->custom1) { + switch(node->custom1) { case 0: /* Add */ *out= in0 + in1; diff --git a/source/blender/nodes/texture/nodes/node_texture_output.c b/source/blender/nodes/texture/nodes/node_texture_output.c index 19ba0e88639..2b899fde593 100644 --- a/source/blender/nodes/texture/nodes/node_texture_output.c +++ b/source/blender/nodes/texture/nodes/node_texture_output.c @@ -88,14 +88,14 @@ static void unique_name(bNode *node) i = node; while (i->prev) i = i->prev; - for ( ; i; i = i->next) { - if (i == node || - i->type != TEX_NODE_OUTPUT || - strcmp(name, ((TexNodeOutput*)(i->storage))->name)) - { + for (; i; i=i->next) { + if ( + i == node || + i->type != TEX_NODE_OUTPUT || + strcmp(name, ((TexNodeOutput*)(i->storage))->name) + ) continue; - } - + if (!new_name) { int len = strlen(name); if (len >= 4 && sscanf(name + len - 4, ".%03d", &suffix) == 1) { |