diff options
Diffstat (limited to 'source/blender/nodes')
45 files changed, 680 insertions, 105 deletions
diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt index 82848c6a5d7..69e7f9cac6b 100644 --- a/source/blender/nodes/CMakeLists.txt +++ b/source/blender/nodes/CMakeLists.txt @@ -80,6 +80,8 @@ set(SRC composite/nodes/node_composite_mapValue.c composite/nodes/node_composite_math.c composite/nodes/node_composite_mixrgb.c + composite/nodes/node_composite_movieclip.c + composite/nodes/node_composite_moviedistortion.c composite/nodes/node_composite_normal.c composite/nodes/node_composite_normalize.c composite/nodes/node_composite_outputFile.c @@ -93,8 +95,10 @@ set(SRC composite/nodes/node_composite_sepcombYUVA.c composite/nodes/node_composite_setalpha.c composite/nodes/node_composite_splitViewer.c + composite/nodes/node_composite_stabilize2d.c composite/nodes/node_composite_texture.c composite/nodes/node_composite_tonemap.c + composite/nodes/node_composite_transform.c composite/nodes/node_composite_translate.c composite/nodes/node_composite_valToRgb.c composite/nodes/node_composite_value.c diff --git a/source/blender/nodes/NOD_composite.h b/source/blender/nodes/NOD_composite.h index d768a5d794f..f1415a8c8f0 100644 --- a/source/blender/nodes/NOD_composite.h +++ b/source/blender/nodes/NOD_composite.h @@ -52,6 +52,7 @@ void register_node_type_cmp_texture(ListBase *lb); void register_node_type_cmp_value(ListBase *lb); void register_node_type_cmp_rgb(ListBase *lb); void register_node_type_cmp_curve_time(ListBase *lb); +void register_node_type_cmp_movieclip(ListBase *lb); void register_node_type_cmp_composite(ListBase *lb); void register_node_type_cmp_viewer(ListBase *lb); @@ -113,6 +114,9 @@ void register_node_type_cmp_flip(ListBase *lb); void register_node_type_cmp_crop(ListBase *lb); void register_node_type_cmp_displace(ListBase *lb); void register_node_type_cmp_mapuv(ListBase *lb); +void register_node_type_cmp_transform(ListBase *lb); +void register_node_type_cmp_stabilize2d(ListBase *lb); +void register_node_type_cmp_moviedistortion(ListBase *lb); void register_node_type_cmp_glare(ListBase *lb); void register_node_type_cmp_tonemap(ListBase *lb); diff --git a/source/blender/nodes/composite/node_composite_tree.c b/source/blender/nodes/composite/node_composite_tree.c index 2151176f907..d3f4a5b2999 100644 --- a/source/blender/nodes/composite/node_composite_tree.c +++ b/source/blender/nodes/composite/node_composite_tree.c @@ -45,6 +45,7 @@ #include "BKE_global.h" #include "BKE_main.h" #include "BKE_node.h" +#include "BKE_tracking.h" #include "BKE_utildefines.h" #include "node_exec.h" @@ -168,6 +169,17 @@ static void local_merge(bNodeTree *localtree, bNodeTree *ntree) BKE_image_merge((Image *)lnode->new_node->id, (Image *)lnode->id); } } + else if(lnode->type==CMP_NODE_MOVIEDISTORTION) { + /* special case for distortion node: distortion context is allocating in exec function + and to achive much better performance on further calls this context should be + copied back to original node */ + if(lnode->storage) { + if(lnode->new_node->storage) + BKE_tracking_distortion_destroy(lnode->new_node->storage); + + lnode->new_node->storage= BKE_tracking_distortion_copy(lnode->storage); + } + } for(lsock= lnode->outputs.first; lsock; lsock= lsock->next) { if(ntreeOutputExists(lnode->new_node, lsock->new_sock)) { @@ -806,6 +818,10 @@ int ntreeCompositTagAnimated(bNodeTree *ntree) nodeUpdate(ntree, node); } } + else if(ELEM(node->type, CMP_NODE_MOVIECLIP, CMP_NODE_TRANSFORM)) { + nodeUpdate(ntree, node); + tagged= 1; + } } return tagged; diff --git a/source/blender/nodes/composite/node_composite_util.c b/source/blender/nodes/composite/node_composite_util.c index 929b87618d8..0356ed394f1 100644 --- a/source/blender/nodes/composite/node_composite_util.c +++ b/source/blender/nodes/composite/node_composite_util.c @@ -317,8 +317,8 @@ CompBuf *typecheck_compbuf(CompBuf *inbuf, int type) if(inbuf->rect_procedural) { outbuf->rect_procedural= inbuf->rect_procedural; - VECCOPY(outbuf->procedural_size, inbuf->procedural_size); - VECCOPY(outbuf->procedural_offset, inbuf->procedural_offset); + copy_v3_v3(outbuf->procedural_size, inbuf->procedural_size); + copy_v3_v3(outbuf->procedural_offset, inbuf->procedural_offset); outbuf->procedural_type= inbuf->procedural_type; outbuf->node= inbuf->node; return outbuf; @@ -707,12 +707,12 @@ void do_ycca_to_rgba(bNode *UNUSED(node), float *out, float *in) void do_copy_rgba(bNode *UNUSED(node), float *out, float *in) { - QUATCOPY(out, in); + copy_v4_v4(out, in); } void do_copy_rgb(bNode *UNUSED(node), float *out, float *in) { - VECCOPY(out, in); + copy_v3_v3(out, in); out[3]= 1.0f; } @@ -723,7 +723,7 @@ void do_copy_value(bNode *UNUSED(node), float *out, float *in) void do_copy_a_rgba(bNode *UNUSED(node), float *out, float *in, float *fac) { - VECCOPY(out, in); + copy_v3_v3(out, in); out[3]= *fac; } diff --git a/source/blender/nodes/composite/node_composite_util.h b/source/blender/nodes/composite/node_composite_util.h index 9ebca8688b4..9cac4c477eb 100644 --- a/source/blender/nodes/composite/node_composite_util.h +++ b/source/blender/nodes/composite/node_composite_util.h @@ -44,6 +44,7 @@ #include "DNA_ID.h" #include "DNA_image_types.h" #include "DNA_material_types.h" +#include "DNA_movieclip_types.h" #include "DNA_node_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" @@ -57,13 +58,16 @@ #include "BLI_utildefines.h" #include "BKE_blender.h" +#include "BKE_camera.h" #include "BKE_colortools.h" #include "BKE_global.h" #include "BKE_image.h" #include "BKE_main.h" #include "BKE_material.h" +#include "BKE_movieclip.h" #include "BKE_node.h" #include "BKE_texture.h" +#include "BKE_tracking.h" #include "BKE_library.h" #include "BKE_object.h" @@ -209,4 +213,11 @@ CompBuf* qd_downScaledCopy(CompBuf* src, int scale); void IIR_gauss(CompBuf* src, float sigma, int chan, int xy); /* end utility funcs */ +/* transformations */ + +#define CMP_SCALE_MAX 12000 + +CompBuf* node_composit_transform(CompBuf *cbuf, float x, float y, float angle, float scale, int filter_type); +float *node_composit_get_float_buffer(RenderData *rd, ImBuf *ibuf, int *alloc); + #endif diff --git a/source/blender/nodes/composite/nodes/node_composite_alphaOver.c b/source/blender/nodes/composite/nodes/node_composite_alphaOver.c index b542954948a..4fd4b750178 100644 --- a/source/blender/nodes/composite/nodes/node_composite_alphaOver.c +++ b/source/blender/nodes/composite/nodes/node_composite_alphaOver.c @@ -48,10 +48,10 @@ static void do_alphaover_premul(bNode *UNUSED(node), float *out, float *src, flo { if(over[3]<=0.0f) { - QUATCOPY(out, src); + copy_v4_v4(out, src); } else if(fac[0]==1.0f && over[3]>=1.0f) { - QUATCOPY(out, over); + copy_v4_v4(out, over); } else { float mul= 1.0f - fac[0]*over[3]; @@ -68,10 +68,10 @@ static void do_alphaover_key(bNode *UNUSED(node), float *out, float *src, float { if(over[3]<=0.0f) { - QUATCOPY(out, src); + copy_v4_v4(out, src); } else if(fac[0]==1.0f && over[3]>=1.0f) { - QUATCOPY(out, over); + copy_v4_v4(out, over); } else { float premul= fac[0]*over[3]; @@ -89,10 +89,10 @@ static void do_alphaover_mixed(bNode *node, float *out, float *src, float *over, { if(over[3]<=0.0f) { - QUATCOPY(out, src); + copy_v4_v4(out, src); } else if(fac[0]==1.0f && over[3]>=1.0f) { - QUATCOPY(out, over); + copy_v4_v4(out, over); } else { NodeTwoFloats *ntf= node->storage; diff --git a/source/blender/nodes/composite/nodes/node_composite_blur.c b/source/blender/nodes/composite/nodes/node_composite_blur.c index 188ac653506..d0ddfb47f08 100644 --- a/source/blender/nodes/composite/nodes/node_composite_blur.c +++ b/source/blender/nodes/composite/nodes/node_composite_blur.c @@ -512,7 +512,7 @@ static void blur_with_reference(bNode *node, CompBuf *new, CompBuf *img, CompBuf if(pix==1) dest[0]= src[0]; else - QUATCOPY(dest, src); + copy_v4_v4(dest, src); } else { int minxr= x-refradx<0?-x:-refradx; diff --git a/source/blender/nodes/composite/nodes/node_composite_colorMatte.c b/source/blender/nodes/composite/nodes/node_composite_colorMatte.c index 3dfc3a193a8..b226e562799 100644 --- a/source/blender/nodes/composite/nodes/node_composite_colorMatte.c +++ b/source/blender/nodes/composite/nodes/node_composite_colorMatte.c @@ -52,7 +52,7 @@ static void do_color_key(bNode *node, float *out, float *in) c=node->storage; - VECCOPY(out, in); + copy_v3_v3(out, in); if( /* do hue last because it needs to wrap, and does some more checks */ diff --git a/source/blender/nodes/composite/nodes/node_composite_curves.c b/source/blender/nodes/composite/nodes/node_composite_curves.c index 675710942fb..6f4d32f6573 100644 --- a/source/blender/nodes/composite/nodes/node_composite_curves.c +++ b/source/blender/nodes/composite/nodes/node_composite_curves.c @@ -144,7 +144,7 @@ static void do_curves_fac(bNode *node, float *out, float *in, float *fac) if(*fac>=1.0) curvemapping_evaluate_premulRGBF(node->storage, out, in); else if(*fac<=0.0) { - VECCOPY(out, in); + copy_v3_v3(out, in); } else { float col[4], mfac= 1.0f-*fac; @@ -175,7 +175,7 @@ static void node_composit_exec_curve_rgb(void *UNUSED(data), bNode *node, bNodeS curvemapping_set_black_white(node->storage, in[2]->vec, in[3]->vec); - if(in[0]->vec[0] == 1.0) + if(in[0]->data==NULL && in[0]->vec[0] == 1.0) composit1_pixel_processor(node, stackbuf, in[1]->data, in[1]->vec, do_curves, CB_RGBA); else composit2_pixel_processor(node, stackbuf, in[1]->data, in[1]->vec, in[0]->data, in[0]->vec, do_curves_fac, CB_RGBA, CB_VAL); diff --git a/source/blender/nodes/composite/nodes/node_composite_diffMatte.c b/source/blender/nodes/composite/nodes/node_composite_diffMatte.c index c621d524044..17156ab3492 100644 --- a/source/blender/nodes/composite/nodes/node_composite_diffMatte.c +++ b/source/blender/nodes/composite/nodes/node_composite_diffMatte.c @@ -60,7 +60,7 @@ static void do_diff_matte(bNode *node, float *outColor, float *inColor1, float * /*average together the distances*/ difference=difference/3.0; - VECCOPY(outColor, inColor1); + copy_v3_v3(outColor, inColor1); /*make 100% transparent*/ if(difference < tolerence) { diff --git a/source/blender/nodes/composite/nodes/node_composite_distanceMatte.c b/source/blender/nodes/composite/nodes/node_composite_distanceMatte.c index 401b143aac3..27fe66cbe0d 100644 --- a/source/blender/nodes/composite/nodes/node_composite_distanceMatte.c +++ b/source/blender/nodes/composite/nodes/node_composite_distanceMatte.c @@ -59,7 +59,7 @@ static void do_distance_matte(bNode *node, float *out, float *in) (c->key[1]-in[1])*(c->key[1]-in[1]) + (c->key[2]-in[2])*(c->key[2]-in[2])); - VECCOPY(out, in); + copy_v3_v3(out, in); /*make 100% transparent */ if(distance < tolerence) { diff --git a/source/blender/nodes/composite/nodes/node_composite_filter.c b/source/blender/nodes/composite/nodes/node_composite_filter.c index 071ee84377c..1a0c51fab53 100644 --- a/source/blender/nodes/composite/nodes/node_composite_filter.c +++ b/source/blender/nodes/composite/nodes/node_composite_filter.c @@ -64,7 +64,7 @@ static void do_filter_edge(CompBuf *out, CompBuf *in, float *filter, float fac) fp= out->rect + pix*y*rowlen; if(pix==CB_RGBA) { - QUATCOPY(fp, row2); + copy_v4_v4(fp, row2); fp+= pix; for(x=2; x<rowlen; x++) { @@ -78,7 +78,7 @@ static void do_filter_edge(CompBuf *out, CompBuf *in, float *filter, float fac) /* no alpha... will clear it completely */ fp++; row1++; row2++; row3++; } - QUATCOPY(fp, row2+4); + copy_v4_v4(fp, row2+4); } else if(pix==CB_VAL) { fp+= pix; @@ -138,7 +138,7 @@ static void do_filter3(CompBuf *out, CompBuf *in, float *filter, float fac) fp[1]= row2[3]; } else if(pixlen==3) { - VECCOPY(fp, row2); + copy_v3_v3(fp, row2); fp+= 3; for(x=2; x<rowlen; x++) { @@ -147,10 +147,10 @@ static void do_filter3(CompBuf *out, CompBuf *in, float *filter, float fac) fp++; row1++; row2++; row3++; } } - VECCOPY(fp, row2+3); + copy_v3_v3(fp, row2+3); } else { - QUATCOPY(fp, row2); + copy_v4_v4(fp, row2); fp+= 4; for(x=2; x<rowlen; x++) { @@ -159,7 +159,7 @@ static void do_filter3(CompBuf *out, CompBuf *in, float *filter, float fac) fp++; row1++; row2++; row3++; } } - QUATCOPY(fp, row2+4); + copy_v4_v4(fp, row2+4); } } } diff --git a/source/blender/nodes/composite/nodes/node_composite_hueSatVal.c b/source/blender/nodes/composite/nodes/node_composite_hueSatVal.c index c2304b37c0d..3c73d07d96c 100644 --- a/source/blender/nodes/composite/nodes/node_composite_hueSatVal.c +++ b/source/blender/nodes/composite/nodes/node_composite_hueSatVal.c @@ -64,7 +64,7 @@ static void do_hue_sat_fac(bNode *node, float *out, float *in, float *fac) out[3]= in[3]; } else { - QUATCOPY(out, in); + copy_v4_v4(out, in); } } diff --git a/source/blender/nodes/composite/nodes/node_composite_image.c b/source/blender/nodes/composite/nodes/node_composite_image.c index c1e9d28bb4d..41427c42286 100644 --- a/source/blender/nodes/composite/nodes/node_composite_image.c +++ b/source/blender/nodes/composite/nodes/node_composite_image.c @@ -58,6 +58,36 @@ static bNodeSocketTemplate cmp_node_rlayers_out[]= { { -1, 0, "" } }; +/* float buffer from the image with matching color management */ +float *node_composit_get_float_buffer(RenderData *rd, ImBuf *ibuf, int *alloc) +{ + float *rect; + + *alloc= FALSE; + + if(rd->color_mgt_flag & R_COLOR_MANAGEMENT) { + if(ibuf->profile != IB_PROFILE_NONE) { + rect= ibuf->rect_float; + } + else { + rect= MEM_mapallocN(sizeof(float) * 4 * ibuf->x * ibuf->y, "node_composit_get_image"); + srgb_to_linearrgb_rgba_rgba_buf(rect, ibuf->rect_float, ibuf->x * ibuf->y); + *alloc= TRUE; + } + } + else { + if(ibuf->profile == IB_PROFILE_NONE) { + rect= ibuf->rect_float; + } + else { + rect= MEM_mapallocN(sizeof(float) * 4 * ibuf->x * ibuf->y, "node_composit_get_image"); + linearrgb_to_srgb_rgba_rgba_buf(rect, ibuf->rect_float, ibuf->x * ibuf->y); + *alloc= TRUE; + } + } + + return rect; +} /* note: this function is used for multilayer too, to ensure uniform handling with BKE_image_get_ibuf() */ @@ -82,26 +112,7 @@ static CompBuf *node_composit_get_image(RenderData *rd, Image *ima, ImageUser *i /* now we need a float buffer from the image with matching color management */ /* XXX weak code, multilayer is excluded from this */ if(ibuf->channels == 4 && ima->rr==NULL) { - if(rd->color_mgt_flag & R_COLOR_MANAGEMENT) { - if(ibuf->profile != IB_PROFILE_NONE) { - rect= ibuf->rect_float; - } - else { - rect= MEM_mapallocN(sizeof(float) * 4 * ibuf->x * ibuf->y, "node_composit_get_image"); - srgb_to_linearrgb_rgba_rgba_buf(rect, ibuf->rect_float, ibuf->x * ibuf->y); - alloc= TRUE; - } - } - else { - if(ibuf->profile == IB_PROFILE_NONE) { - rect= ibuf->rect_float; - } - else { - rect= MEM_mapallocN(sizeof(float) * 4 * ibuf->x * ibuf->y, "node_composit_get_image"); - linearrgb_to_srgb_rgba_rgba_buf(rect, ibuf->rect_float, ibuf->x * ibuf->y); - alloc= TRUE; - } - } + rect= node_composit_get_float_buffer(rd, ibuf, &alloc); } else { /* non-rgba passes can't use color profiles */ diff --git a/source/blender/nodes/composite/nodes/node_composite_invert.c b/source/blender/nodes/composite/nodes/node_composite_invert.c index c428e37bd35..daf2ee0cbe7 100644 --- a/source/blender/nodes/composite/nodes/node_composite_invert.c +++ b/source/blender/nodes/composite/nodes/node_composite_invert.c @@ -50,7 +50,7 @@ static void do_invert(bNode *node, float *out, float *in) out[1] = 1.0f - in[1]; out[2] = 1.0f - in[2]; } else - VECCOPY(out, in); + copy_v3_v3(out, in); if(node->custom1 & CMP_CHAN_A) out[3] = 1.0f - in[3]; @@ -75,7 +75,7 @@ static void do_invert_fac(bNode *node, float *out, float *in, float *fac) if(node->custom1 & CMP_CHAN_A) col[3] = fac[0]*col[3] + (facm*in[3]); - QUATCOPY(out, col); + copy_v4_v4(out, col); } static void node_composit_exec_invert(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out) diff --git a/source/blender/nodes/composite/nodes/node_composite_mixrgb.c b/source/blender/nodes/composite/nodes/node_composite_mixrgb.c index 0f5a2b61b87..275d949da28 100644 --- a/source/blender/nodes/composite/nodes/node_composite_mixrgb.c +++ b/source/blender/nodes/composite/nodes/node_composite_mixrgb.c @@ -47,12 +47,12 @@ static void do_mix_rgb(bNode *node, float *out, float *in1, float *in2, float *f { float col[3]; - VECCOPY(col, in1); + copy_v3_v3(col, in1); if(node->custom2) ramp_blend(node->custom1, col, col+1, col+2, in2[3]*fac[0], in2); else ramp_blend(node->custom1, col, col+1, col+2, fac[0], in2); - VECCOPY(out, col); + copy_v3_v3(out, col); out[3]= in1[3]; } diff --git a/source/blender/nodes/composite/nodes/node_composite_movieclip.c b/source/blender/nodes/composite/nodes/node_composite_movieclip.c new file mode 100644 index 00000000000..8931b899017 --- /dev/null +++ b/source/blender/nodes/composite/nodes/node_composite_movieclip.c @@ -0,0 +1,157 @@ +/* + * ***** 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) 2011 Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): Blender Foundation, + * Sergey Sharybin + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/nodes/composite/nodes/node_composite_movieclip.c + * \ingroup cmpnodes + */ + + +#include "node_composite_util.h" + +static bNodeSocketTemplate cmp_node_movieclip_out[]= { + { SOCK_RGBA, 0, "Image"}, + { SOCK_FLOAT, 1, "Offset X"}, + { SOCK_FLOAT, 1, "Offset Y"}, + { SOCK_FLOAT, 1, "Scale"}, + { SOCK_FLOAT, 1, "Angle"}, + { -1, 0, "" } +}; + +static CompBuf *node_composit_get_movieclip(RenderData *rd, MovieClip *clip, MovieClipUser *user) +{ + ImBuf *ibuf; + CompBuf *stackbuf; + int type; + + float *rect; + int alloc= FALSE; + + ibuf= BKE_movieclip_get_ibuf(clip, user); + + if(ibuf==NULL || (ibuf->rect==NULL && ibuf->rect_float==NULL)) { + IMB_freeImBuf(ibuf); + return NULL; + } + + if (ibuf->rect_float == NULL || ibuf->userflags&IB_RECT_INVALID) { + IMB_float_from_rect(ibuf); + 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); + } + else { + /* non-rgba passes can't use color profiles */ + rect= ibuf->rect_float; + } + /* done coercing into the correct color management */ + + if(!alloc) { + rect= MEM_dupallocN(rect); + alloc= 1; + } + + type= ibuf->channels; + + if(rd->scemode & R_COMP_CROP) { + 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; + } + + IMB_freeImBuf(ibuf); + + return stackbuf; +} + +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; + + BKE_movieclip_user_set_frame(user, rd->cfra); + + stackbuf= node_composit_get_movieclip(rd, clip, user); + + if (stackbuf) { + MovieTrackingStabilization *stab= &clip->tracking.stabilization; + + /* put image on stack */ + out[0]->data= stackbuf; + + 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[3]->vec[0]= scale; + out[4]->vec[0]= angle; + } + + /* generate preview */ + generate_preview(data, node, stackbuf); + } + } +} + +static void init(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp)) +{ + MovieClipUser *user= MEM_callocN(sizeof(MovieClipUser), "node movie clip user"); + + node->storage= user; + user->framenr= 1; +} + +void register_node_type_cmp_movieclip(ListBase *lb) +{ + static bNodeType ntype; + + node_type_base(&ntype, CMP_NODE_MOVIECLIP, "Movie Clip", NODE_CLASS_INPUT, NODE_PREVIEW|NODE_OPTIONS); + node_type_socket_templates(&ntype, NULL, cmp_node_movieclip_out); + node_type_size(&ntype, 120, 80, 300); + node_type_init(&ntype, init); + node_type_storage(&ntype, "MovieClipUser", node_free_standard_storage, node_copy_standard_storage); + node_type_exec(&ntype, node_composit_exec_movieclip); + + nodeRegisterType(lb, &ntype); +} diff --git a/source/blender/nodes/composite/nodes/node_composite_moviedistortion.c b/source/blender/nodes/composite/nodes/node_composite_moviedistortion.c new file mode 100644 index 00000000000..439616377a1 --- /dev/null +++ b/source/blender/nodes/composite/nodes/node_composite_moviedistortion.c @@ -0,0 +1,135 @@ +/* + * ***** 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) 2011 Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): Blender Foundation, + * Sergey Sharybin + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/nodes/composite/nodes/node_composite_moviedistortion.c + * \ingroup cmpnodes + */ + + +#include "node_composite_util.h" + +/* **************** Translate ******************** */ + +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[]= { + { SOCK_RGBA, 0, "Image"}, + { -1, 0, "" } +}; + +static void exec(void *UNUSED(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); + ImBuf *ibuf; + + ibuf= IMB_allocImBuf(cbuf->x, cbuf->y, 32, 0); + + if(ibuf) { + ImBuf *obuf; + MovieTracking *tracking= &clip->tracking; + int width, height; + float overscan= 0.0f; + + ibuf->rect_float= cbuf->rect; + + BKE_movieclip_get_size(clip, NULL, &width, &height); + + if(!node->storage) + node->storage= BKE_tracking_distortion_create(); + + 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= 1; + + obuf->mall&= ~IB_rectfloat; + obuf->rect_float= NULL; + + IMB_freeImBuf(ibuf); + IMB_freeImBuf(obuf); + } + + /* pass on output and free */ + out[0]->data= stackbuf; + + if(cbuf!=in[0]->data) + free_compbuf(cbuf); + } else { + CompBuf *cbuf= in[0]->data; + CompBuf *stackbuf= pass_on_compbuf(cbuf); + + out[0]->data= stackbuf; + } + } +} + +static const char *label(bNode *node) +{ + if(node->custom1==0) + return "Undistortion"; + else + return "Distortion"; +} + +static void storage_free(bNode *node) +{ + if(node->storage) + BKE_tracking_distortion_destroy(node->storage); + + node->storage= NULL; +} + +void storage_copy(bNode *orig_node, bNode *new_node) +{ + if(orig_node->storage) + new_node->storage= BKE_tracking_distortion_copy(orig_node->storage); +} + +void register_node_type_cmp_moviedistortion(ListBase *lb) +{ + static bNodeType ntype; + + node_type_base(&ntype, CMP_NODE_MOVIEDISTORTION, "Movie Distortion", NODE_CLASS_DISTORT, NODE_OPTIONS); + node_type_socket_templates(&ntype, cmp_node_moviedistortion_in, cmp_node_moviedistortion_out); + node_type_size(&ntype, 140, 100, 320); + node_type_label(&ntype, label); + node_type_exec(&ntype, exec); + node_type_storage(&ntype, NULL, storage_free, storage_copy); + + nodeRegisterType(lb, &ntype); +} diff --git a/source/blender/nodes/composite/nodes/node_composite_normal.c b/source/blender/nodes/composite/nodes/node_composite_normal.c index a19b339e674..4c43871d867 100644 --- a/source/blender/nodes/composite/nodes/node_composite_normal.c +++ b/source/blender/nodes/composite/nodes/node_composite_normal.c @@ -64,9 +64,9 @@ static void node_composit_exec_normal(void *UNUSED(data), bNode *node, bNodeStac /* input no image? then only vector op */ if(in[0]->data==NULL) { - VECCOPY(out[0]->vec, nor); + copy_v3_v3(out[0]->vec, nor); /* render normals point inside... the widget points outside */ - out[1]->vec[0]= -INPR(out[0]->vec, in[0]->vec); + out[1]->vec[0]= -dot_v3v3(out[0]->vec, in[0]->vec); } else if(out[1]->hasoutput) { /* make output size of input image */ diff --git a/source/blender/nodes/composite/nodes/node_composite_normalize.c b/source/blender/nodes/composite/nodes/node_composite_normalize.c index 36206d82d0b..d14f589f3f2 100644 --- a/source/blender/nodes/composite/nodes/node_composite_normalize.c +++ b/source/blender/nodes/composite/nodes/node_composite_normalize.c @@ -69,7 +69,7 @@ static void node_composit_exec_normalize(void *UNUSED(data), bNode *node, bNodeS /* Input has no image buffer? Then pass the value */ if(in[0]->data==NULL) { - QUATCOPY(out[0]->vec, in[0]->vec); + copy_v4_v4(out[0]->vec, in[0]->vec); } else { float min = 1.0f+BLENDER_ZMAX; @@ -109,7 +109,6 @@ void register_node_type_cmp_normalize(ListBase *lb) node_type_socket_templates(&ntype, cmp_node_normalize_in, cmp_node_normalize_out); node_type_size(&ntype, 100, 60, 150); node_type_exec(&ntype, node_composit_exec_normalize); - node_type_storage(&ntype, "TexMapping", NULL, NULL); nodeRegisterType(lb, &ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_rgb.c b/source/blender/nodes/composite/nodes/node_composite_rgb.c index a7c820ddce6..12f073a816d 100644 --- a/source/blender/nodes/composite/nodes/node_composite_rgb.c +++ b/source/blender/nodes/composite/nodes/node_composite_rgb.c @@ -55,7 +55,7 @@ static void node_composit_exec_rgb(void *UNUSED(data), bNode *node, bNodeStack * bNodeSocket *sock= node->outputs.first; float *col= ((bNodeSocketValueRGBA*)sock->default_value)->value; - QUATCOPY(out[0]->vec, col); + copy_v4_v4(out[0]->vec, col); } void register_node_type_cmp_rgb(ListBase *lb) diff --git a/source/blender/nodes/composite/nodes/node_composite_scale.c b/source/blender/nodes/composite/nodes/node_composite_scale.c index 5eb789ae0c9..37332c9bd7e 100644 --- a/source/blender/nodes/composite/nodes/node_composite_scale.c +++ b/source/blender/nodes/composite/nodes/node_composite_scale.c @@ -34,8 +34,6 @@ /* **************** Scale ******************** */ -#define CMP_SCALE_MAX 12000 - static bNodeSocketTemplate cmp_node_scale_in[]= { { SOCK_RGBA, 1, "Image", 1.0f, 1.0f, 1.0f, 1.0f}, { SOCK_FLOAT, 1, "X", 1.0f, 0.0f, 0.0f, 0.0f, 0.0001f, CMP_SCALE_MAX, PROP_FACTOR}, @@ -110,6 +108,25 @@ static void node_composit_exec_scale(void *data, bNode *node, bNodeStack **in, b if(cbuf!=in[0]->data) free_compbuf(cbuf); } + else if (node->custom1==CMP_SCALE_ABSOLUTE) { + CompBuf *stackbuf; + int a, x, y; + float *fp; + + x = MAX2((int)in[1]->vec[0], 1); + y = MAX2((int)in[2]->vec[0], 1); + + stackbuf = alloc_compbuf(x, y, CB_RGBA, 1); + fp = stackbuf->rect; + + a = stackbuf->x * stackbuf->y; + while(a--) { + copy_v4_v4(fp, in[0]->vec); + fp += 4; + } + + out[0]->data= stackbuf; + } } void register_node_type_cmp_scale(ListBase *lb) diff --git a/source/blender/nodes/composite/nodes/node_composite_splitViewer.c b/source/blender/nodes/composite/nodes/node_composite_splitViewer.c index 22f3dd3a7b0..b63b42224e2 100644 --- a/source/blender/nodes/composite/nodes/node_composite_splitViewer.c +++ b/source/blender/nodes/composite/nodes/node_composite_splitViewer.c @@ -42,10 +42,10 @@ static bNodeSocketTemplate cmp_node_splitviewer_in[]= { static void do_copy_split_rgba(bNode *UNUSED(node), float *out, float *in1, float *in2, float *fac) { if(*fac==0.0f) { - QUATCOPY(out, in1); + copy_v4_v4(out, in1); } else { - QUATCOPY(out, in2); + copy_v4_v4(out, in2); } } diff --git a/source/blender/nodes/composite/nodes/node_composite_stabilize2d.c b/source/blender/nodes/composite/nodes/node_composite_stabilize2d.c new file mode 100644 index 00000000000..c5d60e65530 --- /dev/null +++ b/source/blender/nodes/composite/nodes/node_composite_stabilize2d.c @@ -0,0 +1,79 @@ +/* + * ***** 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) 2011 Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): Blender Foundation, + * Sergey Sharybin + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/nodes/composite/nodes/node_composite_stabilize2d.c + * \ingroup cmpnodes + */ + + +#include "node_composite_util.h" + +/* **************** Translate ******************** */ + +static bNodeSocketTemplate cmp_node_stabilize2d_in[]= { + { SOCK_RGBA, 1, "Image", 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f}, + { -1, 0, "" } +}; + +static bNodeSocketTemplate cmp_node_stabilize2d_out[]= { + { SOCK_RGBA, 0, "Image"}, + { -1, 0, "" } +}; + +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); + 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); + + /* pass on output and free */ + out[0]->data= stackbuf; + + if(cbuf!=in[0]->data) + free_compbuf(cbuf); + } +} + +void register_node_type_cmp_stabilize2d(ListBase *lb) +{ + static bNodeType ntype; + + node_type_base(&ntype, CMP_NODE_STABILIZE2D, "Stabilize 2D", NODE_CLASS_DISTORT, NODE_OPTIONS); + node_type_socket_templates(&ntype, cmp_node_stabilize2d_in, cmp_node_stabilize2d_out); + node_type_size(&ntype, 140, 100, 320); + node_type_exec(&ntype, node_composit_exec_stabilize2d); + + nodeRegisterType(lb, &ntype); +} diff --git a/source/blender/nodes/composite/nodes/node_composite_texture.c b/source/blender/nodes/composite/nodes/node_composite_texture.c index 24d7b30f11d..2f54f27e481 100644 --- a/source/blender/nodes/composite/nodes/node_composite_texture.c +++ b/source/blender/nodes/composite/nodes/node_composite_texture.c @@ -80,7 +80,7 @@ static void texture_procedural(CompBuf *cbuf, float *out, float xco, float yco) else col[0]= col[1]= col[2]= col[3]; } else { - VECCOPY(col, nor); + copy_v3_v3(col, nor); } typecheck_compbuf_color(out, col, cbuf->type, cbuf->procedural_type); @@ -101,8 +101,8 @@ static void node_composit_exec_texture(void *data, bNode *node, bNodeStack **in, prevbuf->rect_procedural= texture_procedural; prevbuf->node= node; - VECCOPY(prevbuf->procedural_offset, in[0]->vec); - VECCOPY(prevbuf->procedural_size, in[1]->vec); + copy_v3_v3(prevbuf->procedural_offset, in[0]->vec); + copy_v3_v3(prevbuf->procedural_size, in[1]->vec); prevbuf->procedural_type= CB_RGBA; composit1_pixel_processor(node, prevbuf, prevbuf, out[0]->vec, do_copy_rgba, CB_RGBA); @@ -118,8 +118,8 @@ static void node_composit_exec_texture(void *data, bNode *node, bNodeStack **in, stackbuf->rect_procedural= texture_procedural; stackbuf->node= node; - VECCOPY(stackbuf->procedural_offset, in[0]->vec); - VECCOPY(stackbuf->procedural_size, in[1]->vec); + copy_v3_v3(stackbuf->procedural_offset, in[0]->vec); + copy_v3_v3(stackbuf->procedural_size, in[1]->vec); stackbuf->procedural_type= CB_VAL; composit1_pixel_processor(node, stackbuf, stackbuf, out[0]->vec, do_copy_value, CB_VAL); stackbuf->rect_procedural= NULL; @@ -131,8 +131,8 @@ static void node_composit_exec_texture(void *data, bNode *node, bNodeStack **in, stackbuf->rect_procedural= texture_procedural; stackbuf->node= node; - VECCOPY(stackbuf->procedural_offset, in[0]->vec); - VECCOPY(stackbuf->procedural_size, in[1]->vec); + copy_v3_v3(stackbuf->procedural_offset, in[0]->vec); + copy_v3_v3(stackbuf->procedural_size, in[1]->vec); stackbuf->procedural_type= CB_RGBA; composit1_pixel_processor(node, stackbuf, stackbuf, out[0]->vec, do_copy_rgba, CB_RGBA); stackbuf->rect_procedural= NULL; diff --git a/source/blender/nodes/composite/nodes/node_composite_transform.c b/source/blender/nodes/composite/nodes/node_composite_transform.c new file mode 100644 index 00000000000..de9b8fceaee --- /dev/null +++ b/source/blender/nodes/composite/nodes/node_composite_transform.c @@ -0,0 +1,142 @@ +/* + * ***** 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) 2011 Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): Blender Foundation, + * Sergey Sharybin + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/nodes/composite/nodes/node_composite_transform.c + * \ingroup cmpnodes + */ + +#include "node_composite_util.h" + +/* **************** Transform ******************** */ + +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}, + { SOCK_FLOAT, 1, "Angle", 0.0f, 0.0f, 0.0f, 0.0f, -10000.0f, 10000.0f, PROP_ANGLE}, + { SOCK_FLOAT, 1, "Scale", 1.0f, 0.0f, 0.0f, 0.0f, 0.0001f, CMP_SCALE_MAX}, + { -1, 0, "" } +}; + +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, 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}; + + unit_m4(rmat); + unit_m4(lmat); + unit_m4(smat); + unit_m4(cmat); + + /* image center as rotation center */ + 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 */ + add_v2_v2(lmat[3], loc); /* tranlation matrix */ + rotate_m4(rmat, 'Z', angle); /* rotation matrix */ + + /* compose transformation matrix */ + mul_serie_m4(mat, lmat, cmat, rmat, smat, icmat, NULL, NULL, NULL); + + invert_m4(mat); + + 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; + + 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) { + case 0: + neareast_interpolation(ibuf, obuf, vec[0], vec[1], i, j); + break ; + case 1: + bilinear_interpolation(ibuf, obuf, vec[0], vec[1], i, j); + break; + case 2: + bicubic_interpolation(ibuf, obuf, vec[0], vec[1], i, j); + break; + } + } + } + + IMB_freeImBuf(ibuf); + IMB_freeImBuf(obuf); + } + + /* pass on output and free */ + return stackbuf; +} + +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 *stackbuf; + + 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; + + if(cbuf!=in[0]->data) + free_compbuf(cbuf); + } +} + +void register_node_type_cmp_transform(ListBase *lb) +{ + static bNodeType ntype; + + node_type_base(&ntype, CMP_NODE_TRANSFORM, "Transform", NODE_CLASS_DISTORT, NODE_OPTIONS); + node_type_socket_templates(&ntype, cmp_node_transform_in, cmp_node_transform_out); + node_type_size(&ntype, 140, 100, 320); + node_type_exec(&ntype, node_composit_exec_transform); + + nodeRegisterType(lb, &ntype); +} + + diff --git a/source/blender/nodes/composite/nodes/node_composite_zcombine.c b/source/blender/nodes/composite/nodes/node_composite_zcombine.c index 7aac3539960..868c0d2b5f3 100644 --- a/source/blender/nodes/composite/nodes/node_composite_zcombine.c +++ b/source/blender/nodes/composite/nodes/node_composite_zcombine.c @@ -65,7 +65,7 @@ static void do_zcombine(bNode *node, float *out, float *src1, float *z1, float * } else { // do combination based solely on z value - QUATCOPY(out, src1); + copy_v4_v4(out, src1); } } else { @@ -80,7 +80,7 @@ static void do_zcombine(bNode *node, float *out, float *src1, float *z1, float * } else { // do combination based solely on z value - QUATCOPY(out, src1); + copy_v4_v4(out, src1); } if(node->custom2) diff --git a/source/blender/nodes/shader/node_shader_util.c b/source/blender/nodes/shader/node_shader_util.c index b0ef6ccccbf..dd72f7662d0 100644 --- a/source/blender/nodes/shader/node_shader_util.c +++ b/source/blender/nodes/shader/node_shader_util.c @@ -55,12 +55,12 @@ void nodestack_get_vec(float *in, short type_in, bNodeStack *ns) in[2]= from[0]; } else { - VECCOPY(in, from); + copy_v3_v3(in, from); } } else { /* type_in==SOCK_RGBA */ if(ns->sockettype==SOCK_RGBA) { - QUATCOPY(in, from); + copy_v4_v4(in, from); } else if(ns->sockettype==SOCK_FLOAT) { in[0]= from[0]; @@ -69,7 +69,7 @@ void nodestack_get_vec(float *in, short type_in, bNodeStack *ns) in[3]= 1.0f; } else { - VECCOPY(in, from); + copy_v3_v3(in, from); in[3]= 1.0f; } } @@ -142,13 +142,13 @@ void nodeShaderSynchronizeID(bNode *node, int copyto) if(copyto) { switch(a) { case MAT_IN_COLOR: - VECCOPY(&ma->r, ((bNodeSocketValueRGBA*)sock->default_value)->value); break; + copy_v3_v3(&ma->r, ((bNodeSocketValueRGBA*)sock->default_value)->value); break; case MAT_IN_SPEC: - VECCOPY(&ma->specr, ((bNodeSocketValueRGBA*)sock->default_value)->value); break; + copy_v3_v3(&ma->specr, ((bNodeSocketValueRGBA*)sock->default_value)->value); break; case MAT_IN_REFL: ma->ref= ((bNodeSocketValueFloat*)sock->default_value)->value; break; case MAT_IN_MIR: - VECCOPY(&ma->mirr, ((bNodeSocketValueRGBA*)sock->default_value)->value); break; + copy_v3_v3(&ma->mirr, ((bNodeSocketValueRGBA*)sock->default_value)->value); break; case MAT_IN_AMB: ma->amb= ((bNodeSocketValueFloat*)sock->default_value)->value; break; case MAT_IN_EMIT: @@ -166,13 +166,13 @@ void nodeShaderSynchronizeID(bNode *node, int copyto) else { switch(a) { case MAT_IN_COLOR: - VECCOPY(((bNodeSocketValueRGBA*)sock->default_value)->value, &ma->r); break; + copy_v3_v3(((bNodeSocketValueRGBA*)sock->default_value)->value, &ma->r); break; case MAT_IN_SPEC: - VECCOPY(((bNodeSocketValueRGBA*)sock->default_value)->value, &ma->specr); break; + copy_v3_v3(((bNodeSocketValueRGBA*)sock->default_value)->value, &ma->specr); break; case MAT_IN_REFL: ((bNodeSocketValueFloat*)sock->default_value)->value= ma->ref; break; case MAT_IN_MIR: - VECCOPY(((bNodeSocketValueRGBA*)sock->default_value)->value, &ma->mirr); break; + copy_v3_v3(((bNodeSocketValueRGBA*)sock->default_value)->value, &ma->mirr); break; case MAT_IN_AMB: ((bNodeSocketValueFloat*)sock->default_value)->value= ma->amb; break; case MAT_IN_EMIT: @@ -198,7 +198,7 @@ void node_gpu_stack_from_data(struct GPUNodeStack *gs, int type, bNodeStack *ns) { memset(gs, 0, sizeof(*gs)); - QUATCOPY(gs->vec, ns->vec); + copy_v4_v4(gs->vec, ns->vec); gs->link= ns->data; if (type == SOCK_FLOAT) diff --git a/source/blender/nodes/shader/nodes/node_shader_camera.c b/source/blender/nodes/shader/nodes/node_shader_camera.c index c7882a6e0e2..02efbd63aba 100644 --- a/source/blender/nodes/shader/nodes/node_shader_camera.c +++ b/source/blender/nodes/shader/nodes/node_shader_camera.c @@ -46,7 +46,7 @@ static void node_shader_exec_camera(void *data, bNode *UNUSED(node), bNodeStack if(data) { ShadeInput *shi= ((ShaderCallData *)data)->shi; /* Data we need for shading. */ - VECCOPY(out[0]->vec, shi->co); /* get view vector */ + copy_v3_v3(out[0]->vec, shi->co); /* get view vector */ out[1]->vec[0]= fabs(shi->co[2]); /* get view z-depth */ out[2]->vec[0]= normalize_v3(out[0]->vec); /* get view distance */ } diff --git a/source/blender/nodes/shader/nodes/node_shader_geom.c b/source/blender/nodes/shader/nodes/node_shader_geom.c index ab4931f12ac..6547194b33a 100644 --- a/source/blender/nodes/shader/nodes/node_shader_geom.c +++ b/source/blender/nodes/shader/nodes/node_shader_geom.c @@ -91,7 +91,7 @@ static void node_shader_exec_geom(void *data, bNode *node, bNodeStack **UNUSED(i } } - VECCOPY(out[GEOM_OUT_VCOL]->vec, scol->col); + copy_v3_v3(out[GEOM_OUT_VCOL]->vec, scol->col); out[GEOM_OUT_VCOL]->vec[3]= scol->col[3]; out[GEOM_OUT_VCOL_ALPHA]->vec[0]= scol->col[3]; } diff --git a/source/blender/nodes/shader/nodes/node_shader_hueSatVal.c b/source/blender/nodes/shader/nodes/node_shader_hueSatVal.c index 7fb31d80ffc..1207196381d 100644 --- a/source/blender/nodes/shader/nodes/node_shader_hueSatVal.c +++ b/source/blender/nodes/shader/nodes/node_shader_hueSatVal.c @@ -65,7 +65,7 @@ static void do_hue_sat_fac(bNode *UNUSED(node), float *out, float *hue, float *s out[2]= mfac*in[2] + *fac*col[2]; } else { - QUATCOPY(out, in); + copy_v4_v4(out, in); } } diff --git a/source/blender/nodes/shader/nodes/node_shader_invert.c b/source/blender/nodes/shader/nodes/node_shader_invert.c index 066ff14a870..e3dacefbcf2 100644 --- a/source/blender/nodes/shader/nodes/node_shader_invert.c +++ b/source/blender/nodes/shader/nodes/node_shader_invert.c @@ -64,7 +64,7 @@ bNodeStack **out) col[2] = in[0]->vec[0]*col[2] + (facm*in[1]->vec[2]); } - VECCOPY(out[0]->vec, col); + copy_v3_v3(out[0]->vec, col); } static int gpu_shader_invert(GPUMaterial *mat, bNode *UNUSED(node), GPUNodeStack *in, GPUNodeStack *out) diff --git a/source/blender/nodes/shader/nodes/node_shader_material.c b/source/blender/nodes/shader/nodes/node_shader_material.c index f93928d8884..a74a2567844 100644 --- a/source/blender/nodes/shader/nodes/node_shader_material.c +++ b/source/blender/nodes/shader/nodes/node_shader_material.c @@ -148,13 +148,13 @@ static void node_shader_exec_material(void *data, bNode *node, bNodeStack **in, /* write to outputs */ if(node->custom1 & SH_NODE_MAT_DIFF) { - VECCOPY(col, shrnode.combined); + copy_v3_v3(col, shrnode.combined); if(!(node->custom1 & SH_NODE_MAT_SPEC)) { sub_v3_v3(col, shrnode.spec); } } else if(node->custom1 & SH_NODE_MAT_SPEC) { - VECCOPY(col, shrnode.spec); + copy_v3_v3(col, shrnode.spec); } else col[0]= col[1]= col[2]= 0.0f; @@ -164,7 +164,7 @@ static void node_shader_exec_material(void *data, bNode *node, bNodeStack **in, if(shi->do_preview) nodeAddToPreview(node, col, shi->xs, shi->ys, shi->do_manage); - VECCOPY(out[MAT_OUT_COLOR]->vec, col); + copy_v3_v3(out[MAT_OUT_COLOR]->vec, col); out[MAT_OUT_ALPHA]->vec[0]= shrnode.alpha; if(node->custom1 & SH_NODE_MAT_NEG) { @@ -173,15 +173,15 @@ static void node_shader_exec_material(void *data, bNode *node, bNodeStack **in, shi->vn[2]= -shi->vn[2]; } - VECCOPY(out[MAT_OUT_NORMAL]->vec, shi->vn); + copy_v3_v3(out[MAT_OUT_NORMAL]->vec, shi->vn); /* Extended material options */ if (node->type == SH_NODE_MATERIAL_EXT) { /* Shadow, Reflect, Refract, Radiosity, Speed seem to cause problems inside * a node tree :( */ - VECCOPY(out[MAT_OUT_DIFFUSE]->vec, shrnode.diff); - VECCOPY(out[MAT_OUT_SPEC]->vec, shrnode.spec); - VECCOPY(out[MAT_OUT_AO]->vec, shrnode.ao); + copy_v3_v3(out[MAT_OUT_DIFFUSE]->vec, shrnode.diff); + copy_v3_v3(out[MAT_OUT_SPEC]->vec, shrnode.spec); + copy_v3_v3(out[MAT_OUT_AO]->vec, shrnode.ao); } /* copy passes, now just active node */ diff --git a/source/blender/nodes/shader/nodes/node_shader_mixRgb.c b/source/blender/nodes/shader/nodes/node_shader_mixRgb.c index 7aed6bce4c4..7692956368c 100644 --- a/source/blender/nodes/shader/nodes/node_shader_mixRgb.c +++ b/source/blender/nodes/shader/nodes/node_shader_mixRgb.c @@ -59,7 +59,7 @@ static void node_shader_exec_mix_rgb(void *UNUSED(data), bNode *node, bNodeStack nodestack_get_vec(vec, SOCK_VECTOR, in[2]); ramp_blend(node->custom1, col, col+1, col+2, fac, vec); - VECCOPY(out[0]->vec, col); + copy_v3_v3(out[0]->vec, col); } static int gpu_shader_mix_rgb(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *out) diff --git a/source/blender/nodes/shader/nodes/node_shader_normal.c b/source/blender/nodes/shader/nodes/node_shader_normal.c index c23c6d328cf..40f2f65a193 100644 --- a/source/blender/nodes/shader/nodes/node_shader_normal.c +++ b/source/blender/nodes/shader/nodes/node_shader_normal.c @@ -66,7 +66,7 @@ static void node_shader_exec_normal(void *UNUSED(data), bNode *node, bNodeStack nodestack_get_vec(vec, SOCK_VECTOR, in[0]); - VECCOPY(out[0]->vec, ((bNodeSocketValueVector*)sock->default_value)->value); + copy_v3_v3(out[0]->vec, ((bNodeSocketValueVector*)sock->default_value)->value); /* render normals point inside... the widget points outside */ out[1]->vec[0]= -INPR(out[0]->vec, vec); } diff --git a/source/blender/nodes/shader/nodes/node_shader_output.c b/source/blender/nodes/shader/nodes/node_shader_output.c index ea7fae8f961..22e3cab532d 100644 --- a/source/blender/nodes/shader/nodes/node_shader_output.c +++ b/source/blender/nodes/shader/nodes/node_shader_output.c @@ -57,10 +57,10 @@ static void node_shader_exec_output(void *data, bNode *node, bNodeStack **in, bN if(node->flag & NODE_DO_OUTPUT) { ShadeResult *shr= ((ShaderCallData *)data)->shr; - QUATCOPY(shr->combined, col); + copy_v4_v4(shr->combined, col); shr->alpha= col[3]; - // VECCOPY(shr->nor, in[3]->vec); + // copy_v3_v3(shr->nor, in[3]->vec); } } } diff --git a/source/blender/nodes/shader/nodes/node_shader_rgb.c b/source/blender/nodes/shader/nodes/node_shader_rgb.c index 1a0b4ea616b..67c0ec165ca 100644 --- a/source/blender/nodes/shader/nodes/node_shader_rgb.c +++ b/source/blender/nodes/shader/nodes/node_shader_rgb.c @@ -54,7 +54,7 @@ static void node_shader_exec_rgb(void *UNUSED(data), bNode *node, bNodeStack **U bNodeSocket *sock= node->outputs.first; float *col= ((bNodeSocketValueRGBA*)sock->default_value)->value; - VECCOPY(out[0]->vec, col); + copy_v3_v3(out[0]->vec, col); } static int gpu_shader_rgb(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *out) diff --git a/source/blender/nodes/shader/nodes/node_shader_texture.c b/source/blender/nodes/shader/nodes/node_shader_texture.c index 588cdc1da83..42460e141e2 100644 --- a/source/blender/nodes/shader/nodes/node_shader_texture.c +++ b/source/blender/nodes/shader/nodes/node_shader_texture.c @@ -82,7 +82,7 @@ static void node_shader_exec_texture(void *data, bNode *node, bNodeStack **in, b retval= multitex_nodes((Tex *)node->id, vec, NULL, NULL, 0, &texres, thread, which_output, NULL, NULL); } else { - VECCOPY(vec, shi->lo); + copy_v3_v3(vec, shi->lo); retval= multitex_nodes((Tex *)node->id, vec, NULL, NULL, 0, &texres, thread, which_output, NULL, NULL); } @@ -111,7 +111,7 @@ static void node_shader_exec_texture(void *data, bNode *node, bNodeStack **in, b out[1]->vec[3]= 1.0f; } - VECCOPY(out[2]->vec, nor); + copy_v3_v3(out[2]->vec, nor); if(shi->do_preview) nodeAddToPreview(node, out[1]->vec, shi->xs, shi->ys, shi->do_manage); diff --git a/source/blender/nodes/texture/nodes/node_texture_bricks.c b/source/blender/nodes/texture/nodes/node_texture_bricks.c index 2011426b845..0700085a787 100644 --- a/source/blender/nodes/texture/nodes/node_texture_bricks.c +++ b/source/blender/nodes/texture/nodes/node_texture_bricks.c @@ -107,9 +107,9 @@ static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor if( ins_x < mortar_thickness || ins_y < mortar_thickness || ins_x > (brick_width - mortar_thickness) || ins_y > (row_height - mortar_thickness) ) { - QUATCOPY( out, mortar ); + copy_v4_v4( out, mortar ); } else { - QUATCOPY( out, bricks1 ); + copy_v4_v4( out, bricks1 ); ramp_blend( MA_RAMP_BLEND, out, out+1, out+2, tint, bricks2 ); } } diff --git a/source/blender/nodes/texture/nodes/node_texture_hueSatVal.c b/source/blender/nodes/texture/nodes/node_texture_hueSatVal.c index 111d6e78023..3346592f7d3 100644 --- a/source/blender/nodes/texture/nodes/node_texture_hueSatVal.c +++ b/source/blender/nodes/texture/nodes/node_texture_hueSatVal.c @@ -66,7 +66,7 @@ static void do_hue_sat_fac(bNode *UNUSED(node), float *out, float hue, float sat out[2]= mfac*in[2] + fac*col[2]; } else { - QUATCOPY(out, in); + copy_v4_v4(out, in); } } diff --git a/source/blender/nodes/texture/nodes/node_texture_image.c b/source/blender/nodes/texture/nodes/node_texture_image.c index 3a81ecb1466..0ead3a3dec2 100644 --- a/source/blender/nodes/texture/nodes/node_texture_image.c +++ b/source/blender/nodes/texture/nodes/node_texture_image.c @@ -76,7 +76,7 @@ static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **UNUSED(i while( py >= ibuf->y ) py -= ibuf->y; result = ibuf->rect_float + py*ibuf->x*4 + px*4; - QUATCOPY( out, result ); + copy_v4_v4( out, result ); } } } diff --git a/source/blender/nodes/texture/nodes/node_texture_invert.c b/source/blender/nodes/texture/nodes/node_texture_invert.c index 3ad11026f28..5ee60d02e32 100644 --- a/source/blender/nodes/texture/nodes/node_texture_invert.c +++ b/source/blender/nodes/texture/nodes/node_texture_invert.c @@ -54,7 +54,7 @@ static void colorfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack ** col[1] = 1.0f - col[1]; col[2] = 1.0f - col[2]; - VECCOPY(out, col); + copy_v3_v3(out, col); out[3] = col[3]; } diff --git a/source/blender/nodes/texture/nodes/node_texture_mixRgb.c b/source/blender/nodes/texture/nodes/node_texture_mixRgb.c index c68adf2f4aa..e3b5119c797 100644 --- a/source/blender/nodes/texture/nodes/node_texture_mixRgb.c +++ b/source/blender/nodes/texture/nodes/node_texture_mixRgb.c @@ -55,7 +55,7 @@ static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor CLAMP(fac, 0.0f, 1.0f); - QUATCOPY(out, col1); + copy_v4_v4(out, col1); ramp_blend(node->custom1, out, out+1, out+2, fac, col2); } diff --git a/source/blender/nodes/texture/nodes/node_texture_proc.c b/source/blender/nodes/texture/nodes/node_texture_proc.c index d9ac8700be1..3012d313db5 100644 --- a/source/blender/nodes/texture/nodes/node_texture_proc.c +++ b/source/blender/nodes/texture/nodes/node_texture_proc.c @@ -75,10 +75,10 @@ static void do_proc(float *result, TexParams *p, float *col1, float *col2, char return; if(textype & TEX_RGB) { - QUATCOPY(result, &texres.tr); + copy_v4_v4(result, &texres.tr); } else { - QUATCOPY(result, col1); + copy_v4_v4(result, col1); ramp_blend(MA_RAMP_BLEND, result, result+1, result+2, texres.tin, col2); } } diff --git a/source/blender/nodes/texture/nodes/node_texture_texture.c b/source/blender/nodes/texture/nodes/node_texture_texture.c index 1b8eb3aabc6..667570582fe 100644 --- a/source/blender/nodes/texture/nodes/node_texture_texture.c +++ b/source/blender/nodes/texture/nodes/node_texture_texture.c @@ -65,7 +65,7 @@ static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor if(node->custom2 || node->need_exec==0) { /* this node refers to its own texture tree! */ - QUATCOPY(out, (fabs(co[0] - co[1]) < .01) ? white : red ); + copy_v4_v4(out, (fabs(co[0] - co[1]) < .01) ? white : red ); } else if(nodetex) { TexResult texres; @@ -81,10 +81,10 @@ static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor &texres, thread, 0, p->shi, p->mtex); if(textype & TEX_RGB) { - QUATCOPY(out, &texres.tr); + copy_v4_v4(out, &texres.tr); } else { - QUATCOPY(out, col1); + copy_v4_v4(out, col1); ramp_blend(MA_RAMP_BLEND, out, out+1, out+2, texres.tin, col2); } } |