diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-06-08 09:07:48 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-06-08 09:07:48 +0300 |
commit | a25c11fd8d602236f36c34c342453149bdc1d909 (patch) | |
tree | c1e537d7ef21767130c459914313517671d0170b /source/blender/nodes | |
parent | 009c38df5303f0a32eed2962650b89ebd6ae2e46 (diff) |
Cleanup: trailing space
Remove from blender/nodes, collada, blenfont & render.
Diffstat (limited to 'source/blender/nodes')
81 files changed, 575 insertions, 575 deletions
diff --git a/source/blender/nodes/composite/node_composite_tree.c b/source/blender/nodes/composite/node_composite_tree.c index 0e98418ffea..4779fdd33d2 100644 --- a/source/blender/nodes/composite/node_composite_tree.c +++ b/source/blender/nodes/composite/node_composite_tree.c @@ -59,7 +59,7 @@ static void composite_get_from_context(const bContext *C, bNodeTreeType *UNUSED(treetype), bNodeTree **r_ntree, ID **r_id, ID **r_from) { Scene *scene = CTX_data_scene(C); - + *r_from = NULL; *r_id = &scene->id; *r_ntree = scene->nodetree; @@ -83,7 +83,7 @@ static void foreach_nodeclass(Scene *UNUSED(scene), void *calldata, bNodeClassCa static void free_node_cache(bNodeTree *UNUSED(ntree), bNode *node) { bNodeSocket *sock; - + for (sock = node->outputs.first; sock; sock = sock->next) { if (sock->cache) { sock->cache = NULL; @@ -103,15 +103,15 @@ static void localize(bNodeTree *UNUSED(localtree), bNodeTree *ntree) { bNode *node; bNodeSocket *sock; - + for (node = ntree->nodes.first; node; node = node->next) { /* ensure new user input gets handled ok */ node->need_exec = 0; node->new_node->original = node; - + /* move over the compbufs */ /* right after ntreeCopyTree() oldsock pointers are valid */ - + if (ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) { if (node->id) { if (node->flag & NODE_DO_OUTPUT) @@ -120,7 +120,7 @@ static void localize(bNodeTree *UNUSED(localtree), bNodeTree *ntree) node->new_node->id = NULL; } } - + for (sock = node->outputs.first; sock; sock = sock->next) { sock->new_sock->cache = sock->cache; sock->cache = NULL; @@ -138,10 +138,10 @@ static void local_merge(bNodeTree *localtree, bNodeTree *ntree) { bNode *lnode; bNodeSocket *lsock; - + /* move over the compbufs and previews */ BKE_node_preview_merge_tree(ntree, localtree, true); - + for (lnode = localtree->nodes.first; lnode; lnode = lnode->next) { if (ntreeNodeExists(ntree, lnode->new_node)) { if (ELEM(lnode->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) { @@ -161,7 +161,7 @@ static void local_merge(bNodeTree *localtree, bNodeTree *ntree) 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)) { lsock->new_sock->cache = lsock->cache; @@ -176,9 +176,9 @@ static void local_merge(bNodeTree *localtree, bNodeTree *ntree) static void update(bNodeTree *ntree) { ntreeSetOutput(ntree); - + ntree_update_reroute_nodes(ntree); - + if (ntree->update & NTREE_UPDATE_NODES) { /* clean up preview cache, in case nodes have been removed */ BKE_node_preview_remove_unused(ntree); @@ -187,12 +187,12 @@ static void update(bNodeTree *ntree) static void composite_node_add_init(bNodeTree *UNUSED(bnodetree), bNode *bnode) { - /* Composite node will only show previews for input classes - * by default, other will be hidden + /* Composite node will only show previews for input classes + * by default, other will be hidden * but can be made visible with the show_preview option */ if (bnode->typeinfo->nclass != NODE_CLASS_INPUT) { bnode->flag &= ~NODE_PREVIEW; - } + } } bNodeTreeType *ntreeType_Composite; @@ -200,13 +200,13 @@ bNodeTreeType *ntreeType_Composite; void register_node_tree_type_cmp(void) { bNodeTreeType *tt = ntreeType_Composite = MEM_callocN(sizeof(bNodeTreeType), "compositor node tree type"); - + tt->type = NTREE_COMPOSIT; strcpy(tt->idname, "CompositorNodeTree"); strcpy(tt->ui_name, "Compositing"); tt->ui_icon = 0; /* defined in drawnode.c */ strcpy(tt->ui_description, "Compositing nodes"); - + tt->free_cache = free_cache; tt->free_node_cache = free_node_cache; tt->foreach_nodeclass = foreach_nodeclass; @@ -216,9 +216,9 @@ void register_node_tree_type_cmp(void) tt->update = update; tt->get_from_context = composite_get_from_context; tt->node_add_init = composite_node_add_init; - + tt->ext.srna = &RNA_CompositorNodeTree; - + ntreeTypeAdd(tt); } diff --git a/source/blender/nodes/composite/node_composite_util.c b/source/blender/nodes/composite/node_composite_util.c index faf3d994bf9..022794e8d42 100644 --- a/source/blender/nodes/composite/node_composite_util.c +++ b/source/blender/nodes/composite/node_composite_util.c @@ -52,7 +52,7 @@ void cmp_node_update_default(bNodeTree *UNUSED(ntree), bNode *node) void cmp_node_type_base(bNodeType *ntype, int type, const char *name, short nclass, short flag) { node_type_base(ntype, type, name, nclass, flag); - + ntype->poll = cmp_node_poll_default; ntype->updatefunc = cmp_node_update_default; ntype->insert_link = node_insert_link_default; diff --git a/source/blender/nodes/composite/nodes/node_composite_bokehblur.c b/source/blender/nodes/composite/nodes/node_composite_bokehblur.c index 503d1ad9a9d..acb5d100b0a 100644 --- a/source/blender/nodes/composite/nodes/node_composite_bokehblur.c +++ b/source/blender/nodes/composite/nodes/node_composite_bokehblur.c @@ -60,6 +60,6 @@ void register_node_type_cmp_bokehblur(void) cmp_node_type_base(&ntype, CMP_NODE_BOKEHBLUR, "Bokeh Blur", NODE_CLASS_OP_FILTER, 0); node_type_socket_templates(&ntype, cmp_node_bokehblur_in, cmp_node_bokehblur_out); node_type_init(&ntype, node_composit_init_bokehblur); - + nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_bokehimage.c b/source/blender/nodes/composite/nodes/node_composite_bokehimage.c index 1473212f8e1..04cdd3367e6 100644 --- a/source/blender/nodes/composite/nodes/node_composite_bokehimage.c +++ b/source/blender/nodes/composite/nodes/node_composite_bokehimage.c @@ -54,7 +54,7 @@ static void node_composit_init_bokehimage(bNodeTree *UNUSED(ntree), bNode *node) void register_node_type_cmp_bokehimage(void) { static bNodeType ntype; - + cmp_node_type_base(&ntype, CMP_NODE_BOKEHIMAGE, "Bokeh Image", NODE_CLASS_INPUT, NODE_PREVIEW); node_type_socket_templates(&ntype, NULL, cmp_node_bokehimage_out); node_type_init(&ntype, node_composit_init_bokehimage); diff --git a/source/blender/nodes/composite/nodes/node_composite_boxmask.c b/source/blender/nodes/composite/nodes/node_composite_boxmask.c index 2a47c58c33f..611cf323873 100644 --- a/source/blender/nodes/composite/nodes/node_composite_boxmask.c +++ b/source/blender/nodes/composite/nodes/node_composite_boxmask.c @@ -32,7 +32,7 @@ #include "../node_composite_util.h" -/* **************** SCALAR MATH ******************** */ +/* **************** SCALAR MATH ******************** */ static bNodeSocketTemplate cmp_node_boxmask_in[] = { { SOCK_FLOAT, 1, N_("Mask"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f}, { SOCK_FLOAT, 1, N_("Value"), 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f}, diff --git a/source/blender/nodes/composite/nodes/node_composite_brightness.c b/source/blender/nodes/composite/nodes/node_composite_brightness.c index 845e9e20c81..d44b8cd63cb 100644 --- a/source/blender/nodes/composite/nodes/node_composite_brightness.c +++ b/source/blender/nodes/composite/nodes/node_composite_brightness.c @@ -54,7 +54,7 @@ static void node_composit_init_brightcontrast(bNodeTree *UNUSED(ntree), bNode *n void register_node_type_cmp_brightcontrast(void) { static bNodeType ntype; - + cmp_node_type_base(&ntype, CMP_NODE_BRIGHTCONTRAST, "Bright/Contrast", NODE_CLASS_OP_COLOR, 0); node_type_socket_templates(&ntype, cmp_node_brightcontrast_in, cmp_node_brightcontrast_out); node_type_init(&ntype, node_composit_init_brightcontrast); diff --git a/source/blender/nodes/composite/nodes/node_composite_colorSpill.c b/source/blender/nodes/composite/nodes/node_composite_colorSpill.c index a6a7f3aa5a3..641026c3aad 100644 --- a/source/blender/nodes/composite/nodes/node_composite_colorSpill.c +++ b/source/blender/nodes/composite/nodes/node_composite_colorSpill.c @@ -57,7 +57,7 @@ static void node_composit_init_color_spill(bNodeTree *UNUSED(ntree), bNode *node void register_node_type_cmp_color_spill(void) { static bNodeType ntype; - + cmp_node_type_base(&ntype, CMP_NODE_COLOR_SPILL, "Color Spill", NODE_CLASS_MATTE, 0); node_type_socket_templates(&ntype, cmp_node_color_spill_in, cmp_node_color_spill_out); node_type_init(&ntype, node_composit_init_color_spill); diff --git a/source/blender/nodes/composite/nodes/node_composite_colorbalance.c b/source/blender/nodes/composite/nodes/node_composite_colorbalance.c index 8370ace8cb3..f9ad8c0ea5f 100644 --- a/source/blender/nodes/composite/nodes/node_composite_colorbalance.c +++ b/source/blender/nodes/composite/nodes/node_composite_colorbalance.c @@ -52,7 +52,7 @@ void ntreeCompositColorBalanceSyncFromLGG(bNodeTree *UNUSED(ntree), bNode *node) { NodeColorBalance *n = node->storage; int c; - + for (c = 0; c < 3; ++c) { n->slope[c] = (2.0f - n->lift[c]) * n->gain[c]; n->offset[c] = (n->lift[c] - 1.0f) * n->gain[c]; @@ -64,7 +64,7 @@ void ntreeCompositColorBalanceSyncFromCDL(bNodeTree *UNUSED(ntree), bNode *node) { NodeColorBalance *n = node->storage; int c; - + for (c = 0; c < 3; ++c) { float d = n->slope[c] + n->offset[c]; n->lift[c] = (d != 0.0f ? n->slope[c] + 2.0f * n->offset[c] / d : 0.0f); diff --git a/source/blender/nodes/composite/nodes/node_composite_common.c b/source/blender/nodes/composite/nodes/node_composite_common.c index 57ec0f1c7ad..de97a5beac3 100644 --- a/source/blender/nodes/composite/nodes/node_composite_common.c +++ b/source/blender/nodes/composite/nodes/node_composite_common.c @@ -43,7 +43,7 @@ void register_node_type_cmp_group(void) { static bNodeType ntype; - + /* NB: cannot use sh_node_type_base for node group, because it would map the node type * to the shared NODE_GROUP integer type id. */ @@ -56,7 +56,7 @@ void register_node_type_cmp_group(void) ntype.ext.srna = RNA_struct_find("CompositorNodeGroup"); BLI_assert(ntype.ext.srna != NULL); RNA_struct_blender_type_set(ntype.ext.srna, &ntype); - + node_type_socket_templates(&ntype, NULL, NULL); node_type_size(&ntype, 140, 60, 400); node_type_label(&ntype, node_group_label); diff --git a/source/blender/nodes/composite/nodes/node_composite_dilate.c b/source/blender/nodes/composite/nodes/node_composite_dilate.c index 4efee112438..72d12e0a643 100644 --- a/source/blender/nodes/composite/nodes/node_composite_dilate.c +++ b/source/blender/nodes/composite/nodes/node_composite_dilate.c @@ -54,7 +54,7 @@ static void node_composit_init_dilateerode(bNodeTree *UNUSED(ntree), bNode *node void register_node_type_cmp_dilateerode(void) { static bNodeType ntype; - + cmp_node_type_base(&ntype, CMP_NODE_DILATEERODE, "Dilate/Erode", NODE_CLASS_OP_FILTER, 0); node_type_socket_templates(&ntype, cmp_node_dilateerode_in, cmp_node_dilateerode_out); node_type_init(&ntype, node_composit_init_dilateerode); diff --git a/source/blender/nodes/composite/nodes/node_composite_ellipsemask.c b/source/blender/nodes/composite/nodes/node_composite_ellipsemask.c index df8ae4931e5..b72a0fb82ae 100644 --- a/source/blender/nodes/composite/nodes/node_composite_ellipsemask.c +++ b/source/blender/nodes/composite/nodes/node_composite_ellipsemask.c @@ -32,7 +32,7 @@ #include "../node_composite_util.h" -/* **************** SCALAR MATH ******************** */ +/* **************** SCALAR MATH ******************** */ static bNodeSocketTemplate cmp_node_ellipsemask_in[] = { { SOCK_FLOAT, 1, N_("Mask"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f}, { SOCK_FLOAT, 1, N_("Value"), 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f}, diff --git a/source/blender/nodes/composite/nodes/node_composite_gamma.c b/source/blender/nodes/composite/nodes/node_composite_gamma.c index 81764c97aac..30d399d3f73 100644 --- a/source/blender/nodes/composite/nodes/node_composite_gamma.c +++ b/source/blender/nodes/composite/nodes/node_composite_gamma.c @@ -47,9 +47,9 @@ static bNodeSocketTemplate cmp_node_gamma_out[] = { void register_node_type_cmp_gamma(void) { static bNodeType ntype; - + cmp_node_type_base(&ntype, CMP_NODE_GAMMA, "Gamma", NODE_CLASS_OP_COLOR, 0); node_type_socket_templates(&ntype, cmp_node_gamma_in, cmp_node_gamma_out); - + nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_huecorrect.c b/source/blender/nodes/composite/nodes/node_composite_huecorrect.c index 4ee1bccd726..70c73bcb46a 100644 --- a/source/blender/nodes/composite/nodes/node_composite_huecorrect.c +++ b/source/blender/nodes/composite/nodes/node_composite_huecorrect.c @@ -47,14 +47,14 @@ static void node_composit_init_huecorrect(bNodeTree *UNUSED(ntree), bNode *node) { CurveMapping *cumapping = node->storage = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); int c; - + cumapping->preset = CURVE_PRESET_MID9; - + for (c = 0; c < 3; c++) { CurveMap *cuma = &cumapping->cm[c]; curvemap_reset(cuma, &cumapping->clipr, cumapping->preset, CURVEMAP_SLOPE_POSITIVE); } - + /* default to showing Saturation */ cumapping->cur = 1; } diff --git a/source/blender/nodes/composite/nodes/node_composite_image.c b/source/blender/nodes/composite/nodes/node_composite_image.c index 4fd7434f632..bf50070e5cb 100644 --- a/source/blender/nodes/composite/nodes/node_composite_image.c +++ b/source/blender/nodes/composite/nodes/node_composite_image.c @@ -149,10 +149,10 @@ static void cmp_node_image_create_outputs(bNodeTree *ntree, bNode *node, LinkNod /* make sure ima->type is correct */ ibuf = BKE_image_acquire_ibuf(ima, &load_iuser, NULL); - + if (ima->rr) { RenderLayer *rl = BLI_findlink(&ima->rr->layers, iuser->layer); - + if (rl) { RenderPass *rpass; for (rpass = rl->passes.first; rpass; rpass = rpass->next) { @@ -250,7 +250,7 @@ static void cmp_node_image_verify_outputs(bNodeTree *ntree, bNode *node, bool rl bNodeSocket *sock, *sock_next; LinkNodePair available_sockets = {NULL, NULL}; int sock_index; - + /* XXX make callback */ if (rlayer) cmp_node_rlayer_create_outputs(ntree, node, &available_sockets); @@ -305,7 +305,7 @@ static void node_composit_init_image(bNodeTree *ntree, bNode *node) iuser->sfra = 1; iuser->fie_ima = 2; iuser->ok = 1; - + /* setup initial outputs */ cmp_node_image_verify_outputs(ntree, node, false); } @@ -313,20 +313,20 @@ static void node_composit_init_image(bNodeTree *ntree, bNode *node) static void node_composit_free_image(bNode *node) { bNodeSocket *sock; - + /* free extra socket info */ for (sock = node->outputs.first; sock; sock = sock->next) MEM_freeN(sock->storage); - + MEM_freeN(node->storage); } static void node_composit_copy_image(bNodeTree *UNUSED(dest_ntree), bNode *dest_node, bNode *src_node) { bNodeSocket *sock; - + dest_node->storage = MEM_dupallocN(src_node->storage); - + /* copy extra socket info */ for (sock = src_node->outputs.first; sock; sock = sock->next) sock->new_sock->storage = MEM_dupallocN(sock->storage); @@ -392,7 +392,7 @@ static int node_composit_poll_rlayers(bNodeType *UNUSED(ntype), bNodeTree *ntree { if (STREQ(ntree->idname, "CompositorNodeTree")) { Scene *scene; - + /* XXX ugly: check if ntree is a local scene node tree. * Render layers node can only be used in local scene->nodetree, * since it directly links to the scene. @@ -400,7 +400,7 @@ static int node_composit_poll_rlayers(bNodeType *UNUSED(ntype), bNodeTree *ntree for (scene = G.main->scene.first; scene; scene = scene->id.next) if (scene->nodetree == ntree) break; - + return (scene != NULL); } return false; diff --git a/source/blender/nodes/composite/nodes/node_composite_inpaint.c b/source/blender/nodes/composite/nodes/node_composite_inpaint.c index a0d3531dabf..f97f366d0c4 100644 --- a/source/blender/nodes/composite/nodes/node_composite_inpaint.c +++ b/source/blender/nodes/composite/nodes/node_composite_inpaint.c @@ -47,7 +47,7 @@ static bNodeSocketTemplate cmp_node_inpaint_out[] = { void register_node_type_cmp_inpaint(void) { static bNodeType ntype; - + cmp_node_type_base(&ntype, CMP_NODE_INPAINT, "Inpaint", NODE_CLASS_OP_FILTER, 0); node_type_socket_templates(&ntype, cmp_node_inpaint_in, cmp_node_inpaint_out); diff --git a/source/blender/nodes/composite/nodes/node_composite_math.c b/source/blender/nodes/composite/nodes/node_composite_math.c index 276dab27f76..e40621d3210 100644 --- a/source/blender/nodes/composite/nodes/node_composite_math.c +++ b/source/blender/nodes/composite/nodes/node_composite_math.c @@ -32,7 +32,7 @@ #include "node_composite_util.h" -/* **************** SCALAR MATH ******************** */ +/* **************** SCALAR MATH ******************** */ static bNodeSocketTemplate cmp_node_math_in[] = { { SOCK_FLOAT, 1, N_("Value"), 0.5f, 0.5f, 0.5f, 1.0f, -10000.0f, 10000.0f, PROP_NONE}, { SOCK_FLOAT, 1, N_("Value"), 0.5f, 0.5f, 0.5f, 1.0f, -10000.0f, 10000.0f, PROP_NONE}, diff --git a/source/blender/nodes/composite/nodes/node_composite_moviedistortion.c b/source/blender/nodes/composite/nodes/node_composite_moviedistortion.c index 9c54009d2f1..4149a0eec9d 100644 --- a/source/blender/nodes/composite/nodes/node_composite_moviedistortion.c +++ b/source/blender/nodes/composite/nodes/node_composite_moviedistortion.c @@ -58,7 +58,7 @@ static void init(const bContext *C, PointerRNA *ptr) { bNode *node = ptr->data; Scene *scene = CTX_data_scene(C); - + node->id = (ID *)scene->clip; } diff --git a/source/blender/nodes/composite/nodes/node_composite_normalize.c b/source/blender/nodes/composite/nodes/node_composite_normalize.c index d93c62f8229..9a5cc84797e 100644 --- a/source/blender/nodes/composite/nodes/node_composite_normalize.c +++ b/source/blender/nodes/composite/nodes/node_composite_normalize.c @@ -46,9 +46,9 @@ static bNodeSocketTemplate cmp_node_normalize_out[] = { void register_node_type_cmp_normalize(void) { static bNodeType ntype; - + cmp_node_type_base(&ntype, CMP_NODE_NORMALIZE, "Normalize", NODE_CLASS_OP_VECTOR, 0); node_type_socket_templates(&ntype, cmp_node_normalize_in, cmp_node_normalize_out); - + nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_outputFile.c b/source/blender/nodes/composite/nodes/node_composite_outputFile.c index 8b349ea8779..a2a25d5c515 100644 --- a/source/blender/nodes/composite/nodes/node_composite_outputFile.c +++ b/source/blender/nodes/composite/nodes/node_composite_outputFile.c @@ -107,16 +107,16 @@ bNodeSocket *ntreeCompositOutputFileAddSocket(bNodeTree *ntree, bNode *node, con { NodeImageMultiFile *nimf = node->storage; bNodeSocket *sock = nodeAddStaticSocket(ntree, node, SOCK_IN, SOCK_RGBA, PROP_NONE, NULL, name); - + /* create format data for the input socket */ NodeImageMultiFileSocket *sockdata = MEM_callocN(sizeof(NodeImageMultiFileSocket), "socket image format"); sock->storage = sockdata; - + BLI_strncpy_utf8(sockdata->path, name, sizeof(sockdata->path)); ntreeCompositOutputFileUniquePath(&node->inputs, sock, name, '_'); BLI_strncpy_utf8(sockdata->layer, name, sizeof(sockdata->layer)); ntreeCompositOutputFileUniqueLayer(&node->inputs, sock, name, '_'); - + if (im_format) { sockdata->format = *im_format; if (BKE_imtype_is_movie(sockdata->format.imtype)) { @@ -129,7 +129,7 @@ bNodeSocket *ntreeCompositOutputFileAddSocket(bNodeTree *ntree, bNode *node, con sockdata->use_node_format = true; nimf->active_input = BLI_findindex(&node->inputs, sock); - + return sock; } @@ -138,16 +138,16 @@ int ntreeCompositOutputFileRemoveActiveSocket(bNodeTree *ntree, bNode *node) NodeImageMultiFile *nimf = node->storage; bNodeSocket *sock = BLI_findlink(&node->inputs, nimf->active_input); int totinputs = BLI_listbase_count(&node->inputs); - + if (!sock) return 0; - + if (nimf->active_input == totinputs - 1) --nimf->active_input; - + /* free format data */ MEM_freeN(sock->storage); - + nodeRemoveSocket(ntree, node, sock); return 1; } @@ -175,7 +175,7 @@ static void init_output_file(const bContext *C, PointerRNA *ptr) NodeImageMultiFile *nimf = MEM_callocN(sizeof(NodeImageMultiFile), "node image multi file"); ImageFormatData *format = NULL; node->storage = nimf; - + if (scene) { RenderData *rd = &scene->r; @@ -184,7 +184,7 @@ static void init_output_file(const bContext *C, PointerRNA *ptr) if (BKE_imtype_is_movie(nimf->format.imtype)) { nimf->format.imtype = R_IMF_IMTYPE_OPENEXR; } - + format = &nimf->format; } else @@ -197,21 +197,21 @@ static void init_output_file(const bContext *C, PointerRNA *ptr) static void free_output_file(bNode *node) { bNodeSocket *sock; - + /* free storage data in sockets */ for (sock = node->inputs.first; sock; sock = sock->next) { MEM_freeN(sock->storage); } - + MEM_freeN(node->storage); } static void copy_output_file(bNodeTree *UNUSED(dest_ntree), bNode *dest_node, bNode *src_node) { bNodeSocket *src_sock, *dest_sock; - + dest_node->storage = MEM_dupallocN(src_node->storage); - + /* duplicate storage data in sockets */ for (src_sock = src_node->inputs.first, dest_sock = dest_node->inputs.first; src_sock && dest_sock; src_sock = src_sock->next, dest_sock = dest_sock->next) { dest_sock->storage = MEM_dupallocN(src_sock->storage); @@ -222,7 +222,7 @@ static void update_output_file(bNodeTree *ntree, bNode *node) { bNodeSocket *sock, *sock_next; PointerRNA ptr; - + /* XXX fix for #36706: remove invalid sockets added with bpy API. * This is not ideal, but prevents crashes from missing storage. * FileOutput node needs a redesign to support this properly. @@ -237,9 +237,9 @@ static void update_output_file(bNodeTree *ntree, bNode *node) sock_next = sock->next; nodeRemoveSocket(ntree, node, sock); } - + cmp_node_update_default(ntree, node); - + /* automatically update the socket type based on linked input */ for (sock = node->inputs.first; sock; sock = sock->next) { if (sock->link) { diff --git a/source/blender/nodes/composite/nodes/node_composite_splitViewer.c b/source/blender/nodes/composite/nodes/node_composite_splitViewer.c index 780ec1592bf..dbe47066f66 100644 --- a/source/blender/nodes/composite/nodes/node_composite_splitViewer.c +++ b/source/blender/nodes/composite/nodes/node_composite_splitViewer.c @@ -49,7 +49,7 @@ static void node_composit_init_splitviewer(bNodeTree *UNUSED(ntree), bNode *node iuser->fie_ima = 2; iuser->ok = 1; node->custom1 = 50; /* default 50% split */ - + node->id = (ID *)BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node"); } diff --git a/source/blender/nodes/composite/nodes/node_composite_stabilize2d.c b/source/blender/nodes/composite/nodes/node_composite_stabilize2d.c index 93ae6b6c4a4..16f5d340ddd 100644 --- a/source/blender/nodes/composite/nodes/node_composite_stabilize2d.c +++ b/source/blender/nodes/composite/nodes/node_composite_stabilize2d.c @@ -50,9 +50,9 @@ static void init(const bContext *C, PointerRNA *ptr) { bNode *node = ptr->data; Scene *scene = CTX_data_scene(C); - + node->id = (ID *)scene->clip; - + /* default to bilinear, see node_sampler_type_items in rna_nodetree.c */ node->custom1 = 1; } diff --git a/source/blender/nodes/composite/nodes/node_composite_valToRgb.c b/source/blender/nodes/composite/nodes/node_composite_valToRgb.c index 1b62f4e77d4..16fc98a5e85 100644 --- a/source/blender/nodes/composite/nodes/node_composite_valToRgb.c +++ b/source/blender/nodes/composite/nodes/node_composite_valToRgb.c @@ -77,10 +77,10 @@ static bNodeSocketTemplate cmp_node_rgbtobw_out[] = { void register_node_type_cmp_rgbtobw(void) { static bNodeType ntype; - + cmp_node_type_base(&ntype, CMP_NODE_RGBTOBW, "RGB to BW", NODE_CLASS_CONVERTOR, 0); node_type_socket_templates(&ntype, cmp_node_rgbtobw_in, cmp_node_rgbtobw_out); node_type_size_preset(&ntype, NODE_SIZE_SMALL); - + nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_viewer.c b/source/blender/nodes/composite/nodes/node_composite_viewer.c index 66f2e2bacbc..a10ba02b38e 100644 --- a/source/blender/nodes/composite/nodes/node_composite_viewer.c +++ b/source/blender/nodes/composite/nodes/node_composite_viewer.c @@ -52,7 +52,7 @@ static void node_composit_init_viewer(bNodeTree *UNUSED(ntree), bNode *node) iuser->ok = 1; node->custom3 = 0.5f; node->custom4 = 0.5f; - + node->id = (ID *)BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node"); } diff --git a/source/blender/nodes/intern/node_common.c b/source/blender/nodes/intern/node_common.c index c465f7a9be5..4a47bf7035c 100644 --- a/source/blender/nodes/intern/node_common.c +++ b/source/blender/nodes/intern/node_common.c @@ -98,16 +98,16 @@ int nodeGroupPoll(bNodeTree *nodetree, bNodeTree *grouptree) { bNode *node; int valid = 1; - + /* unspecified node group, generally allowed * (if anything, should be avoided on operator level) */ if (grouptree == NULL) return 1; - + if (nodetree == grouptree) return 0; - + for (node = grouptree->nodes.first; node; node = node->next) { if (node->typeinfo->poll_instance && !node->typeinfo->poll_instance(node, nodetree)) { valid = 0; @@ -121,27 +121,27 @@ int nodeGroupPoll(bNodeTree *nodetree, bNodeTree *grouptree) static bNodeSocket *group_verify_socket(bNodeTree *ntree, bNode *gnode, bNodeSocket *iosock, ListBase *verify_lb, int in_out) { bNodeSocket *sock; - + for (sock = verify_lb->first; sock; sock = sock->next) { if (STREQ(sock->identifier, iosock->identifier)) break; } if (sock) { strcpy(sock->name, iosock->name); - + if (iosock->typeinfo->interface_verify_socket) iosock->typeinfo->interface_verify_socket(ntree, iosock, gnode, sock, "interface"); } else { sock = nodeAddSocket(ntree, gnode, in_out, iosock->idname, iosock->identifier, iosock->name); - + if (iosock->typeinfo->interface_init_socket) iosock->typeinfo->interface_init_socket(ntree, iosock, gnode, sock, "interface"); } - + /* remove from list temporarily, to distinguish from orphaned sockets */ BLI_remlink(verify_lb, sock); - + return sock; } @@ -150,9 +150,9 @@ static void group_verify_socket_list(bNodeTree *ntree, bNode *gnode, ListBase *iosock_lb, ListBase *verify_lb, int in_out) { bNodeSocket *iosock, *sock, *nextsock; - + /* step by step compare */ - + iosock = iosock_lb->first; for (; iosock; iosock = iosock->next) { /* abusing new_sock pointer for verification here! only used inside this function */ @@ -195,9 +195,9 @@ static void node_frame_init(bNodeTree *UNUSED(ntree), bNode *node) { NodeFrame *data = (NodeFrame *)MEM_callocN(sizeof(NodeFrame), "frame node storage"); node->storage = data; - + data->flag |= NODE_FRAME_SHRINK; - + data->label_size = 20; } @@ -211,7 +211,7 @@ void register_node_type_frame(void) node_type_storage(ntype, "NodeFrame", node_free_standard_storage, node_copy_standard_storage); node_type_size(ntype, 150, 100, 0); node_type_compatibility(ntype, NODE_OLD_SHADING | NODE_NEW_SHADING); - + ntype->needs_free = 1; nodeRegisterType(ntype); } @@ -251,11 +251,11 @@ void register_node_type_reroute(void) { /* frame type is used for all tree types, needs dynamic allocation */ bNodeType *ntype = MEM_callocN(sizeof(bNodeType), "frame node type"); - + node_type_base(ntype, NODE_REROUTE, "Reroute", NODE_CLASS_LAYOUT, 0); node_type_init(ntype, node_reroute_init); node_type_internal_links(ntype, node_reroute_update_internal_links); - + ntype->needs_free = 1; nodeRegisterType(ntype); } @@ -267,14 +267,14 @@ static void node_reroute_inherit_type_recursive(bNodeTree *ntree, bNode *node, i bNodeLink *link; int type = SOCK_FLOAT; const char *type_idname = nodeStaticSocketType(type, PROP_NONE); - + /* XXX it would be a little bit more efficient to restrict actual updates * to rerout nodes connected to an updated node, but there's no reliable flag * to indicate updated nodes (node->update is not set on linking). */ - + node->done = 1; - + /* recursive update */ for (link = ntree->links.first; link; link = link->next) { bNode *fromnode = link->fromnode; @@ -283,7 +283,7 @@ static void node_reroute_inherit_type_recursive(bNodeTree *ntree, bNode *node, i continue; if (nodeLinkIsHidden(link)) continue; - + if (flag & REFINE_FORWARD) { if (tonode == node && fromnode->type == NODE_REROUTE && !fromnode->done) node_reroute_inherit_type_recursive(ntree, fromnode, REFINE_FORWARD); @@ -293,7 +293,7 @@ static void node_reroute_inherit_type_recursive(bNodeTree *ntree, bNode *node, i node_reroute_inherit_type_recursive(ntree, tonode, REFINE_BACKWARD); } } - + /* determine socket type from unambiguous input/output connection if possible */ if (input->limit == 1 && input->link) { type = input->link->fromsock->type; @@ -303,7 +303,7 @@ static void node_reroute_inherit_type_recursive(bNodeTree *ntree, bNode *node, i type = output->link->tosock->type; type_idname = nodeStaticSocketType(type, PROP_NONE); } - + if (input->type != type) { bNodeSocket *ninput = nodeAddSocket(ntree, node, SOCK_IN, type_idname, "input", "Input"); for (link = ntree->links.first; link; link = link->next) { @@ -314,7 +314,7 @@ static void node_reroute_inherit_type_recursive(bNodeTree *ntree, bNode *node, i } nodeRemoveSocket(ntree, node, input); } - + if (output->type != type) { bNodeSocket *noutput = nodeAddSocket(ntree, node, SOCK_OUT, type_idname, "output", "Output"); for (link = ntree->links.first; link; link = link->next) { @@ -324,7 +324,7 @@ static void node_reroute_inherit_type_recursive(bNodeTree *ntree, bNode *node, i } nodeRemoveSocket(ntree, node, output); } - + nodeUpdateInternalLinks(ntree, node); } @@ -334,11 +334,11 @@ static void node_reroute_inherit_type_recursive(bNodeTree *ntree, bNode *node, i void ntree_update_reroute_nodes(bNodeTree *ntree) { bNode *node; - + /* clear tags */ for (node = ntree->nodes.first; node; node = node->next) node->done = 0; - + for (node = ntree->nodes.first; node; node = node->next) if (node->type == NODE_REROUTE && !node->done) node_reroute_inherit_type_recursive(ntree, node, REFINE_FORWARD | REFINE_BACKWARD); @@ -411,7 +411,7 @@ void node_group_input_verify(bNodeTree *ntree, bNode *node, ID *id) if (id == (ID *)ntree) { /* value_in_out inverted for interface nodes to get correct socket value_property */ group_verify_socket_list(ntree, node, &ntree->inputs, &node->outputs, SOCK_OUT); - + /* add virtual extension socket */ nodeAddSocket(ntree, node, SOCK_OUT, "NodeSocketVirtual", "__extend__", ""); } @@ -426,23 +426,23 @@ static void node_group_input_update(bNodeTree *ntree, bNode *node) * so they can be recreated after verification. */ ListBase tmplinks; - + /* find links from the extension socket and store them */ BLI_listbase_clear(&tmplinks); for (link = ntree->links.first; link; link = linknext) { linknext = link->next; if (nodeLinkIsHidden(link)) continue; - + if (link->fromsock == extsock) { bNodeLink *tlink = MEM_callocN(sizeof(bNodeLink), "temporary link"); *tlink = *link; BLI_addtail(&tmplinks, tlink); - + nodeRemLink(ntree, link); } } - + /* find valid link to expose */ exposelink = NULL; for (link = tmplinks.first; link; link = link->next) { @@ -456,22 +456,22 @@ static void node_group_input_update(bNodeTree *ntree, bNode *node) break; } } - + if (exposelink) { bNodeSocket *gsock, *newsock; - + gsock = ntreeAddSocketInterfaceFromSocket(ntree, exposelink->tonode, exposelink->tosock); - + node_group_input_verify(ntree, node, (ID *)ntree); newsock = node_group_input_find_socket(node, gsock->identifier); - + /* redirect links from the extension socket */ for (link = tmplinks.first; link; link = link->next) { nodeAddLink(ntree, node, newsock, link->tonode, link->tosock); } - + } - + BLI_freelistN(&tmplinks); } @@ -479,13 +479,13 @@ void register_node_type_group_input(void) { /* used for all tree types, needs dynamic allocation */ bNodeType *ntype = MEM_callocN(sizeof(bNodeType), "node type"); - + node_type_base(ntype, NODE_GROUP_INPUT, "Group Input", NODE_CLASS_INTERFACE, 0); node_type_size(ntype, 140, 80, 400); node_type_init(ntype, node_group_input_init); node_type_update(ntype, node_group_input_update, node_group_input_verify); node_type_compatibility(ntype, NODE_OLD_SHADING | NODE_NEW_SHADING); - + ntype->needs_free = 1; nodeRegisterType(ntype); } @@ -510,7 +510,7 @@ void node_group_output_verify(bNodeTree *ntree, bNode *node, ID *id) if (id == (ID *)ntree) { /* value_in_out inverted for interface nodes to get correct socket value_property */ group_verify_socket_list(ntree, node, &ntree->outputs, &node->inputs, SOCK_IN); - + /* add virtual extension socket */ nodeAddSocket(ntree, node, SOCK_IN, "NodeSocketVirtual", "__extend__", ""); } @@ -525,23 +525,23 @@ static void node_group_output_update(bNodeTree *ntree, bNode *node) * so they can be recreated after verification. */ ListBase tmplinks; - + /* find links to the extension socket and store them */ BLI_listbase_clear(&tmplinks); for (link = ntree->links.first; link; link = linknext) { linknext = link->next; if (nodeLinkIsHidden(link)) continue; - + if (link->tosock == extsock) { bNodeLink *tlink = MEM_callocN(sizeof(bNodeLink), "temporary link"); *tlink = *link; BLI_addtail(&tmplinks, tlink); - + nodeRemLink(ntree, link); } } - + /* find valid link to expose */ exposelink = NULL; for (link = tmplinks.first; link; link = link->next) { @@ -555,22 +555,22 @@ static void node_group_output_update(bNodeTree *ntree, bNode *node) break; } } - + if (exposelink) { bNodeSocket *gsock, *newsock; - + /* XXX what if connecting virtual to virtual socket?? */ gsock = ntreeAddSocketInterfaceFromSocket(ntree, exposelink->fromnode, exposelink->fromsock); - + node_group_output_verify(ntree, node, (ID *)ntree); newsock = node_group_output_find_socket(node, gsock->identifier); - + /* redirect links to the extension socket */ for (link = tmplinks.first; link; link = link->next) { nodeAddLink(ntree, link->fromnode, link->fromsock, node, newsock); } } - + BLI_freelistN(&tmplinks); } @@ -578,13 +578,13 @@ void register_node_type_group_output(void) { /* used for all tree types, needs dynamic allocation */ bNodeType *ntype = MEM_callocN(sizeof(bNodeType), "node type"); - + node_type_base(ntype, NODE_GROUP_OUTPUT, "Group Output", NODE_CLASS_INTERFACE, 0); node_type_size(ntype, 140, 80, 400); node_type_init(ntype, node_group_output_init); node_type_update(ntype, node_group_output_update, node_group_output_verify); node_type_compatibility(ntype, NODE_OLD_SHADING | NODE_NEW_SHADING); - + ntype->needs_free = 1; nodeRegisterType(ntype); } diff --git a/source/blender/nodes/intern/node_exec.c b/source/blender/nodes/intern/node_exec.c index 9782c2f4a2c..a5be5dad534 100644 --- a/source/blender/nodes/intern/node_exec.c +++ b/source/blender/nodes/intern/node_exec.c @@ -61,14 +61,14 @@ bNodeStack *node_get_socket_stack(bNodeStack *stack, bNodeSocket *sock) void node_get_stack(bNode *node, bNodeStack *stack, bNodeStack **in, bNodeStack **out) { bNodeSocket *sock; - + /* build pointer stack */ if (in) { for (sock = node->inputs.first; sock; sock = sock->next) { *(in++) = node_get_socket_stack(stack, sock); } } - + if (out) { for (sock = node->outputs.first; sock; sock = sock->next) { *(out++) = node_get_socket_stack(stack, sock); @@ -127,13 +127,13 @@ static struct bNodeStack *setup_stack(bNodeStack *stack, bNodeTree *ntree, bNode bNodeStack *ns = node_get_socket_stack(stack, sock); if (!ns) return NULL; - + /* don't mess with remote socket stacks, these are initialized by other nodes! */ if (sock->link) return ns; - + ns->sockettype = sock->type; - + switch (sock->type) { case SOCK_FLOAT: ns->vec[0] = node_socket_get_float(ntree, node, sock); @@ -145,7 +145,7 @@ static struct bNodeStack *setup_stack(bNodeStack *stack, bNodeTree *ntree, bNode node_socket_get_color(ntree, node, sock, ns->vec); break; } - + return ns; } @@ -161,29 +161,29 @@ bNodeTreeExec *ntree_exec_begin(bNodeExecContext *context, bNodeTree *ntree, bNo bNode **nodelist; int totnodes, n; /* XXX texnodes have threading issues with muting, have to disable it there ... */ - + /* ensure all sock->link pointers and node levels are correct */ ntreeUpdateTree(G.main, ntree); - + /* get a dependency-sorted list of nodes */ ntreeGetDependencyList(ntree, &nodelist, &totnodes); - + /* XXX could let callbacks do this for specialized data */ exec = MEM_callocN(sizeof(bNodeTreeExec), "node tree execution data"); /* backpointer to node tree */ exec->nodetree = ntree; - + /* set stack indices */ index = 0; for (n = 0; n < totnodes; ++n) { node = nodelist[n]; - + node->stack_index = index; - + /* init node socket stack indexes */ for (sock = node->inputs.first; sock; sock = sock->next) node_init_input_index(sock, &index); - + if (node->flag & NODE_MUTED || node->type == NODE_REROUTE) { for (sock = node->outputs.first; sock; sock = sock->next) node_init_output_index(sock, &index, &node->internal_links); @@ -193,48 +193,48 @@ bNodeTreeExec *ntree_exec_begin(bNodeExecContext *context, bNodeTree *ntree, bNo node_init_output_index(sock, &index, NULL); } } - + /* allocated exec data pointers for nodes */ exec->totnodes = totnodes; exec->nodeexec = MEM_callocN(exec->totnodes * sizeof(bNodeExec), "node execution data"); /* allocate data pointer for node stack */ exec->stacksize = index; exec->stack = MEM_callocN(exec->stacksize * sizeof(bNodeStack), "bNodeStack"); - + /* all non-const results are considered inputs */ for (n = 0; n < exec->stacksize; ++n) exec->stack[n].hasinput = 1; - + /* prepare all nodes for execution */ for (n = 0, nodeexec = exec->nodeexec; n < totnodes; ++n, ++nodeexec) { node = nodeexec->node = nodelist[n]; nodeexec->freeexecfunc = node->typeinfo->freeexecfunc; - + /* tag inputs */ for (sock = node->inputs.first; sock; sock = sock->next) { /* disable the node if an input link is invalid */ if (sock->link && !(sock->link->flag & NODE_LINK_VALID)) node->need_exec = 0; - + ns = setup_stack(exec->stack, ntree, node, sock); if (ns) ns->hasoutput = 1; } - + /* tag all outputs */ for (sock = node->outputs.first; sock; sock = sock->next) { /* ns = */ setup_stack(exec->stack, ntree, node, sock); } - + nodekey = BKE_node_instance_key(parent_key, ntree, node); nodeexec->data.preview = context->previews ? BKE_node_instance_hash_lookup(context->previews, nodekey) : NULL; if (node->typeinfo->initexecfunc) nodeexec->data.data = node->typeinfo->initexecfunc(context, node, nodekey); } - + if (nodelist) MEM_freeN(nodelist); - + return exec; } @@ -242,18 +242,18 @@ void ntree_exec_end(bNodeTreeExec *exec) { bNodeExec *nodeexec; int n; - + if (exec->stack) MEM_freeN(exec->stack); - + for (n = 0, nodeexec = exec->nodeexec; n < exec->totnodes; ++n, ++nodeexec) { if (nodeexec->freeexecfunc) nodeexec->freeexecfunc(nodeexec->data.data); } - + if (exec->nodeexec) MEM_freeN(exec->nodeexec); - + MEM_freeN(exec); } @@ -263,14 +263,14 @@ bNodeThreadStack *ntreeGetThreadStack(bNodeTreeExec *exec, int thread) { ListBase *lb = &exec->threadstack[thread]; bNodeThreadStack *nts; - + for (nts = lb->first; nts; nts = nts->next) { if (!nts->used) { nts->used = true; break; } } - + if (!nts) { nts = MEM_callocN(sizeof(bNodeThreadStack), "bNodeThreadStack"); nts->stack = MEM_dupallocN(exec->stack); @@ -293,9 +293,9 @@ bool ntreeExecThreadNodes(bNodeTreeExec *exec, bNodeThreadStack *nts, void *call bNodeExec *nodeexec; bNode *node; int n; - + /* nodes are presorted, so exec is in order of list */ - + for (n = 0, nodeexec = exec->nodeexec; n < exec->totnodes; ++n, ++nodeexec) { node = nodeexec->node; if (node->need_exec) { @@ -310,7 +310,7 @@ bool ntreeExecThreadNodes(bNodeTreeExec *exec, bNodeThreadStack *nts, void *call node->typeinfo->execfunc(callerdata, thread, node, &nodeexec->data, nsin, nsout); } } - + /* signal to that all went OK, for render */ return true; } diff --git a/source/blender/nodes/intern/node_exec.h b/source/blender/nodes/intern/node_exec.h index bf4c29bad8e..6771df76bf9 100644 --- a/source/blender/nodes/intern/node_exec.h +++ b/source/blender/nodes/intern/node_exec.h @@ -51,17 +51,17 @@ struct bNodeStack; typedef struct bNodeExec { struct bNode *node; /* backpointer to node */ bNodeExecData data; - + NodeFreeExecFunction freeexecfunc; /* free function, stored in exec itself to avoid dangling node pointer access */ } bNodeExec; /* Execution Data for each instance of node tree execution */ typedef struct bNodeTreeExec { struct bNodeTree *nodetree; /* backpointer to node tree */ - + int totnodes; /* total node count */ struct bNodeExec *nodeexec; /* per-node execution data */ - + int stacksize; struct bNodeStack *stack; /* socket data stack */ /* only used by material and texture trees to keep one stack for each thread */ diff --git a/source/blender/nodes/intern/node_socket.c b/source/blender/nodes/intern/node_socket.c index 6e2cdb65a86..d1903a53334 100644 --- a/source/blender/nodes/intern/node_socket.c +++ b/source/blender/nodes/intern/node_socket.c @@ -52,9 +52,9 @@ struct Main; struct bNodeSocket *node_add_socket_from_template(struct bNodeTree *ntree, struct bNode *node, struct bNodeSocketTemplate *stemp, int in_out) { bNodeSocket *sock = nodeAddStaticSocket(ntree, node, in_out, stemp->type, stemp->subtype, stemp->identifier, stemp->name); - + sock->flag |= stemp->flag; - + /* initialize default_value */ switch (stemp->type) { case SOCK_FLOAT: @@ -99,14 +99,14 @@ struct bNodeSocket *node_add_socket_from_template(struct bNodeTree *ntree, struc break; } } - + return sock; } static bNodeSocket *verify_socket_template(bNodeTree *ntree, bNode *node, int in_out, ListBase *socklist, bNodeSocketTemplate *stemp) { bNodeSocket *sock; - + for (sock = socklist->first; sock; sock = sock->next) { if (STREQLEN(sock->name, stemp->name, NODE_MAXSTR)) break; @@ -127,7 +127,7 @@ static bNodeSocket *verify_socket_template(bNodeTree *ntree, bNode *node, int in /* remove the new socket from the node socket list first, * will be added back after verification. */ BLI_remlink(socklist, sock); - + return sock; } @@ -135,7 +135,7 @@ static void verify_socket_template_list(bNodeTree *ntree, bNode *node, int in_ou { bNodeSocket *sock, *nextsock; bNodeSocketTemplate *stemp; - + /* no inputs anymore? */ if (stemp_first == NULL) { for (sock = (bNodeSocket *)socklist->first; sock; sock = nextsock) { @@ -155,7 +155,7 @@ static void verify_socket_template_list(bNodeTree *ntree, bNode *node, int in_ou nextsock = sock->next; nodeRemoveSocket(ntree, node, sock); } - + /* and we put back the verified sockets */ stemp = stemp_first; if (socklist->first) { @@ -199,10 +199,10 @@ void node_socket_init_default_value(bNodeSocket *sock) { int type = sock->typeinfo->type; int subtype = sock->typeinfo->subtype; - + if (sock->default_value) return; /* already initialized */ - + switch (type) { case SOCK_FLOAT: { @@ -211,7 +211,7 @@ void node_socket_init_default_value(bNodeSocket *sock) dval->value = 0.0f; dval->min = -FLT_MAX; dval->max = FLT_MAX; - + sock->default_value = dval; break; } @@ -222,7 +222,7 @@ void node_socket_init_default_value(bNodeSocket *sock) dval->value = 0; dval->min = INT_MIN; dval->max = INT_MAX; - + sock->default_value = dval; break; } @@ -230,7 +230,7 @@ void node_socket_init_default_value(bNodeSocket *sock) { bNodeSocketValueBoolean *dval = MEM_callocN(sizeof(bNodeSocketValueBoolean), "node socket value bool"); dval->value = false; - + sock->default_value = dval; break; } @@ -242,7 +242,7 @@ void node_socket_init_default_value(bNodeSocket *sock) copy_v3_v3(dval->value, default_value); dval->min = -FLT_MAX; dval->max = FLT_MAX; - + sock->default_value = dval; break; } @@ -251,7 +251,7 @@ void node_socket_init_default_value(bNodeSocket *sock) static float default_value[] = { 0.0f, 0.0f, 0.0f, 1.0f }; bNodeSocketValueRGBA *dval = MEM_callocN(sizeof(bNodeSocketValueRGBA), "node socket value color"); copy_v4_v4(dval->value, default_value); - + sock->default_value = dval; break; } @@ -260,7 +260,7 @@ void node_socket_init_default_value(bNodeSocket *sock) bNodeSocketValueString *dval = MEM_callocN(sizeof(bNodeSocketValueString), "node socket value string"); dval->subtype = subtype; dval->value[0] = '\0'; - + sock->default_value = dval; break; } @@ -272,12 +272,12 @@ void node_socket_copy_default_value(bNodeSocket *to, bNodeSocket *from) /* sanity check */ if (to->type != from->type) return; - + /* make sure both exist */ if (!from->default_value) return; node_socket_init_default_value(to); - + switch (from->typeinfo->type) { case SOCK_FLOAT: { @@ -330,7 +330,7 @@ static void standard_node_socket_interface_init_socket(bNodeTree *UNUSED(ntree), { /* initialize the type value */ sock->type = sock->typeinfo->type; - + /* XXX socket interface 'type' value is not used really, * but has to match or the copy function will bail out */ @@ -345,12 +345,12 @@ static void standard_node_socket_interface_verify_socket(bNodeTree *UNUSED(ntree /* sanity check */ if (sock->type != stemp->typeinfo->type) return; - + /* make sure both exist */ if (!stemp->default_value) return; node_socket_init_default_value(sock); - + switch (stemp->typeinfo->type) { case SOCK_FLOAT: { @@ -389,65 +389,65 @@ static void standard_node_socket_interface_from_socket(bNodeTree *UNUSED(ntree), static bNodeSocketType *make_standard_socket_type(int type, int subtype) { extern void ED_init_standard_node_socket_type(bNodeSocketType *); - + const char *socket_idname = nodeStaticSocketType(type, subtype); const char *interface_idname = nodeStaticSocketInterfaceType(type, subtype); bNodeSocketType *stype; StructRNA *srna; - + stype = MEM_callocN(sizeof(bNodeSocketType), "node socket C type"); BLI_strncpy(stype->idname, socket_idname, sizeof(stype->idname)); - + /* set the RNA type * uses the exact same identifier as the socket type idname */ srna = stype->ext_socket.srna = RNA_struct_find(socket_idname); BLI_assert(srna != NULL); /* associate the RNA type with the socket type */ RNA_struct_blender_type_set(srna, stype); - + /* set the interface RNA type */ srna = stype->ext_interface.srna = RNA_struct_find(interface_idname); BLI_assert(srna != NULL); /* associate the RNA type with the socket type */ RNA_struct_blender_type_set(srna, stype); - + /* extra type info for standard socket types */ stype->type = type; stype->subtype = subtype; - + /* XXX bad-level call! needed for setting draw callbacks */ ED_init_standard_node_socket_type(stype); - + stype->interface_init_socket = standard_node_socket_interface_init_socket; stype->interface_from_socket = standard_node_socket_interface_from_socket; stype->interface_verify_socket = standard_node_socket_interface_verify_socket; - + return stype; } static bNodeSocketType *make_socket_type_virtual(void) { extern void ED_init_node_socket_type_virtual(bNodeSocketType *); - + const char *socket_idname = "NodeSocketVirtual"; bNodeSocketType *stype; StructRNA *srna; - + stype = MEM_callocN(sizeof(bNodeSocketType), "node socket C type"); BLI_strncpy(stype->idname, socket_idname, sizeof(stype->idname)); - + /* set the RNA type * uses the exact same identifier as the socket type idname */ srna = stype->ext_socket.srna = RNA_struct_find(socket_idname); BLI_assert(srna != NULL); /* associate the RNA type with the socket type */ RNA_struct_blender_type_set(srna, stype); - + /* extra type info for standard socket types */ stype->type = SOCK_CUSTOM; - + ED_init_node_socket_type_virtual(stype); - + return stype; } @@ -455,21 +455,21 @@ static bNodeSocketType *make_socket_type_virtual(void) void register_standard_node_socket_types(void) { /* draw callbacks are set in drawnode.c to avoid bad-level calls */ - + nodeRegisterSocketType(make_standard_socket_type(SOCK_FLOAT, PROP_NONE)); nodeRegisterSocketType(make_standard_socket_type(SOCK_FLOAT, PROP_UNSIGNED)); nodeRegisterSocketType(make_standard_socket_type(SOCK_FLOAT, PROP_PERCENTAGE)); nodeRegisterSocketType(make_standard_socket_type(SOCK_FLOAT, PROP_FACTOR)); nodeRegisterSocketType(make_standard_socket_type(SOCK_FLOAT, PROP_ANGLE)); nodeRegisterSocketType(make_standard_socket_type(SOCK_FLOAT, PROP_TIME)); - + nodeRegisterSocketType(make_standard_socket_type(SOCK_INT, PROP_NONE)); nodeRegisterSocketType(make_standard_socket_type(SOCK_INT, PROP_UNSIGNED)); nodeRegisterSocketType(make_standard_socket_type(SOCK_INT, PROP_PERCENTAGE)); nodeRegisterSocketType(make_standard_socket_type(SOCK_INT, PROP_FACTOR)); - + nodeRegisterSocketType(make_standard_socket_type(SOCK_BOOLEAN, PROP_NONE)); - + nodeRegisterSocketType(make_standard_socket_type(SOCK_VECTOR, PROP_NONE)); nodeRegisterSocketType(make_standard_socket_type(SOCK_VECTOR, PROP_TRANSLATION)); nodeRegisterSocketType(make_standard_socket_type(SOCK_VECTOR, PROP_DIRECTION)); @@ -477,12 +477,12 @@ void register_standard_node_socket_types(void) nodeRegisterSocketType(make_standard_socket_type(SOCK_VECTOR, PROP_ACCELERATION)); nodeRegisterSocketType(make_standard_socket_type(SOCK_VECTOR, PROP_EULER)); nodeRegisterSocketType(make_standard_socket_type(SOCK_VECTOR, PROP_XYZ)); - + nodeRegisterSocketType(make_standard_socket_type(SOCK_RGBA, PROP_NONE)); - + nodeRegisterSocketType(make_standard_socket_type(SOCK_STRING, PROP_NONE)); - + nodeRegisterSocketType(make_standard_socket_type(SOCK_SHADER, PROP_NONE)); - + nodeRegisterSocketType(make_socket_type_virtual()); } diff --git a/source/blender/nodes/intern/node_util.c b/source/blender/nodes/intern/node_util.c index 45409a2dfad..19529794c7c 100644 --- a/source/blender/nodes/intern/node_util.c +++ b/source/blender/nodes/intern/node_util.c @@ -165,10 +165,10 @@ static int node_count_links(bNodeTree *ntree, bNodeSocket *sock) static bNodeSocket *node_find_linkable_socket(bNodeTree *ntree, bNode *node, bNodeSocket *cur) { /* link swapping: try to find a free slot with a matching name */ - + bNodeSocket *first = cur->in_out == SOCK_IN ? node->inputs.first : node->outputs.first; bNodeSocket *sock; - + sock = cur->next ? cur->next : first; /* wrap around the list end */ while (sock != cur) { if (!nodeSocketIsHidden(sock) && node_link_socket_match(sock, cur)) { @@ -177,7 +177,7 @@ static bNodeSocket *node_find_linkable_socket(bNodeTree *ntree, bNode *node, bNo if (link_count + 1 <= sock->limit) return sock; /* found a valid free socket we can swap to */ } - + sock = sock->next ? sock->next : first; /* wrap around the list end */ } return NULL; @@ -187,18 +187,18 @@ void node_insert_link_default(bNodeTree *ntree, bNode *node, bNodeLink *link) { bNodeSocket *sock = link->tosock; bNodeLink *tlink, *tlink_next; - + /* inputs can have one link only, outputs can have unlimited links */ if (node != link->tonode) return; - + for (tlink = ntree->links.first; tlink; tlink = tlink_next) { bNodeSocket *new_sock; tlink_next = tlink->next; - + if (sock != tlink->tosock) continue; - + new_sock = node_find_linkable_socket(ntree, node, sock); if (new_sock && new_sock != sock) { /* redirect existing link */ @@ -287,12 +287,12 @@ static bNodeSocket *select_internal_link_input(bNode *node, bNodeSocket *output) int i; int sel_priority = -1; bool sel_is_linked = false; - + for (input = node->inputs.first, i = 0; input; input = input->next, ++i) { int priority = node_datatype_priority(input->type, output->type); bool is_linked = (input->link != NULL); bool preferred; - + if (nodeSocketIsHidden(input) || /* ignore hidden sockets */ input->flag & SOCK_NO_INTERNAL_LINK || /* ignore if input is not allowed for internal connections */ priority < 0 || /* ignore incompatible types */ @@ -300,18 +300,18 @@ static bNodeSocket *select_internal_link_input(bNode *node, bNodeSocket *output) { continue; } - + /* determine if this input is preferred over the currently selected */ preferred = (priority > sel_priority) || /* prefer higher datatype priority */ (is_linked && !sel_is_linked); /* prefer linked over unlinked */ - + if (preferred) { selected = input; sel_is_linked = is_linked; sel_priority = priority; } } - + return selected; } @@ -319,29 +319,29 @@ void node_update_internal_links_default(bNodeTree *ntree, bNode *node) { bNodeLink *link; bNodeSocket *output, *input; - + /* sanity check */ if (!ntree) return; - + /* use link pointer as a tag for handled sockets (for outputs is unused anyway) */ for (output = node->outputs.first; output; output = output->next) output->link = NULL; - + for (link = ntree->links.first; link; link = link->next) { if (nodeLinkIsHidden(link)) continue; - + output = link->fromsock; if (link->fromnode != node || output->link) continue; if (nodeSocketIsHidden(output) || output->flag & SOCK_NO_INTERNAL_LINK) continue; output->link = link; /* not really used, just for tagging handled sockets */ - + /* look for suitable input */ input = select_internal_link_input(node, output); - + if (input) { bNodeLink *ilink = MEM_callocN(sizeof(bNodeLink), "internal node link"); ilink->fromnode = node; @@ -353,7 +353,7 @@ void node_update_internal_links_default(bNodeTree *ntree, bNode *node) BLI_addtail(&node->internal_links, ilink); } } - + /* clean up */ for (output = node->outputs.first; output; output = output->next) output->link = NULL; diff --git a/source/blender/nodes/shader/node_shader_tree.c b/source/blender/nodes/shader/node_shader_tree.c index 420dbc431d1..34ec76df710 100644 --- a/source/blender/nodes/shader/node_shader_tree.c +++ b/source/blender/nodes/shader/node_shader_tree.c @@ -80,7 +80,7 @@ static void shader_get_from_context(const bContext *C, bNodeTreeType *UNUSED(tre SpaceNode *snode = CTX_wm_space_node(C); Scene *scene = CTX_data_scene(C); Object *ob = OBACT; - + if ((snode->shaderfrom == SNODE_SHADER_OBJECT) || (BKE_scene_use_new_shading_nodes(scene) == false)) { @@ -127,7 +127,7 @@ static void foreach_nodeclass(Scene *scene, void *calldata, bNodeClassCallback f func(calldata, NODE_CLASS_SHADER, N_("Shader")); func(calldata, NODE_CLASS_TEXTURE, N_("Texture")); } - + func(calldata, NODE_CLASS_OP_COLOR, N_("Color")); func(calldata, NODE_CLASS_OP_VECTOR, N_("Vector")); func(calldata, NODE_CLASS_CONVERTOR, N_("Convertor")); @@ -140,11 +140,11 @@ static void foreach_nodeclass(Scene *scene, void *calldata, bNodeClassCallback f static void localize(bNodeTree *localtree, bNodeTree *UNUSED(ntree)) { bNode *node, *node_next; - + /* replace muted nodes and reroute nodes by internal links */ for (node = localtree->nodes.first; node; node = node_next) { node_next = node->next; - + if (node->flag & NODE_MUTED || node->type == NODE_REROUTE) { nodeInternalRelink(localtree, node); nodeFreeNode(localtree, node); @@ -165,9 +165,9 @@ static void local_merge(bNodeTree *localtree, bNodeTree *ntree) static void update(bNodeTree *ntree) { ntreeSetOutput(ntree); - + ntree_update_reroute_nodes(ntree); - + if (ntree->update & NTREE_UPDATE_NODES) { /* clean up preview cache, in case nodes have been removed */ BKE_node_preview_remove_unused(ntree); @@ -179,13 +179,13 @@ bNodeTreeType *ntreeType_Shader; void register_node_tree_type_sh(void) { bNodeTreeType *tt = ntreeType_Shader = MEM_callocN(sizeof(bNodeTreeType), "shader node tree type"); - + tt->type = NTREE_SHADER; strcpy(tt->idname, "ShaderNodeTree"); strcpy(tt->ui_name, "Shader"); tt->ui_icon = 0; /* defined in drawnode.c */ strcpy(tt->ui_description, "Shader nodes"); - + tt->foreach_nodeclass = foreach_nodeclass; tt->localize = localize; tt->local_sync = local_sync; @@ -193,9 +193,9 @@ void register_node_tree_type_sh(void) tt->update = update; tt->poll = shader_tree_poll; tt->get_from_context = shader_get_from_context; - + tt->ext.srna = &RNA_ShaderNodeTree; - + ntreeTypeAdd(tt); } @@ -524,19 +524,19 @@ bNodeTreeExec *ntreeShaderBeginExecTree_internal(bNodeExecContext *context, bNod { bNodeTreeExec *exec; bNode *node; - + /* ensures only a single output node is enabled */ ntreeSetOutput(ntree); - + /* common base initialization */ exec = ntree_exec_begin(context, ntree, parent_key); - + /* allocate the thread stack listbase array */ exec->threadstack = MEM_callocN(BLENDER_MAX_THREADS * sizeof(ListBase), "thread stack array"); - + for (node = exec->nodetree->nodes.first; node; node = node->next) node->need_exec = 1; - + return exec; } @@ -544,22 +544,22 @@ bNodeTreeExec *ntreeShaderBeginExecTree(bNodeTree *ntree) { bNodeExecContext context; bNodeTreeExec *exec; - + /* XXX hack: prevent exec data from being generated twice. * this should be handled by the renderer! */ if (ntree->execdata) return ntree->execdata; - + context.previews = ntree->previews; - + exec = ntreeShaderBeginExecTree_internal(&context, ntree, NODE_INSTANCE_KEY_BASE); - + /* XXX this should not be necessary, but is still used for cmp/sha/tex nodes, * which only store the ntree pointer. Should be fixed at some point! */ ntree->execdata = exec; - + return exec; } @@ -567,18 +567,18 @@ void ntreeShaderEndExecTree_internal(bNodeTreeExec *exec) { bNodeThreadStack *nts; int a; - + if (exec->threadstack) { for (a = 0; a < BLENDER_MAX_THREADS; a++) { for (nts = exec->threadstack[a].first; nts; nts = nts->next) if (nts->stack) MEM_freeN(nts->stack); BLI_freelistN(&exec->threadstack[a]); } - + MEM_freeN(exec->threadstack); exec->threadstack = NULL; } - + ntree_exec_end(exec); } @@ -588,7 +588,7 @@ void ntreeShaderEndExecTree(bNodeTreeExec *exec) /* exec may get freed, so assign ntree */ bNodeTree *ntree = exec->nodetree; ntreeShaderEndExecTree_internal(exec); - + /* XXX clear nodetree backpointer to exec data, same problem as noted in ntreeBeginExecTree */ ntree->execdata = NULL; } @@ -606,14 +606,14 @@ bool ntreeShaderExecTree(bNodeTree *ntree, ShadeInput *shi, ShadeResult *shr) bNodeThreadStack *nts = NULL; bNodeTreeExec *exec = ntree->execdata; int compat; - + /* convert caller data to struct */ scd.shi = shi; scd.shr = shr; - + /* each material node has own local shaderesult, with optional copying */ memset(shr, 0, sizeof(ShadeResult)); - + /* ensure execdata is only initialized once */ if (!exec) { BLI_thread_lock(LOCK_NODES); @@ -623,19 +623,19 @@ bool ntreeShaderExecTree(bNodeTree *ntree, ShadeInput *shi, ShadeResult *shr) exec = ntree->execdata; } - + nts = ntreeGetThreadStack(exec, shi->thread); compat = ntreeExecThreadNodes(exec, nts, &scd, shi->thread); ntreeReleaseThreadStack(nts); - + // \note: set material back to preserved material shi->mat = mat; - + /* better not allow negative for now */ if (shr->combined[0] < 0.0f) shr->combined[0] = 0.0f; if (shr->combined[1] < 0.0f) shr->combined[1] = 0.0f; if (shr->combined[2] < 0.0f) shr->combined[2] = 0.0f; - + /* if compat is zero, it has been using non-compatible nodes */ return compat; } diff --git a/source/blender/nodes/shader/node_shader_util.c b/source/blender/nodes/shader/node_shader_util.c index da8b0ee42be..b25a6c2bba0 100644 --- a/source/blender/nodes/shader/node_shader_util.c +++ b/source/blender/nodes/shader/node_shader_util.c @@ -45,7 +45,7 @@ int sh_node_poll_default(bNodeType *UNUSED(ntype), bNodeTree *ntree) void sh_node_type_base(struct bNodeType *ntype, int type, const char *name, short nclass, short flag) { node_type_base(ntype, type, name, nclass, flag); - + ntype->poll = sh_node_poll_default; ntype->insert_link = node_insert_link_default; ntype->update_internal_links = node_update_internal_links_default; @@ -56,11 +56,11 @@ void sh_node_type_base(struct bNodeType *ntype, int type, const char *name, shor void nodestack_get_vec(float *in, short type_in, bNodeStack *ns) { const float *from = ns->vec; - + if (type_in == SOCK_FLOAT) { if (ns->sockettype == SOCK_FLOAT) *in = *from; - else + else *in = (from[0] + from[1] + from[2]) / 3.0f; } else if (type_in == SOCK_VECTOR) { @@ -98,7 +98,7 @@ void ntreeShaderGetTexcoMode(bNodeTree *ntree, int r_mode, short *texco, int *mo bNode *node; bNodeSocket *sock; int a; - + for (node = ntree->nodes.first; node; node = node->next) { if (node->type == SH_NODE_TEXTURE) { if ((r_mode & R_OSA) && node->id) { @@ -117,15 +117,15 @@ void ntreeShaderGetTexcoMode(bNodeTree *ntree, int r_mode, short *texco, int *mo for (a = 0, sock = node->outputs.first; sock; sock = sock->next, a++) { if (sock->flag & SOCK_IN_USE) { switch (a) { - case GEOM_OUT_GLOB: + case GEOM_OUT_GLOB: *texco |= TEXCO_GLOB | NEED_UV; break; - case GEOM_OUT_VIEW: + case GEOM_OUT_VIEW: *texco |= TEXCO_VIEW | NEED_UV; break; - case GEOM_OUT_ORCO: + case GEOM_OUT_ORCO: *texco |= TEXCO_ORCO | NEED_UV; break; - case GEOM_OUT_UV: + case GEOM_OUT_UV: *texco |= TEXCO_UV | NEED_UV; break; - case GEOM_OUT_NORMAL: + case GEOM_OUT_NORMAL: *texco |= TEXCO_NORM | NEED_UV; break; case GEOM_OUT_VCOL: *texco |= NEED_UV; *mode |= MA_VERTEXCOL; break; @@ -141,7 +141,7 @@ void ntreeShaderGetTexcoMode(bNodeTree *ntree, int r_mode, short *texco, int *mo void node_gpu_stack_from_data(struct GPUNodeStack *gs, int type, bNodeStack *ns) { memset(gs, 0, sizeof(*gs)); - + if (ns == NULL) { /* node_get_stack() will generate NULL bNodeStack pointers for unknown/unsuported types of sockets... */ zero_v4(gs->vec); @@ -155,7 +155,7 @@ void node_gpu_stack_from_data(struct GPUNodeStack *gs, int type, bNodeStack *ns) else { nodestack_get_vec(gs->vec, type, ns); gs->link = ns->data; - + if (type == SOCK_FLOAT) gs->type = GPU_FLOAT; else if (type == SOCK_VECTOR) @@ -189,10 +189,10 @@ static void gpu_stack_from_data_list(GPUNodeStack *gs, ListBase *sockets, bNodeS { bNodeSocket *sock; int i; - + for (sock = sockets->first, i = 0; sock; sock = sock->next, i++) node_gpu_stack_from_data(&gs[i], sock->type, ns[i]); - + gs[i].type = GPU_NONE; } @@ -241,7 +241,7 @@ bNode *nodeGetActiveTexture(bNodeTree *ntree) if (activetexnode) return activetexnode; - + if (hasgroup) { /* node active texture node in this tree, look inside groups */ for (node = ntree->nodes.first; node; node = node->next) { @@ -252,7 +252,7 @@ bNode *nodeGetActiveTexture(bNodeTree *ntree) } } } - + return inactivenode; } @@ -271,7 +271,7 @@ void ntreeExecGPUNodes(bNodeTreeExec *exec, GPUMaterial *mat, int do_outputs, sh for (n = 0, nodeexec = exec->nodeexec; n < exec->totnodes; ++n, ++nodeexec) { node = nodeexec->node; - + do_it = false; /* for groups, only execute outputs for edited group */ if (node->typeinfo->nclass == NODE_CLASS_OUTPUT) { diff --git a/source/blender/nodes/shader/nodes/node_shader_brightness.c b/source/blender/nodes/shader/nodes/node_shader_brightness.c index 75a3f7ca5a2..75e258bd27d 100644 --- a/source/blender/nodes/shader/nodes/node_shader_brightness.c +++ b/source/blender/nodes/shader/nodes/node_shader_brightness.c @@ -50,13 +50,13 @@ static int gpu_shader_brightcontrast(GPUMaterial *mat, bNode *UNUSED(node), bNod void register_node_type_sh_brightcontrast(void) { static bNodeType ntype; - + sh_node_type_base(&ntype, SH_NODE_BRIGHTCONTRAST, "Bright/Contrast", NODE_CLASS_OP_COLOR, 0); node_type_compatibility(&ntype, NODE_NEW_SHADING); node_type_socket_templates(&ntype, sh_node_brightcontrast_in, sh_node_brightcontrast_out); node_type_init(&ntype, NULL); node_type_storage(&ntype, "", NULL, NULL); node_type_gpu(&ntype, gpu_shader_brightcontrast); - + nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_bump.c b/source/blender/nodes/shader/nodes/node_shader_bump.c index 65da3485fc3..41df17cef67 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bump.c +++ b/source/blender/nodes/shader/nodes/node_shader_bump.c @@ -31,7 +31,7 @@ #include "node_shader_util.h" -/* **************** BUMP ******************** */ +/* **************** BUMP ******************** */ static bNodeSocketTemplate sh_node_bump_in[] = { { SOCK_FLOAT, 1, N_("Strength"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, { SOCK_FLOAT, 1, N_("Distance"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f}, diff --git a/source/blender/nodes/shader/nodes/node_shader_camera.c b/source/blender/nodes/shader/nodes/node_shader_camera.c index 869f24537ef..b1c3a817b84 100644 --- a/source/blender/nodes/shader/nodes/node_shader_camera.c +++ b/source/blender/nodes/shader/nodes/node_shader_camera.c @@ -45,7 +45,7 @@ static void node_shader_exec_camera(void *data, int UNUSED(thread), bNode *UNUSE { if (data) { ShadeInput *shi = ((ShaderCallData *)data)->shi; /* Data we need for shading. */ - + copy_v3_v3(out[0]->vec, shi->co); /* get view vector */ out[1]->vec[0] = fabsf(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_common.c b/source/blender/nodes/shader/nodes/node_shader_common.c index 134319cb352..24de03dbda4 100644 --- a/source/blender/nodes/shader/nodes/node_shader_common.c +++ b/source/blender/nodes/shader/nodes/node_shader_common.c @@ -50,7 +50,7 @@ static void copy_stack(bNodeStack *to, bNodeStack *from) copy_v4_v4(to->vec, from->vec); to->data = from->data; to->datatype = from->datatype; - + /* tag as copy to prevent freeing */ to->is_copy = 1; } @@ -63,7 +63,7 @@ static void move_stack(bNodeStack *to, bNodeStack *from) to->data = from->data; to->datatype = from->datatype; to->is_copy = from->is_copy; - + from->data = NULL; from->is_copy = 0; } @@ -75,20 +75,20 @@ static void *group_initexec(bNodeExecContext *context, bNode *node, bNodeInstanc { bNodeTree *ngroup = (bNodeTree *)node->id; bNodeTreeExec *exec; - + if (!ngroup) return NULL; - + /* initialize the internal node tree execution */ exec = ntreeShaderBeginExecTree_internal(context, ngroup, key); - + return exec; } static void group_freeexec(void *nodedata) { bNodeTreeExec *gexec = (bNodeTreeExec *)nodedata; - + if (gexec) ntreeShaderEndExecTree_internal(gexec); } @@ -102,7 +102,7 @@ static void group_copy_inputs(bNode *gnode, bNodeStack **in, bNodeStack *gstack) bNodeSocket *sock; bNodeStack *ns; int a; - + for (node = ngroup->nodes.first; node; node = node->next) { if (node->type == NODE_GROUP_INPUT) { for (sock = node->outputs.first, a = 0; sock; sock = sock->next, ++a) { @@ -123,7 +123,7 @@ static void group_move_outputs(bNode *gnode, bNodeStack **out, bNodeStack *gstac bNodeSocket *sock; bNodeStack *ns; int a; - + for (node = ngroup->nodes.first; node; node = node->next) { if (node->type == NODE_GROUP_OUTPUT && (node->flag & NODE_DO_OUTPUT)) { for (sock = node->inputs.first, a = 0; sock; sock = sock->next, ++a) { @@ -140,10 +140,10 @@ static void group_execute(void *data, int thread, struct bNode *node, bNodeExecD { bNodeTreeExec *exec = execdata->data; 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. */ @@ -152,13 +152,13 @@ static void group_execute(void *data, int thread, struct bNode *node, bNodeExecD for (inode = exec->nodetree->nodes.first; inode; inode = inode->next) inode->need_exec = 1; } - + nts = ntreeGetThreadStack(exec, thread); - + group_copy_inputs(node, in, nts->stack); ntreeExecThreadNodes(exec, nts, data, thread); group_move_outputs(node, out, nts->stack); - + ntreeReleaseThreadStack(nts); } @@ -169,7 +169,7 @@ static void group_gpu_copy_inputs(bNode *gnode, GPUNodeStack *in, bNodeStack *gs bNodeSocket *sock; bNodeStack *ns; int a; - + for (node = ngroup->nodes.first; node; node = node->next) { if (node->type == NODE_GROUP_INPUT) { for (sock = node->outputs.first, a = 0; sock; sock = sock->next, ++a) { @@ -192,7 +192,7 @@ static void group_gpu_move_outputs(bNode *gnode, GPUNodeStack *out, bNodeStack * bNodeSocket *sock; bNodeStack *ns; int a; - + for (node = ngroup->nodes.first; node; node = node->next) { if (node->type == NODE_GROUP_OUTPUT && (node->flag & NODE_DO_OUTPUT)) { for (sock = node->inputs.first, a = 0; sock; sock = sock->next, ++a) { @@ -210,10 +210,10 @@ static void group_gpu_move_outputs(bNode *gnode, GPUNodeStack *out, bNodeStack * static int gpu_group_execute(GPUMaterial *mat, bNode *node, bNodeExecData *execdata, GPUNodeStack *in, GPUNodeStack *out) { bNodeTreeExec *exec = execdata->data; - + if (!node->id) return 0; - + group_gpu_copy_inputs(node, in, exec->stack); #if 0 /* XXX NODE_GROUP_EDIT is deprecated, depends on node space */ ntreeExecGPUNodes(exec, mat, (node->flag & NODE_GROUP_EDIT)); @@ -221,14 +221,14 @@ static int gpu_group_execute(GPUMaterial *mat, bNode *node, bNodeExecData *execd ntreeExecGPUNodes(exec, mat, 0, NODE_NEW_SHADING | NODE_OLD_SHADING); #endif group_gpu_move_outputs(node, out, exec->stack); - + return 1; } void register_node_type_sh_group(void) { static bNodeType ntype; - + /* NB: cannot use sh_node_type_base for node group, because it would map the node type * to the shared NODE_GROUP integer type id. */ @@ -241,7 +241,7 @@ void register_node_type_sh_group(void) ntype.ext.srna = RNA_struct_find("ShaderNodeGroup"); BLI_assert(ntype.ext.srna != NULL); RNA_struct_blender_type_set(ntype.ext.srna, &ntype); - + node_type_compatibility(&ntype, NODE_OLD_SHADING | NODE_NEW_SHADING); node_type_socket_templates(&ntype, NULL, NULL); node_type_size(&ntype, 140, 60, 400); @@ -249,6 +249,6 @@ void register_node_type_sh_group(void) node_type_update(&ntype, NULL, node_group_verify); node_type_exec(&ntype, group_initexec, group_freeexec, group_execute); node_type_gpu(&ntype, gpu_group_execute); - + nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_curves.c b/source/blender/nodes/shader/nodes/node_shader_curves.c index ab0dc91a9b7..0c583ced75f 100644 --- a/source/blender/nodes/shader/nodes/node_shader_curves.c +++ b/source/blender/nodes/shader/nodes/node_shader_curves.c @@ -48,7 +48,7 @@ static bNodeSocketTemplate sh_node_curve_vec_out[] = { static void node_shader_exec_curve_vec(void *UNUSED(data), int UNUSED(thread), bNode *node, bNodeExecData *UNUSED(execdata), bNodeStack **in, bNodeStack **out) { float vec[3]; - + /* stack order input: vec */ /* stack order output: vec */ nodestack_get_vec(vec, SOCK_VECTOR, in[1]); @@ -102,7 +102,7 @@ static void node_shader_exec_curve_rgb(void *UNUSED(data), int UNUSED(thread), b { float vec[3]; float fac; - + /* stack order input: vec */ /* stack order output: vec */ nodestack_get_vec(&fac, SOCK_FLOAT, in[0]); diff --git a/source/blender/nodes/shader/nodes/node_shader_fresnel.c b/source/blender/nodes/shader/nodes/node_shader_fresnel.c index 010399aaedd..393d2c5fee0 100644 --- a/source/blender/nodes/shader/nodes/node_shader_fresnel.c +++ b/source/blender/nodes/shader/nodes/node_shader_fresnel.c @@ -47,7 +47,7 @@ static int node_shader_gpu_fresnel(GPUMaterial *mat, bNode *UNUSED(node), bNodeE else if (GPU_material_use_world_space_shading(mat)) { GPU_link(mat, "direction_transform_m4v3", in[1].link, GPU_builtin(GPU_VIEW_MATRIX), &in[1].link); } - + return GPU_stack_link(mat, "node_fresnel", in, out, GPU_builtin(GPU_VIEW_POSITION)); } diff --git a/source/blender/nodes/shader/nodes/node_shader_gamma.c b/source/blender/nodes/shader/nodes/node_shader_gamma.c index 216fec856b8..8bf58682ef3 100644 --- a/source/blender/nodes/shader/nodes/node_shader_gamma.c +++ b/source/blender/nodes/shader/nodes/node_shader_gamma.c @@ -60,7 +60,7 @@ static int node_shader_gpu_gamma(GPUMaterial *mat, bNode *UNUSED(node), bNodeExe void register_node_type_sh_gamma(void) { static bNodeType ntype; - + sh_node_type_base(&ntype, SH_NODE_GAMMA, "Gamma", NODE_CLASS_OP_COLOR, 0); node_type_compatibility(&ntype, NODE_OLD_SHADING | NODE_NEW_SHADING); node_type_socket_templates(&ntype, sh_node_gamma_in, sh_node_gamma_out); @@ -68,6 +68,6 @@ void register_node_type_sh_gamma(void) node_type_storage(&ntype, "", NULL, NULL); node_type_exec(&ntype, NULL, NULL, node_shader_exec_gamma); node_type_gpu(&ntype, node_shader_gpu_gamma); - + nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_geom.c b/source/blender/nodes/shader/nodes/node_shader_geom.c index 1d7ddc5f226..0a51ee8dc68 100644 --- a/source/blender/nodes/shader/nodes/node_shader_geom.c +++ b/source/blender/nodes/shader/nodes/node_shader_geom.c @@ -103,7 +103,7 @@ static void node_shader_exec_geom(void *data, int UNUSED(thread), bNode *node, b memcpy(out[GEOM_OUT_VCOL]->vec, defaultvcol, sizeof(defaultvcol)); out[GEOM_OUT_VCOL_ALPHA]->vec[0] = 1.0f; } - + if (shi->osatex) { out[GEOM_OUT_GLOB]->data = shi->dxgl; out[GEOM_OUT_GLOB]->datatype = NS_OSA_VECTORS; @@ -118,7 +118,7 @@ static void node_shader_exec_geom(void *data, int UNUSED(thread), bNode *node, b out[GEOM_OUT_NORMAL]->data = shi->dxno; out[GEOM_OUT_NORMAL]->datatype = NS_OSA_VECTORS; } - + /* front/back, normal flipping was stored */ out[GEOM_OUT_FRONTBACK]->vec[0] = (shi->flippednor) ? 0.0f : 1.0f; } diff --git a/source/blender/nodes/shader/nodes/node_shader_hueSatVal.c b/source/blender/nodes/shader/nodes/node_shader_hueSatVal.c index c4a91cb4a0c..548b3970a89 100644 --- a/source/blender/nodes/shader/nodes/node_shader_hueSatVal.c +++ b/source/blender/nodes/shader/nodes/node_shader_hueSatVal.c @@ -52,7 +52,7 @@ static void do_hue_sat_fac(bNode *UNUSED(node), float *out, float hue, float sat { if (fac != 0.0f && (hue != 0.5f || sat != 1.0f || val != 1.0f)) { float col[3], hsv[3], mfac = 1.0f - fac; - + rgb_to_hsv(in[0], in[1], in[2], hsv, hsv + 1, hsv + 2); hsv[0] += (hue - 0.5f); if (hsv[0] > 1.0f) hsv[0] -= 1.0f; else if (hsv[0] < 0.0f) hsv[0] += 1.0f; diff --git a/source/blender/nodes/shader/nodes/node_shader_invert.c b/source/blender/nodes/shader/nodes/node_shader_invert.c index b0336ffd646..dc0817782e5 100644 --- a/source/blender/nodes/shader/nodes/node_shader_invert.c +++ b/source/blender/nodes/shader/nodes/node_shader_invert.c @@ -34,7 +34,7 @@ -/* **************** INVERT ******************** */ +/* **************** INVERT ******************** */ static bNodeSocketTemplate sh_node_invert_in[] = { { SOCK_FLOAT, 1, N_("Fac"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, { SOCK_RGBA, 1, N_("Color"), 0.0f, 0.0f, 0.0f, 1.0f}, @@ -46,18 +46,18 @@ static bNodeSocketTemplate sh_node_invert_out[] = { { -1, 0, "" } }; -static void node_shader_exec_invert(void *UNUSED(data), int UNUSED(thread), bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), bNodeStack **in, +static void node_shader_exec_invert(void *UNUSED(data), int UNUSED(thread), bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), bNodeStack **in, bNodeStack **out) { float col[3], icol[3], fac; nodestack_get_vec(&fac, SOCK_FLOAT, in[0]); nodestack_get_vec(col, SOCK_VECTOR, in[1]); - + icol[0] = 1.0f - col[0]; icol[1] = 1.0f - col[1]; icol[2] = 1.0f - col[2]; - + /* if fac, blend result against original input */ if (fac < 1.0f) interp_v3_v3v3(out[0]->vec, col, icol, fac); diff --git a/source/blender/nodes/shader/nodes/node_shader_mapping.c b/source/blender/nodes/shader/nodes/node_shader_mapping.c index c07d2e99785..95d0fa5c951 100644 --- a/source/blender/nodes/shader/nodes/node_shader_mapping.c +++ b/source/blender/nodes/shader/nodes/node_shader_mapping.c @@ -56,7 +56,7 @@ static void node_shader_exec_mapping(void *UNUSED(data), int UNUSED(thread), bNo { TexMapping *texmap = node->storage; float *vec = out[0]->vec; - + /* stack order input: vector */ /* stack order output: vector */ nodestack_get_vec(vec, SOCK_VECTOR, in[0]); @@ -105,7 +105,7 @@ static int gpu_shader_mapping(GPUMaterial *mat, bNode *node, bNodeExecData *UNUS void register_node_type_sh_mapping(void) { static bNodeType ntype; - + sh_node_type_base(&ntype, SH_NODE_MAPPING, "Mapping", NODE_CLASS_OP_VECTOR, 0); node_type_compatibility(&ntype, NODE_OLD_SHADING | NODE_NEW_SHADING); node_type_socket_templates(&ntype, sh_node_mapping_in, sh_node_mapping_out); @@ -114,6 +114,6 @@ void register_node_type_sh_mapping(void) node_type_storage(&ntype, "TexMapping", node_free_standard_storage, node_copy_standard_storage); node_type_exec(&ntype, node_shader_initexec_mapping, NULL, node_shader_exec_mapping); node_type_gpu(&ntype, gpu_shader_mapping); - + nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_material.c b/source/blender/nodes/shader/nodes/node_shader_material.c index 28380677ba5..8a73ddc1194 100644 --- a/source/blender/nodes/shader/nodes/node_shader_material.c +++ b/source/blender/nodes/shader/nodes/node_shader_material.c @@ -85,7 +85,7 @@ static void node_shader_exec_material(void *data, int UNUSED(thread), bNode *nod bNodeSocket *sock; char hasinput[NUM_MAT_IN] = {'\0'}; int i, mode; - + /* note: cannot use the in[]->hasinput flags directly, as these are not necessarily * the constant input stack values (e.g. in case material node is inside a group). * we just want to know if a node input uses external data or the material setting. @@ -93,24 +93,24 @@ static void node_shader_exec_material(void *data, int UNUSED(thread), bNode *nod */ for (sock = node->inputs.first, i = 0; sock; sock = sock->next, ++i) hasinput[i] = (sock->link != NULL); - + shi = shcd->shi; shi->mat = (Material *)node->id; - + /* copy all relevant material vars, note, keep this synced with render_types.h */ memcpy(&shi->r, &shi->mat->r, 23 * sizeof(float)); shi->har = shi->mat->har; - + /* write values */ if (hasinput[MAT_IN_COLOR]) nodestack_get_vec(&shi->r, SOCK_VECTOR, in[MAT_IN_COLOR]); - + if (hasinput[MAT_IN_SPEC]) nodestack_get_vec(&shi->specr, SOCK_VECTOR, in[MAT_IN_SPEC]); - + if (hasinput[MAT_IN_REFL]) nodestack_get_vec(&shi->refl, SOCK_FLOAT, in[MAT_IN_REFL]); - + /* retrieve normal */ if (hasinput[MAT_IN_NORMAL]) { nodestack_get_vec(shi->vn, SOCK_VECTOR, in[MAT_IN_NORMAL]); @@ -122,12 +122,12 @@ static void node_shader_exec_material(void *data, int UNUSED(thread), bNode *nod } else copy_v3_v3(shi->vn, shi->vno); - + /* custom option to flip normal */ if (node->custom1 & SH_NODE_MAT_NEG) { negate_v3(shi->vn); } - + if (node->type == SH_NODE_MATERIAL_EXT) { if (hasinput[MAT_IN_MIR]) nodestack_get_vec(&shi->mirr, SOCK_VECTOR, in[MAT_IN_MIR]); @@ -144,7 +144,7 @@ static void node_shader_exec_material(void *data, int UNUSED(thread), bNode *nod if (hasinput[MAT_IN_TRANSLUCENCY]) nodestack_get_vec(&shi->translucency, SOCK_FLOAT, in[MAT_IN_TRANSLUCENCY]); } - + /* make alpha output give results even if transparency is only enabled on * the material linked in this not and not on the parent material */ mode = shi->mode; @@ -154,7 +154,7 @@ static void node_shader_exec_material(void *data, int UNUSED(thread), bNode *nod shi->nodes = 1; /* temp hack to prevent trashadow recursion */ node_shader_lamp_loop(shi, &shrnode); /* clears shrnode */ shi->nodes = 0; - + shi->mode = mode; /* write to outputs */ @@ -169,21 +169,21 @@ static void node_shader_exec_material(void *data, int UNUSED(thread), bNode *nod } else col[0] = col[1] = col[2] = 0.0f; - + col[3] = shrnode.alpha; - + if (shi->do_preview) BKE_node_preview_set_pixel(execdata->preview, col, shi->xs, shi->ys, shi->do_manage); - + copy_v3_v3(out[MAT_OUT_COLOR]->vec, col); out[MAT_OUT_ALPHA]->vec[0] = shrnode.alpha; - + if (node->custom1 & SH_NODE_MAT_NEG) { shi->vn[0] = -shi->vn[0]; shi->vn[1] = -shi->vn[1]; shi->vn[2] = -shi->vn[2]; } - + copy_v3_v3(out[MAT_OUT_NORMAL]->vec, shi->vn); if (shi->use_world_space_shading) { @@ -198,7 +198,7 @@ static void node_shader_exec_material(void *data, int UNUSED(thread), bNode *nod 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 */ if (node->flag & NODE_ACTIVE_ID) { float combined[4], alpha; @@ -254,7 +254,7 @@ static int gpu_shader_material(GPUMaterial *mat, bNode *node, bNodeExecData *UNU bNodeSocket *sock; char hasinput[NUM_MAT_IN] = {'\0'}; int i; - + /* note: cannot use the in[]->hasinput flags directly, as these are not necessarily * the constant input stack values (e.g. in case material node is inside a group). * we just want to know if a node input uses external data or the material setting. @@ -267,13 +267,13 @@ static int gpu_shader_material(GPUMaterial *mat, bNode *node, bNodeExecData *UNU /* write values */ if (hasinput[MAT_IN_COLOR]) shi.rgb = gpu_get_input_link(mat, &in[MAT_IN_COLOR]); - + if (hasinput[MAT_IN_SPEC]) shi.specrgb = gpu_get_input_link(mat, &in[MAT_IN_SPEC]); - + if (hasinput[MAT_IN_REFL]) shi.refl = gpu_get_input_link(mat, &in[MAT_IN_REFL]); - + /* retrieve normal */ if (hasinput[MAT_IN_NORMAL]) { GPUNodeLink *tmp; @@ -284,7 +284,7 @@ static int gpu_shader_material(GPUMaterial *mat, bNode *node, bNodeExecData *UNU } GPU_link(mat, "vec_math_normalize", shi.vn, &shi.vn, &tmp); } - + /* custom option to flip normal */ if (node->custom1 & SH_NODE_MAT_NEG) GPU_link(mat, "vec_math_negate", shi.vn, &shi.vn); @@ -303,7 +303,7 @@ static int gpu_shader_material(GPUMaterial *mat, bNode *node, bNodeExecData *UNU } GPU_shaderesult_set(&shi, &shr); /* clears shr */ - + /* write to outputs */ if (node->custom1 & SH_NODE_MAT_DIFF) { out[MAT_OUT_COLOR].link = shr.combined; @@ -322,7 +322,7 @@ static int gpu_shader_material(GPUMaterial *mat, bNode *node, bNodeExecData *UNU GPU_link(mat, "mtex_alpha_to_col", out[MAT_OUT_COLOR].link, shr.alpha, &out[MAT_OUT_COLOR].link); out[MAT_OUT_ALPHA].link = shr.alpha; // - + if (node->custom1 & SH_NODE_MAT_NEG) GPU_link(mat, "vec_math_negate", shi.vn, &shi.vn); out[MAT_OUT_NORMAL].link = shi.vn; diff --git a/source/blender/nodes/shader/nodes/node_shader_math.c b/source/blender/nodes/shader/nodes/node_shader_math.c index f74547ffe70..0a75a0f8bf0 100644 --- a/source/blender/nodes/shader/nodes/node_shader_math.c +++ b/source/blender/nodes/shader/nodes/node_shader_math.c @@ -33,7 +33,7 @@ #include "node_shader_util.h" -/* **************** SCALAR MATH ******************** */ +/* **************** SCALAR MATH ******************** */ static bNodeSocketTemplate sh_node_math_in[] = { { SOCK_FLOAT, 1, N_("Value"), 0.5f, 0.5f, 0.5f, 1.0f, -10000.0f, 10000.0f, PROP_NONE}, { SOCK_FLOAT, 1, N_("Value"), 0.5f, 0.5f, 0.5f, 1.0f, -10000.0f, 10000.0f, PROP_NONE}, @@ -45,15 +45,15 @@ static bNodeSocketTemplate sh_node_math_out[] = { { -1, 0, "" } }; -static void node_shader_exec_math(void *UNUSED(data), int UNUSED(thread), bNode *node, bNodeExecData *UNUSED(execdata), bNodeStack **in, bNodeStack **out) +static void node_shader_exec_math(void *UNUSED(data), int UNUSED(thread), bNode *node, bNodeExecData *UNUSED(execdata), bNodeStack **in, bNodeStack **out) { float a, b, r = 0.0f; - + nodestack_get_vec(&a, SOCK_FLOAT, in[0]); nodestack_get_vec(&b, SOCK_FLOAT, in[1]); - + switch (node->custom1) { - + case NODE_MATH_ADD: r = a + b; break; @@ -147,7 +147,7 @@ static void node_shader_exec_math(void *UNUSED(data), int UNUSED(thread), bNode } else { float y_mod_1 = fabsf(fmodf(b, 1.0f)); - + /* if input value is not nearly an integer, fall back to zero, nicer than straight rounding */ if (y_mod_1 > 0.999f || y_mod_1 < 0.001f) { r = powf(a, floorf(b + 0.5f)); diff --git a/source/blender/nodes/shader/nodes/node_shader_mixRgb.c b/source/blender/nodes/shader/nodes/node_shader_mixRgb.c index a0290697bcd..14a9f2c5ea5 100644 --- a/source/blender/nodes/shader/nodes/node_shader_mixRgb.c +++ b/source/blender/nodes/shader/nodes/node_shader_mixRgb.c @@ -54,7 +54,7 @@ static void node_shader_exec_mix_rgb(void *UNUSED(data), int UNUSED(thread), bNo nodestack_get_vec(&fac, SOCK_FLOAT, in[0]); CLAMP(fac, 0.0f, 1.0f); - + nodestack_get_vec(col, SOCK_VECTOR, in[1]); nodestack_get_vec(vec, SOCK_VECTOR, in[2]); diff --git a/source/blender/nodes/shader/nodes/node_shader_normal.c b/source/blender/nodes/shader/nodes/node_shader_normal.c index 25549fe0013..84d250eed7b 100644 --- a/source/blender/nodes/shader/nodes/node_shader_normal.c +++ b/source/blender/nodes/shader/nodes/node_shader_normal.c @@ -48,12 +48,12 @@ static bNodeSocketTemplate sh_node_normal_out[] = { static void node_shader_exec_normal(void *UNUSED(data), int UNUSED(thread), bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), bNodeStack **in, bNodeStack **out) { float vec[3]; - + /* stack order input: normal */ /* stack order output: normal, value */ - + nodestack_get_vec(vec, SOCK_VECTOR, in[0]); - + /* render normals point inside... the widget points outside */ out[1]->vec[0] = -dot_v3v3(vec, out[0]->vec); } @@ -72,12 +72,12 @@ static int gpu_shader_normal(GPUMaterial *mat, bNode *UNUSED(node), bNodeExecDat void register_node_type_sh_normal(void) { static bNodeType ntype; - + sh_node_type_base(&ntype, SH_NODE_NORMAL, "Normal", NODE_CLASS_OP_VECTOR, 0); node_type_compatibility(&ntype, NODE_OLD_SHADING | NODE_NEW_SHADING); node_type_socket_templates(&ntype, sh_node_normal_in, sh_node_normal_out); node_type_exec(&ntype, NULL, NULL, node_shader_exec_normal); node_type_gpu(&ntype, gpu_shader_normal); - + nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_output.c b/source/blender/nodes/shader/nodes/node_shader_output.c index 21844e51486..5b1a68b4bf9 100644 --- a/source/blender/nodes/shader/nodes/node_shader_output.c +++ b/source/blender/nodes/shader/nodes/node_shader_output.c @@ -44,22 +44,22 @@ static void node_shader_exec_output(void *data, int UNUSED(thread), bNode *node, if (data) { ShadeInput *shi = ((ShaderCallData *)data)->shi; float col[4]; - + /* stack order input sockets: col, alpha, normal */ nodestack_get_vec(col, SOCK_VECTOR, in[0]); nodestack_get_vec(col + 3, SOCK_FLOAT, in[1]); - + if (shi->do_preview) { BKE_node_preview_set_pixel(execdata->preview, col, shi->xs, shi->ys, shi->do_manage); node->lasty = shi->ys; } - + if (node->flag & NODE_DO_OUTPUT) { ShadeResult *shr = ((ShaderCallData *)data)->shr; - + copy_v4_v4(shr->combined, col); shr->alpha = col[3]; - + // copy_v3_v3(shr->nor, in[3]->vec); } } diff --git a/source/blender/nodes/shader/nodes/node_shader_output_world.c b/source/blender/nodes/shader/nodes/node_shader_output_world.c index d8182ee3f77..9581153538b 100644 --- a/source/blender/nodes/shader/nodes/node_shader_output_world.c +++ b/source/blender/nodes/shader/nodes/node_shader_output_world.c @@ -56,7 +56,7 @@ void register_node_type_sh_output_world(void) node_type_init(&ntype, NULL); node_type_storage(&ntype, "", NULL, NULL); node_type_gpu(&ntype, node_shader_gpu_output_world); - + /* Do not allow muting output node. */ node_type_internal_links(&ntype, NULL); diff --git a/source/blender/nodes/shader/nodes/node_shader_sepcombHSV.c b/source/blender/nodes/shader/nodes/node_shader_sepcombHSV.c index d6636956873..0a47978431f 100644 --- a/source/blender/nodes/shader/nodes/node_shader_sepcombHSV.c +++ b/source/blender/nodes/shader/nodes/node_shader_sepcombHSV.c @@ -48,7 +48,7 @@ static void node_shader_exec_sephsv(void *UNUSED(data), int UNUSED(thread), bNod { float col[3]; nodestack_get_vec(col, SOCK_VECTOR, in[0]); - + rgb_to_hsv(col[0], col[1], col[2], &out[0]->vec[0], &out[1]->vec[0], &out[2]->vec[0]); } @@ -90,7 +90,7 @@ static void node_shader_exec_combhsv(void *UNUSED(data), int UNUSED(thread), bNo nodestack_get_vec(&h, SOCK_FLOAT, in[0]); nodestack_get_vec(&s, SOCK_FLOAT, in[1]); nodestack_get_vec(&v, SOCK_FLOAT, in[2]); - + hsv_to_rgb(h, s, v, &out[0]->vec[0], &out[0]->vec[1], &out[0]->vec[2]); } diff --git a/source/blender/nodes/shader/nodes/node_shader_sepcombRGB.c b/source/blender/nodes/shader/nodes/node_shader_sepcombRGB.c index 87a987a6053..8748abd5eb6 100644 --- a/source/blender/nodes/shader/nodes/node_shader_sepcombRGB.c +++ b/source/blender/nodes/shader/nodes/node_shader_sepcombRGB.c @@ -48,7 +48,7 @@ static void node_shader_exec_seprgb(void *UNUSED(data), int UNUSED(thread), bNod { float col[3]; nodestack_get_vec(col, SOCK_VECTOR, in[0]); - + out[0]->vec[0] = col[0]; out[1]->vec[0] = col[1]; out[2]->vec[0] = col[2]; @@ -92,7 +92,7 @@ static void node_shader_exec_combrgb(void *UNUSED(data), int UNUSED(thread), bNo nodestack_get_vec(&r, SOCK_FLOAT, in[0]); nodestack_get_vec(&g, SOCK_FLOAT, in[1]); nodestack_get_vec(&b, SOCK_FLOAT, in[2]); - + out[0]->vec[0] = r; out[0]->vec[1] = g; out[0]->vec[2] = b; diff --git a/source/blender/nodes/shader/nodes/node_shader_squeeze.c b/source/blender/nodes/shader/nodes/node_shader_squeeze.c index f9240b2d4b6..bba6a56d9e5 100644 --- a/source/blender/nodes/shader/nodes/node_shader_squeeze.c +++ b/source/blender/nodes/shader/nodes/node_shader_squeeze.c @@ -32,7 +32,7 @@ #include "node_shader_util.h" -/* **************** VALUE SQUEEZE ******************** */ +/* **************** VALUE SQUEEZE ******************** */ static bNodeSocketTemplate sh_node_squeeze_in[] = { { SOCK_FLOAT, 1, N_("Value"), 0.0f, 0.0f, 0.0f, 0.0f, -100.0f, 100.0f, PROP_NONE}, { SOCK_FLOAT, 1, N_("Width"), 1.0f, 0.0f, 0.0f, 0.0f, -100.0f, 100.0f, PROP_NONE}, @@ -48,7 +48,7 @@ static bNodeSocketTemplate sh_node_squeeze_out[] = { static void node_shader_exec_squeeze(void *UNUSED(data), int UNUSED(thread), bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), bNodeStack **in, bNodeStack **out) { float vec[3]; - + nodestack_get_vec(vec, SOCK_FLOAT, in[0]); nodestack_get_vec(vec + 1, SOCK_FLOAT, in[1]); nodestack_get_vec(vec + 2, SOCK_FLOAT, in[2]); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_brick.c b/source/blender/nodes/shader/nodes/node_shader_tex_brick.c index b032ad74e84..ebfb3fc29a1 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_brick.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_brick.c @@ -54,7 +54,7 @@ static void node_shader_init_tex_brick(bNodeTree *UNUSED(ntree), bNode *node) NodeTexBrick *tex = MEM_callocN(sizeof(NodeTexBrick), "NodeTexBrick"); BKE_texture_mapping_default(&tex->base.tex_mapping, TEXMAP_TYPE_POINT); BKE_texture_colormapping_default(&tex->base.color_mapping); - + tex->offset = 0.5f; tex->squash = 1.0f; tex->offset_freq = 2; diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_coord.c b/source/blender/nodes/shader/nodes/node_shader_tex_coord.c index 38e6fec36a1..f1721fe5567 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_coord.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_coord.c @@ -47,7 +47,7 @@ static int node_shader_gpu_tex_coord(GPUMaterial *mat, bNode *UNUSED(node), bNod GPUNodeLink *orco = GPU_attribute(CD_ORCO, ""); GPUNodeLink *mtface = GPU_attribute(CD_MTFACE, ""); GPUMatType type = GPU_Material_get_type(mat); - + if (type == GPU_MATERIAL_TYPE_MESH) { return GPU_stack_link(mat, "node_tex_coord", in, out, GPU_builtin(GPU_VIEW_POSITION), GPU_builtin(GPU_VIEW_NORMAL), @@ -57,7 +57,7 @@ static int node_shader_gpu_tex_coord(GPUMaterial *mat, bNode *UNUSED(node), bNod else { return GPU_stack_link(mat, "node_tex_coord_background", in, out, GPU_builtin(GPU_VIEW_POSITION), GPU_builtin(GPU_VIEW_NORMAL), - GPU_builtin(GPU_INVERSE_VIEW_MATRIX), GPU_builtin(GPU_INVERSE_OBJECT_MATRIX), + GPU_builtin(GPU_INVERSE_VIEW_MATRIX), GPU_builtin(GPU_INVERSE_OBJECT_MATRIX), GPU_builtin(GPU_CAMERA_TEXCO_FACTORS), orco, mtface); } } diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_environment.c b/source/blender/nodes/shader/nodes/node_shader_tex_environment.c index 81ca08bd356..9b485a30083 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_environment.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_environment.c @@ -66,20 +66,20 @@ static int node_shader_gpu_tex_environment(GPUMaterial *mat, bNode *node, bNodeE if (!in[0].link) { GPUMatType type = GPU_Material_get_type(mat); - + if (type == GPU_MATERIAL_TYPE_MESH) in[0].link = GPU_builtin(GPU_VIEW_POSITION); else GPU_link(mat, "background_transform_to_world", GPU_builtin(GPU_VIEW_POSITION), &in[0].link); } - + node_shader_gpu_tex_mapping(mat, node, in, out); if (tex->projection == SHD_PROJ_EQUIRECTANGULAR) GPU_stack_link(mat, "node_tex_environment_equirectangular", in, out, GPU_image(ima, iuser, isdata)); else GPU_stack_link(mat, "node_tex_environment_mirror_ball", in, out, GPU_image(ima, iuser, isdata)); - + ImBuf *ibuf = BKE_image_acquire_ibuf(ima, iuser, NULL); if (ibuf && (ibuf->colormanage_flag & IMB_COLORMANAGE_IS_DATA) == 0 && GPU_material_do_color_management(mat)) diff --git a/source/blender/nodes/shader/nodes/node_shader_texture.c b/source/blender/nodes/shader/nodes/node_shader_texture.c index 365319844a8..737ec7d1c4b 100644 --- a/source/blender/nodes/shader/nodes/node_shader_texture.c +++ b/source/blender/nodes/shader/nodes/node_shader_texture.c @@ -56,19 +56,19 @@ static void node_shader_exec_texture(void *data, int UNUSED(thread), bNode *node float vec[3], nor[3] = {0.0f, 0.0f, 0.0f}; int retval; short which_output = node->custom1; - + short thread = shi->thread; - + /* out: value, color, normal */ - + /* we should find out if a normal as output is needed, for now we do all */ texres.nor = nor; texres.tr = texres.tg = texres.tb = 0.0f; - + /* don't use in[0]->hasinput, see material node for explanation */ if (sock_vector->link) { nodestack_get_vec(vec, SOCK_VECTOR, in[0]); - + if (in[0]->datatype == NS_OSA_VECTORS) { float *fp = in[0]->data; retval = multitex_nodes((Tex *)node->id, vec, fp, fp + 3, shi->osatex, &texres, thread, which_output, NULL, NULL, NULL); @@ -76,7 +76,7 @@ static void node_shader_exec_texture(void *data, int UNUSED(thread), bNode *node else if (in[0]->datatype == NS_OSA_VALUES) { const float *fp = in[0]->data; float dxt[3], dyt[3]; - + dxt[0] = fp[0]; dxt[1] = dxt[2] = 0.0f; dyt[0] = fp[1]; dyt[1] = dyt[2] = 0.0f; retval = multitex_nodes((Tex *)node->id, vec, dxt, dyt, shi->osatex, &texres, thread, which_output, NULL, NULL, NULL); @@ -88,19 +88,19 @@ static void node_shader_exec_texture(void *data, int UNUSED(thread), bNode *node copy_v3_v3(vec, shi->lo); retval = multitex_nodes((Tex *)node->id, vec, NULL, NULL, 0, &texres, thread, which_output, NULL, NULL, NULL); } - + /* stupid exception */ if ( ((Tex *)node->id)->type == TEX_STUCCI) { texres.tin = 0.5f + 0.7f * texres.nor[0]; CLAMP(texres.tin, 0.0f, 1.0f); } - + /* intensity and color need some handling */ if (texres.talpha) out[0]->vec[0] = texres.ta; else out[0]->vec[0] = texres.tin; - + if ((retval & TEX_RGB) == 0) { copy_v3_fl(out[1]->vec, out[0]->vec[0]); out[1]->vec[3] = 1.0f; @@ -109,13 +109,13 @@ static void node_shader_exec_texture(void *data, int UNUSED(thread), bNode *node copy_v3_v3(out[1]->vec, &texres.tr); out[1]->vec[3] = 1.0f; } - + copy_v3_v3(out[2]->vec, nor); - + if (shi->do_preview) { BKE_node_preview_set_pixel(execdata->preview, out[1]->vec, shi->xs, shi->ys, shi->do_manage); } - + } } diff --git a/source/blender/nodes/shader/nodes/node_shader_valToRgb.c b/source/blender/nodes/shader/nodes/node_shader_valToRgb.c index 6a6c3b43ed9..5a1f0bd472d 100644 --- a/source/blender/nodes/shader/nodes/node_shader_valToRgb.c +++ b/source/blender/nodes/shader/nodes/node_shader_valToRgb.c @@ -48,7 +48,7 @@ static void node_shader_exec_valtorgb(void *UNUSED(data), int UNUSED(thread), bN { /* stack order in: fac */ /* stack order out: col, alpha */ - + if (node->storage) { float fac; nodestack_get_vec(&fac, SOCK_FLOAT, in[0]); diff --git a/source/blender/nodes/shader/nodes/node_shader_vectMath.c b/source/blender/nodes/shader/nodes/node_shader_vectMath.c index 3114d7f3235..02cff52e1a0 100644 --- a/source/blender/nodes/shader/nodes/node_shader_vectMath.c +++ b/source/blender/nodes/shader/nodes/node_shader_vectMath.c @@ -31,7 +31,7 @@ #include "node_shader_util.h" -/* **************** VECTOR MATH ******************** */ +/* **************** VECTOR MATH ******************** */ static bNodeSocketTemplate sh_node_vect_math_in[] = { { SOCK_VECTOR, 1, N_("Vector"), 0.5f, 0.5f, 0.5f, 1.0f, -10000.0f, 10000.0f, PROP_NONE}, { SOCK_VECTOR, 1, N_("Vector"), 0.5f, 0.5f, 0.5f, 1.0f, -10000.0f, 10000.0f, PROP_NONE}, @@ -44,32 +44,32 @@ static bNodeSocketTemplate sh_node_vect_math_out[] = { { -1, 0, "" } }; -static void node_shader_exec_vect_math(void *UNUSED(data), int UNUSED(thread), bNode *node, bNodeExecData *UNUSED(execdata), bNodeStack **in, bNodeStack **out) -{ +static void node_shader_exec_vect_math(void *UNUSED(data), int UNUSED(thread), bNode *node, bNodeExecData *UNUSED(execdata), bNodeStack **in, bNodeStack **out) +{ float vec1[3], vec2[3]; - + nodestack_get_vec(vec1, SOCK_VECTOR, in[0]); nodestack_get_vec(vec2, SOCK_VECTOR, in[1]); - + if (node->custom1 == 0) { /* Add */ out[0]->vec[0] = vec1[0] + vec2[0]; out[0]->vec[1] = vec1[1] + vec2[1]; out[0]->vec[2] = vec1[2] + vec2[2]; - + out[1]->vec[0] = (fabsf(out[0]->vec[0]) + fabsf(out[0]->vec[1]) + fabsf(out[0]->vec[2])) / 3.0f; } else if (node->custom1 == 1) { /* Subtract */ out[0]->vec[0] = vec1[0] - vec2[0]; out[0]->vec[1] = vec1[1] - vec2[1]; out[0]->vec[2] = vec1[2] - vec2[2]; - + out[1]->vec[0] = (fabsf(out[0]->vec[0]) + fabsf(out[0]->vec[1]) + fabsf(out[0]->vec[2])) / 3.0f; } else if (node->custom1 == 2) { /* Average */ out[0]->vec[0] = vec1[0] + vec2[0]; out[0]->vec[1] = vec1[1] + vec2[1]; out[0]->vec[2] = vec1[2] + vec2[2]; - + out[1]->vec[0] = normalize_v3(out[0]->vec); } else if (node->custom1 == 3) { /* Dot product */ @@ -79,7 +79,7 @@ static void node_shader_exec_vect_math(void *UNUSED(data), int UNUSED(thread), b out[0]->vec[0] = (vec1[1] * vec2[2]) - (vec1[2] * vec2[1]); out[0]->vec[1] = (vec1[2] * vec2[0]) - (vec1[0] * vec2[2]); out[0]->vec[2] = (vec1[0] * vec2[1]) - (vec1[1] * vec2[0]); - + out[1]->vec[0] = normalize_v3(out[0]->vec); } else if (node->custom1 == 5) { /* Normalize */ @@ -93,10 +93,10 @@ static void node_shader_exec_vect_math(void *UNUSED(data), int UNUSED(thread), b out[0]->vec[1] = vec2[1]; out[0]->vec[2] = vec2[2]; } - + out[1]->vec[0] = normalize_v3(out[0]->vec); } - + } static int gpu_shader_vect_math(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out) @@ -132,7 +132,7 @@ static int gpu_shader_vect_math(GPUMaterial *mat, bNode *node, bNodeExecData *UN default: return false; } - + return true; } diff --git a/source/blender/nodes/shader/nodes/node_shader_vectTransform.c b/source/blender/nodes/shader/nodes/node_shader_vectTransform.c index ef78f1ecab0..af36e7cea22 100644 --- a/source/blender/nodes/shader/nodes/node_shader_vectTransform.c +++ b/source/blender/nodes/shader/nodes/node_shader_vectTransform.c @@ -28,10 +28,10 @@ /** \file blender/nodes/shader/nodes/node_shader_vectTransform.c * \ingroup shdnodes */ - + #include "../node_shader_util.h" -/* **************** Vector Transform ******************** */ +/* **************** Vector Transform ******************** */ static bNodeSocketTemplate sh_node_vect_transform_in[] = { { SOCK_VECTOR, 1, N_("Vector"), 0.5f, 0.5f, 0.5f, 1.0f, -10000.0f, 10000.0f, PROP_NONE}, { -1, 0, "" } @@ -45,10 +45,10 @@ static bNodeSocketTemplate sh_node_vect_transform_out[] = { static void node_shader_init_vect_transform(bNodeTree *UNUSED(ntree), bNode *node) { NodeShaderVectTransform *vect = MEM_callocN(sizeof(NodeShaderVectTransform), "NodeShaderVectTransform"); - + /* Convert World into Object Space per default */ vect->convert_to = 1; - + node->storage = vect; } diff --git a/source/blender/nodes/texture/node_texture_tree.c b/source/blender/nodes/texture/node_texture_tree.c index bc48802a7ca..b77e0a32fbc 100644 --- a/source/blender/nodes/texture/node_texture_tree.c +++ b/source/blender/nodes/texture/node_texture_tree.c @@ -73,7 +73,7 @@ static void texture_get_from_context(const bContext *C, bNodeTreeType *UNUSED(tr *r_from = (ID *)ob->data; else *r_from = (ID *)give_current_material(ob, ob->actcol); - + /* from is not set fully for material nodes, should be ID + Node then */ *r_id = &tx->id; *r_ntree = tx->nodetree; @@ -92,7 +92,7 @@ static void texture_get_from_context(const bContext *C, bNodeTreeType *UNUSED(tr } else if (snode->texfrom == SNODE_TEX_BRUSH) { struct Brush *brush = NULL; - + if (ob && (ob->mode & OB_MODE_SCULPT)) brush = BKE_paint_brush(&scene->toolsettings->sculpt->paint); else @@ -141,11 +141,11 @@ static void foreach_nodeclass(Scene *UNUSED(scene), void *calldata, bNodeClassCa static void localize(bNodeTree *localtree, bNodeTree *UNUSED(ntree)) { bNode *node, *node_next; - + /* replace muted nodes and reroute nodes by internal links */ for (node = localtree->nodes.first; node; node = node_next) { node_next = node->next; - + if (node->flag & NODE_MUTED || node->type == NODE_REROUTE) { nodeInternalRelink(localtree, node); nodeFreeNode(localtree, node); @@ -171,7 +171,7 @@ static void local_merge(bNodeTree *localtree, bNodeTree *ntree) static void update(bNodeTree *ntree) { ntree_update_reroute_nodes(ntree); - + if (ntree->update & NTREE_UPDATE_NODES) { /* clean up preview cache, in case nodes have been removed */ BKE_node_preview_remove_unused(ntree); @@ -183,31 +183,31 @@ bNodeTreeType *ntreeType_Texture; void register_node_tree_type_tex(void) { bNodeTreeType *tt = ntreeType_Texture = MEM_callocN(sizeof(bNodeTreeType), "texture node tree type"); - + tt->type = NTREE_TEXTURE; strcpy(tt->idname, "TextureNodeTree"); strcpy(tt->ui_name, "Texture"); tt->ui_icon = 0; /* defined in drawnode.c */ strcpy(tt->ui_description, "Texture nodes"); - + tt->foreach_nodeclass = foreach_nodeclass; tt->update = update; tt->localize = localize; tt->local_sync = local_sync; tt->local_merge = local_merge; tt->get_from_context = texture_get_from_context; - + tt->ext.srna = &RNA_TextureNodeTree; - + ntreeTypeAdd(tt); } int ntreeTexTagAnimated(bNodeTree *ntree) { bNode *node; - + if (ntree == NULL) return 0; - + for (node = ntree->nodes.first; node; node = node->next) { if (node->type == TEX_NODE_CURVE_TIME) { nodeUpdate(ntree, node); @@ -219,7 +219,7 @@ int ntreeTexTagAnimated(bNodeTree *ntree) } } } - + return 0; } @@ -227,16 +227,16 @@ bNodeTreeExec *ntreeTexBeginExecTree_internal(bNodeExecContext *context, bNodeTr { bNodeTreeExec *exec; bNode *node; - + /* common base initialization */ exec = ntree_exec_begin(context, ntree, parent_key); - + /* allocate the thread stack listbase array */ exec->threadstack = MEM_callocN(BLENDER_MAX_THREADS * sizeof(ListBase), "thread stack array"); - + for (node = exec->nodetree->nodes.first; node; node = node->next) node->need_exec = 1; - + return exec; } @@ -244,22 +244,22 @@ bNodeTreeExec *ntreeTexBeginExecTree(bNodeTree *ntree) { bNodeExecContext context; bNodeTreeExec *exec; - + /* XXX hack: prevent exec data from being generated twice. * this should be handled by the renderer! */ if (ntree->execdata) return ntree->execdata; - + context.previews = ntree->previews; - + exec = ntreeTexBeginExecTree_internal(&context, ntree, NODE_INSTANCE_KEY_BASE); - + /* XXX this should not be necessary, but is still used for cmp/sha/tex nodes, * which only store the ntree pointer. Should be fixed at some point! */ ntree->execdata = exec; - + return exec; } @@ -269,7 +269,7 @@ static void tex_free_delegates(bNodeTreeExec *exec) bNodeThreadStack *nts; bNodeStack *ns; int th, a; - + for (th = 0; th < BLENDER_MAX_THREADS; th++) for (nts = exec->threadstack[th].first; nts; nts = nts->next) for (ns = nts->stack, a = 0; a < exec->stacksize; a++, ns++) @@ -281,20 +281,20 @@ void ntreeTexEndExecTree_internal(bNodeTreeExec *exec) { bNodeThreadStack *nts; int a; - + if (exec->threadstack) { tex_free_delegates(exec); - + for (a = 0; a < BLENDER_MAX_THREADS; a++) { for (nts = exec->threadstack[a].first; nts; nts = nts->next) if (nts->stack) MEM_freeN(nts->stack); BLI_freelistN(&exec->threadstack[a]); } - + MEM_freeN(exec->threadstack); exec->threadstack = NULL; } - + ntree_exec_end(exec); } @@ -304,7 +304,7 @@ void ntreeTexEndExecTree(bNodeTreeExec *exec) /* exec may get freed, so assign ntree */ bNodeTree *ntree = exec->nodetree; ntreeTexEndExecTree_internal(exec); - + /* XXX clear nodetree backpointer to exec data, same problem as noted in ntreeBeginExecTree */ ntree->execdata = NULL; } @@ -342,7 +342,7 @@ int ntreeTexExecTree( data.cfra = cfra; data.mtex = mtex; data.shi = shi; - + /* ensure execdata is only initialized once */ if (!exec) { BLI_thread_lock(LOCK_NODES); @@ -352,7 +352,7 @@ int ntreeTexExecTree( exec = nodes->execdata; } - + nts = ntreeGetThreadStack(exec, thread); ntreeExecThreadNodes(exec, nts, &data, thread); ntreeReleaseThreadStack(nts); diff --git a/source/blender/nodes/texture/node_texture_util.c b/source/blender/nodes/texture/node_texture_util.c index 32720364f73..0682fa9f414 100644 --- a/source/blender/nodes/texture/node_texture_util.c +++ b/source/blender/nodes/texture/node_texture_util.c @@ -58,7 +58,7 @@ int tex_node_poll_default(bNodeType *UNUSED(ntype), bNodeTree *ntree) void tex_node_type_base(struct bNodeType *ntype, int type, const char *name, short nclass, short flag) { node_type_base(ntype, type, name, nclass, flag); - + ntype->poll = tex_node_poll_default; ntype->insert_link = node_insert_link_default; ntype->update_internal_links = node_update_internal_links_default; @@ -80,7 +80,7 @@ static void tex_input(float *out, int sz, bNodeStack *in, TexParams *params, sho TexDelegate *dg = in->data; if (dg) { tex_call_delegate(dg, in->vec, params, thread); - + if (in->hasoutput && in->sockettype == SOCK_FLOAT) in->vec[1] = in->vec[2] = in->vec[0]; } @@ -95,12 +95,12 @@ void tex_input_vec(float *out, bNodeStack *in, TexParams *params, short thread) void tex_input_rgba(float *out, bNodeStack *in, TexParams *params, short thread) { tex_input(out, 4, in, params, thread); - + if (in->hasoutput && in->sockettype == SOCK_FLOAT) { out[1] = out[2] = out[0]; out[3] = 1; } - + if (in->hasoutput && in->sockettype == SOCK_VECTOR) { out[0] = out[0] * 0.5f + 0.5f; out[1] = out[1] * 0.5f + 0.5f; @@ -133,7 +133,7 @@ void tex_do_preview(bNodePreview *preview, const float coord[2], const float col if (preview) { int xs = ((coord[0] + 1.0f) * 0.5f) * preview->xsize; int ys = ((coord[1] + 1.0f) * 0.5f) * preview->ysize; - + BKE_node_preview_set_pixel(preview, col, xs, ys, do_manage); } } @@ -141,7 +141,7 @@ void tex_do_preview(bNodePreview *preview, const float coord[2], const float col void tex_output(bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack *out, TexFn texfn, TexCallData *cdata) { TexDelegate *dg; - + if (node->flag & NODE_MUTED) { /* do not add a delegate if the node is muted */ return; @@ -176,9 +176,9 @@ void ntreeTexCheckCyclics(struct bNodeTree *ntree) } else { Tex *tex = (Tex *)node->id; - + node->custom2 = 0; - + node->custom1 = 1; if (tex->use_nodes && tex->nodetree) { ntreeTexCheckCyclics(tex->nodetree); diff --git a/source/blender/nodes/texture/nodes/node_texture_at.c b/source/blender/nodes/texture/nodes/node_texture_at.c index bd37a73c776..690d87b42a9 100644 --- a/source/blender/nodes/texture/nodes/node_texture_at.c +++ b/source/blender/nodes/texture/nodes/node_texture_at.c @@ -48,7 +48,7 @@ static void colorfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack ** TexParams np = *p; float new_co[3]; np.co = new_co; - + tex_input_vec(new_co, in[1], p, thread); tex_input_rgba(out, in[0], &np, thread); } @@ -61,11 +61,11 @@ static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *exe void register_node_type_tex_at(void) { static bNodeType ntype; - + tex_node_type_base(&ntype, TEX_NODE_AT, "At", NODE_CLASS_DISTORT, 0); node_type_socket_templates(&ntype, inputs, outputs); node_type_size(&ntype, 140, 100, 320); node_type_exec(&ntype, NULL, NULL, exec); - + nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/texture/nodes/node_texture_bricks.c b/source/blender/nodes/texture/nodes/node_texture_bricks.c index 802cfb97533..43af02acdf2 100644 --- a/source/blender/nodes/texture/nodes/node_texture_bricks.c +++ b/source/blender/nodes/texture/nodes/node_texture_bricks.c @@ -67,43 +67,43 @@ static float noise(int n) /* fast integer noise */ static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread) { const float *co = p->co; - + float x = co[0]; float y = co[1]; - + int bricknum, rownum; float offset = 0; float ins_x, ins_y; float tint; - + float bricks1[4]; float bricks2[4]; float mortar[4]; - + float mortar_thickness = tex_input_value(in[3], p, thread); float bias = tex_input_value(in[4], p, thread); float brick_width = tex_input_value(in[5], p, thread); float row_height = tex_input_value(in[6], p, thread); - + tex_input_rgba(bricks1, in[0], p, thread); tex_input_rgba(bricks2, in[1], p, thread); tex_input_rgba(mortar, in[2], p, thread); - + rownum = (int)floor(y / row_height); - + if (node->custom1 && node->custom2) { brick_width *= ((int)(rownum) % node->custom2) ? 1.0f : node->custom4; /* squash */ offset = ((int)(rownum) % node->custom1) ? 0 : (brick_width * node->custom3); /* offset */ } - + bricknum = (int)floor((x + offset) / brick_width); - + ins_x = (x + offset) - brick_width * bricknum; ins_y = y - row_height * rownum; - + tint = noise((rownum << 16) + (bricknum & 0xFFFF)) + bias; CLAMP(tint, 0.0f, 1.0f); - + if (ins_x < mortar_thickness || ins_y < mortar_thickness || ins_x > (brick_width - mortar_thickness) || ins_y > (row_height - mortar_thickness)) @@ -124,12 +124,12 @@ static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *exe void register_node_type_tex_bricks(void) { static bNodeType ntype; - + tex_node_type_base(&ntype, TEX_NODE_BRICKS, "Bricks", NODE_CLASS_PATTERN, NODE_PREVIEW); node_type_socket_templates(&ntype, inputs, outputs); node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); node_type_init(&ntype, init); node_type_exec(&ntype, NULL, NULL, exec); - + nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/texture/nodes/node_texture_checker.c b/source/blender/nodes/texture/nodes/node_texture_checker.c index b38c883e3b8..d7ad642d474 100644 --- a/source/blender/nodes/texture/nodes/node_texture_checker.c +++ b/source/blender/nodes/texture/nodes/node_texture_checker.c @@ -51,12 +51,12 @@ static void colorfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack ** float y = p->co[1]; float z = p->co[2]; float sz = tex_input_value(in[2], p, thread); - + /* 0.00001 because of unit sized stuff */ int xi = (int)fabs(floor(0.00001f + x / sz)); int yi = (int)fabs(floor(0.00001f + y / sz)); int zi = (int)fabs(floor(0.00001f + z / sz)); - + if ( (xi % 2 == yi % 2) == (zi % 2) ) { tex_input_rgba(out, in[0], p, thread); } @@ -73,10 +73,10 @@ static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *exe void register_node_type_tex_checker(void) { static bNodeType ntype; - + tex_node_type_base(&ntype, TEX_NODE_CHECKER, "Checker", NODE_CLASS_PATTERN, NODE_PREVIEW); node_type_socket_templates(&ntype, inputs, outputs); node_type_exec(&ntype, NULL, NULL, exec); - + nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/texture/nodes/node_texture_common.c b/source/blender/nodes/texture/nodes/node_texture_common.c index 6f9a39d7524..20b1815e436 100644 --- a/source/blender/nodes/texture/nodes/node_texture_common.c +++ b/source/blender/nodes/texture/nodes/node_texture_common.c @@ -50,7 +50,7 @@ static void copy_stack(bNodeStack *to, bNodeStack *from) copy_v4_v4(to->vec, from->vec); to->data = from->data; to->datatype = from->datatype; - + /* tag as copy to prevent freeing */ to->is_copy = 1; } @@ -62,20 +62,20 @@ static void *group_initexec(bNodeExecContext *context, bNode *node, bNodeInstanc { bNodeTree *ngroup = (bNodeTree *)node->id; void *exec; - + if (!ngroup) return NULL; - + /* initialize the internal node tree execution */ exec = ntreeTexBeginExecTree_internal(context, ngroup, key); - + return exec; } static void group_freeexec(void *nodedata) { bNodeTreeExec *gexec = (bNodeTreeExec *)nodedata; - + ntreeTexEndExecTree_internal(gexec); } @@ -89,7 +89,7 @@ static void group_copy_inputs(bNode *gnode, bNodeStack **in, bNodeStack *gstack) bNodeSocket *sock; bNodeStack *ns; int a; - + for (node = ngroup->nodes.first; node; node = node->next) { if (node->type == NODE_GROUP_INPUT) { for (sock = node->outputs.first, a = 0; sock; sock = sock->next, ++a) { @@ -113,7 +113,7 @@ static void group_copy_outputs(bNode *gnode, bNodeStack **out, bNodeStack *gstac bNodeSocket *sock; bNodeStack *ns; int a; - + for (node = ngroup->nodes.first; node; node = node->next) { if (node->type == NODE_GROUP_OUTPUT && (node->flag & NODE_DO_OUTPUT)) { for (sock = node->inputs.first, a = 0; sock; sock = sock->next, ++a) { @@ -133,10 +133,10 @@ static void group_execute(void *data, int thread, struct bNode *node, bNodeExecD { bNodeTreeExec *exec = execdata->data; 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. */ @@ -145,13 +145,13 @@ static void group_execute(void *data, int thread, struct bNode *node, bNodeExecD for (inode = exec->nodetree->nodes.first; inode; inode = inode->next) inode->need_exec = 1; } - + nts = ntreeGetThreadStack(exec, thread); - + group_copy_inputs(node, in, nts->stack); ntreeExecThreadNodes(exec, nts, data, thread); group_copy_outputs(node, out, nts->stack); - + ntreeReleaseThreadStack(nts); } @@ -171,12 +171,12 @@ void register_node_type_tex_group(void) ntype.ext.srna = RNA_struct_find("TextureNodeGroup"); BLI_assert(ntype.ext.srna != NULL); RNA_struct_blender_type_set(ntype.ext.srna, &ntype); - + node_type_socket_templates(&ntype, NULL, NULL); node_type_size(&ntype, 140, 60, 400); node_type_label(&ntype, node_group_label); node_type_update(&ntype, NULL, node_group_verify); node_type_exec(&ntype, group_initexec, group_freeexec, group_execute); - + nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/texture/nodes/node_texture_compose.c b/source/blender/nodes/texture/nodes/node_texture_compose.c index 092bf919a67..002da4428cc 100644 --- a/source/blender/nodes/texture/nodes/node_texture_compose.c +++ b/source/blender/nodes/texture/nodes/node_texture_compose.c @@ -30,7 +30,7 @@ */ -#include "node_texture_util.h" +#include "node_texture_util.h" #include "NOD_texture.h" static bNodeSocketTemplate inputs[] = { @@ -60,10 +60,10 @@ static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *exe void register_node_type_tex_compose(void) { static bNodeType ntype; - + tex_node_type_base(&ntype, TEX_NODE_COMPOSE, "Combine RGBA", NODE_CLASS_OP_COLOR, 0); node_type_socket_templates(&ntype, inputs, outputs); node_type_exec(&ntype, NULL, NULL, exec); - + nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/texture/nodes/node_texture_coord.c b/source/blender/nodes/texture/nodes/node_texture_coord.c index e76987da61b..e698ffd0a54 100644 --- a/source/blender/nodes/texture/nodes/node_texture_coord.c +++ b/source/blender/nodes/texture/nodes/node_texture_coord.c @@ -51,11 +51,11 @@ static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *exe void register_node_type_tex_coord(void) { static bNodeType ntype; - + tex_node_type_base(&ntype, TEX_NODE_COORD, "Coordinates", NODE_CLASS_INPUT, 0); node_type_socket_templates(&ntype, NULL, outputs); node_type_storage(&ntype, "", NULL, NULL); node_type_exec(&ntype, NULL, NULL, exec); - + nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/texture/nodes/node_texture_curves.c b/source/blender/nodes/texture/nodes/node_texture_curves.c index c25c312626e..cc734df9586 100644 --- a/source/blender/nodes/texture/nodes/node_texture_curves.c +++ b/source/blender/nodes/texture/nodes/node_texture_curves.c @@ -45,10 +45,10 @@ static void time_colorfn(float *out, TexParams *p, bNode *node, bNodeStack **UNU { /* stack order output: fac */ float fac = 0.0f; - + if (node->custom1 < node->custom2) fac = (p->cfra - node->custom1) / (float)(node->custom2 - node->custom1); - + curvemapping_initialize(node->storage); fac = curvemapping_evaluateF(node->storage, 0, fac); out[0] = CLAMPIS(fac, 0.0f, 1.0f); @@ -70,14 +70,14 @@ static void time_init(bNodeTree *UNUSED(ntree), bNode *node) void register_node_type_tex_curve_time(void) { static bNodeType ntype; - + tex_node_type_base(&ntype, TEX_NODE_CURVE_TIME, "Time", NODE_CLASS_INPUT, 0); node_type_socket_templates(&ntype, NULL, time_outputs); node_type_size_preset(&ntype, NODE_SIZE_LARGE); node_type_init(&ntype, time_init); node_type_storage(&ntype, "CurveMapping", node_free_curves, node_copy_curves); node_type_exec(&ntype, node_initexec_curves, NULL, time_exec); - + nodeRegisterType(&ntype); } @@ -96,7 +96,7 @@ static void rgb_colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, { float cin[4]; tex_input_rgba(cin, in[0], p, thread); - + curvemapping_evaluateRGBF(node->storage, out, cin); out[3] = cin[3]; } @@ -114,13 +114,13 @@ static void rgb_init(bNodeTree *UNUSED(ntree), bNode *node) void register_node_type_tex_curve_rgb(void) { static bNodeType ntype; - + tex_node_type_base(&ntype, TEX_NODE_CURVE_RGB, "RGB Curves", NODE_CLASS_OP_COLOR, 0); node_type_socket_templates(&ntype, rgb_inputs, rgb_outputs); node_type_size_preset(&ntype, NODE_SIZE_LARGE); node_type_init(&ntype, rgb_init); node_type_storage(&ntype, "CurveMapping", node_free_curves, node_copy_curves); node_type_exec(&ntype, node_initexec_curves, NULL, rgb_exec); - + nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/texture/nodes/node_texture_decompose.c b/source/blender/nodes/texture/nodes/node_texture_decompose.c index 16938bee8e4..392cff970e7 100644 --- a/source/blender/nodes/texture/nodes/node_texture_decompose.c +++ b/source/blender/nodes/texture/nodes/node_texture_decompose.c @@ -30,7 +30,7 @@ */ -#include "node_texture_util.h" +#include "node_texture_util.h" #include "NOD_texture.h" #include <math.h> @@ -81,10 +81,10 @@ static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *exe void register_node_type_tex_decompose(void) { static bNodeType ntype; - + tex_node_type_base(&ntype, TEX_NODE_DECOMPOSE, "Separate RGBA", NODE_CLASS_OP_COLOR, 0); node_type_socket_templates(&ntype, inputs, outputs); node_type_exec(&ntype, NULL, NULL, exec); - + nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/texture/nodes/node_texture_distance.c b/source/blender/nodes/texture/nodes/node_texture_distance.c index 3fdcbe870a9..7cd032f7d59 100644 --- a/source/blender/nodes/texture/nodes/node_texture_distance.c +++ b/source/blender/nodes/texture/nodes/node_texture_distance.c @@ -64,11 +64,11 @@ static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *exe void register_node_type_tex_distance(void) { static bNodeType ntype; - + tex_node_type_base(&ntype, TEX_NODE_DISTANCE, "Distance", NODE_CLASS_CONVERTOR, 0); node_type_socket_templates(&ntype, inputs, outputs); node_type_storage(&ntype, "", NULL, NULL); node_type_exec(&ntype, NULL, NULL, exec); - + nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/texture/nodes/node_texture_hueSatVal.c b/source/blender/nodes/texture/nodes/node_texture_hueSatVal.c index 9c86f2d0a4c..8316579af93 100644 --- a/source/blender/nodes/texture/nodes/node_texture_hueSatVal.c +++ b/source/blender/nodes/texture/nodes/node_texture_hueSatVal.c @@ -51,7 +51,7 @@ static void do_hue_sat_fac(bNode *UNUSED(node), float *out, float hue, float sat { if (fac != 0 && (hue != 0.5f || sat != 1 || val != 1)) { float col[3], hsv[3], mfac = 1.0f - fac; - + rgb_to_hsv(in[0], in[1], in[2], hsv, hsv + 1, hsv + 2); hsv[0] += (hue - 0.5f); if (hsv[0] > 1.0f) hsv[0] -= 1.0f; else if (hsv[0] < 0.0f) hsv[0] += 1.0f; @@ -71,19 +71,19 @@ static void do_hue_sat_fac(bNode *UNUSED(node), float *out, float hue, float sat } static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread) -{ +{ float hue = tex_input_value(in[0], p, thread); float sat = tex_input_value(in[1], p, thread); float val = tex_input_value(in[2], p, thread); float fac = tex_input_value(in[3], p, thread); - + float col[4]; tex_input_rgba(col, in[4], p, thread); - + hue += 0.5f; /* [-0.5, 0.5] -> [0, 1] */ - + do_hue_sat_fac(node, out, hue, sat, val, col, fac); - + out[3] = col[3]; } @@ -95,11 +95,11 @@ static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *exe void register_node_type_tex_hue_sat(void) { static bNodeType ntype; - + tex_node_type_base(&ntype, TEX_NODE_HUE_SAT, "Hue Saturation Value", NODE_CLASS_OP_COLOR, 0); node_type_socket_templates(&ntype, inputs, outputs); node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); node_type_exec(&ntype, NULL, NULL, exec); - + nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/texture/nodes/node_texture_image.c b/source/blender/nodes/texture/nodes/node_texture_image.c index 057c4f24256..d6881ca41f0 100644 --- a/source/blender/nodes/texture/nodes/node_texture_image.c +++ b/source/blender/nodes/texture/nodes/node_texture_image.c @@ -44,37 +44,37 @@ static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **UNUSED(i float y = p->co[1]; Image *ima = (Image *)node->id; ImageUser *iuser = (ImageUser *)node->storage; - + if (ima) { ImBuf *ibuf = BKE_image_acquire_ibuf(ima, iuser, NULL); if (ibuf) { float xsize, ysize; float xoff, yoff; int px, py; - + const float *result; xsize = ibuf->x / 2; ysize = ibuf->y / 2; xoff = yoff = -1; - + px = (int)( (x - xoff) * xsize); py = (int)( (y - yoff) * ysize); - + if ( (!xsize) || (!ysize) ) return; - + if (!ibuf->rect_float) { BLI_thread_lock(LOCK_IMAGE); if (!ibuf->rect_float) IMB_float_from_rect(ibuf); BLI_thread_unlock(LOCK_IMAGE); } - + while (px < 0) px += ibuf->x; while (py < 0) py += ibuf->y; while (px >= ibuf->x) px -= ibuf->x; while (py >= ibuf->y) py -= ibuf->y; - + result = ibuf->rect_float + py * ibuf->x * 4 + px * 4; copy_v4_v4(out, result); @@ -100,7 +100,7 @@ static void init(bNodeTree *UNUSED(ntree), bNode *node) void register_node_type_tex_image(void) { static bNodeType ntype; - + tex_node_type_base(&ntype, TEX_NODE_IMAGE, "Image", NODE_CLASS_INPUT, NODE_PREVIEW); node_type_socket_templates(&ntype, NULL, outputs); node_type_init(&ntype, init); diff --git a/source/blender/nodes/texture/nodes/node_texture_invert.c b/source/blender/nodes/texture/nodes/node_texture_invert.c index 35f5072d8a2..8ef7a7a6ad2 100644 --- a/source/blender/nodes/texture/nodes/node_texture_invert.c +++ b/source/blender/nodes/texture/nodes/node_texture_invert.c @@ -33,7 +33,7 @@ #include "node_texture_util.h" #include "NOD_texture.h" -/* **************** INVERT ******************** */ +/* **************** INVERT ******************** */ static bNodeSocketTemplate inputs[] = { { SOCK_RGBA, 1, N_("Color"), 0.0f, 0.0f, 0.0f, 1.0f}, { -1, 0, "" } @@ -47,13 +47,13 @@ static bNodeSocketTemplate outputs[] = { static void colorfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread) { float col[4]; - + tex_input_rgba(col, in[0], p, thread); col[0] = 1.0f - col[0]; col[1] = 1.0f - col[1]; col[2] = 1.0f - col[2]; - + copy_v3_v3(out, col); out[3] = col[3]; } @@ -66,10 +66,10 @@ static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *exe void register_node_type_tex_invert(void) { static bNodeType ntype; - + tex_node_type_base(&ntype, TEX_NODE_INVERT, "Invert", NODE_CLASS_OP_COLOR, 0); node_type_socket_templates(&ntype, inputs, outputs); node_type_exec(&ntype, NULL, NULL, exec); - + nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/texture/nodes/node_texture_mixRgb.c b/source/blender/nodes/texture/nodes/node_texture_mixRgb.c index 835a49c24d4..9fb8332c61a 100644 --- a/source/blender/nodes/texture/nodes/node_texture_mixRgb.c +++ b/source/blender/nodes/texture/nodes/node_texture_mixRgb.c @@ -49,16 +49,16 @@ static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor { float fac = tex_input_value(in[0], p, thread); float col1[4], col2[4]; - + tex_input_rgba(col1, in[1], p, thread); tex_input_rgba(col2, in[2], p, thread); /* use alpha */ if (node->custom2 & 1) fac *= col2[3]; - + CLAMP(fac, 0.0f, 1.0f); - + copy_v4_v4(out, col1); ramp_blend(node->custom1, out, fac, col2); } @@ -71,11 +71,11 @@ static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *exe void register_node_type_tex_mix_rgb(void) { static bNodeType ntype; - + tex_node_type_base(&ntype, TEX_NODE_MIX_RGB, "Mix", NODE_CLASS_OP_COLOR, 0); node_type_socket_templates(&ntype, inputs, outputs); node_type_label(&ntype, node_blend_label); node_type_exec(&ntype, NULL, NULL, exec); - + nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/texture/nodes/node_texture_output.c b/source/blender/nodes/texture/nodes/node_texture_output.c index 664b7e4f507..412e3ffb56c 100644 --- a/source/blender/nodes/texture/nodes/node_texture_output.c +++ b/source/blender/nodes/texture/nodes/node_texture_output.c @@ -45,7 +45,7 @@ static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *exe { TexCallData *cdata = (TexCallData *)data; TexResult *target = cdata->target; - + if (cdata->do_preview) { TexParams params; params_from_cdata(¶ms, cdata); @@ -61,12 +61,12 @@ static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *exe if (cdata->which_output == node->custom1 || (cdata->which_output == 0 && node->custom1 == 1)) { TexParams params; params_from_cdata(¶ms, cdata); - + tex_input_rgba(&target->tr, in[0], ¶ms, cdata->thread); - + target->tin = (target->tr + target->tg + target->tb) / 3.0f; target->talpha = true; - + if (target->nor) { if (in[1] && in[1]->hasinput) tex_input_vec(target->nor, in[1], ¶ms, cdata->thread); @@ -85,7 +85,7 @@ static void unique_name(bNode *node) int suffix; bNode *i; const char *name = tno->name; - + new_name[0] = '\0'; i = node; while (i->prev) i = i->prev; @@ -114,7 +114,7 @@ static void unique_name(bNode *node) } sprintf(new_name + new_len - 4, ".%03d", ++suffix); } - + if (new_name[0] != '\0') { BLI_strncpy(tno->name, new_name, sizeof(tno->name)); } @@ -124,11 +124,11 @@ static void assign_index(struct bNode *node) { bNode *tnode; int index = 1; - + tnode = node; while (tnode->prev) tnode = tnode->prev; - + check_index: for (; tnode; tnode = tnode->next) if (tnode->type == TEX_NODE_OUTPUT && tnode != node) @@ -136,7 +136,7 @@ check_index: index++; goto check_index; } - + node->custom1 = index; } @@ -144,7 +144,7 @@ static void init(bNodeTree *UNUSED(ntree), bNode *node) { TexNodeOutput *tno = MEM_callocN(sizeof(TexNodeOutput), "TEX_output"); node->storage = tno; - + strcpy(tno->name, "Default"); unique_name(node); assign_index(node); @@ -160,16 +160,16 @@ static void copy(bNodeTree *dest_ntree, bNode *dest_node, bNode *src_node) void register_node_type_tex_output(void) { static bNodeType ntype; - + tex_node_type_base(&ntype, TEX_NODE_OUTPUT, "Output", NODE_CLASS_OUTPUT, NODE_PREVIEW); node_type_socket_templates(&ntype, inputs, NULL); node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); node_type_init(&ntype, init); node_type_storage(&ntype, "TexNodeOutput", node_free_standard_storage, copy); node_type_exec(&ntype, NULL, NULL, exec); - + /* Do not allow muting output. */ node_type_internal_links(&ntype, NULL); - + nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/texture/nodes/node_texture_proc.c b/source/blender/nodes/texture/nodes/node_texture_proc.c index ee270179e72..76f5e7d5c5b 100644 --- a/source/blender/nodes/texture/nodes/node_texture_proc.c +++ b/source/blender/nodes/texture/nodes/node_texture_proc.c @@ -35,7 +35,7 @@ #include "RE_shader_ext.h" -/* +/* * In this file: wrappers to use procedural textures as nodes */ @@ -61,19 +61,19 @@ static void do_proc(float *result, TexParams *p, const float col1[4], const floa { TexResult texres; int textype; - + if (is_normal) { texres.nor = result; } else texres.nor = NULL; - + textype = multitex_nodes(tex, p->co, p->dxt, p->dyt, p->osatex, &texres, thread, 0, p->shi, p->mtex, NULL); - + if (is_normal) return; - + if (textype & TEX_RGB) { copy_v4_v4(result, &texres.tr); } @@ -86,11 +86,11 @@ static void do_proc(float *result, TexParams *p, const float col1[4], const floa typedef void (*MapFn) (Tex *tex, bNodeStack **in, TexParams *p, const short thread); static void texfn( - float *result, + float *result, TexParams *p, - bNode *node, + bNode *node, bNodeStack **in, - char is_normal, + char is_normal, MapFn map_inputs, short thread) { @@ -98,9 +98,9 @@ static void texfn( float col1[4], col2[4]; tex_input_rgba(col1, in[0], p, thread); tex_input_rgba(col2, in[1], p, thread); - + map_inputs(&tex, in, p, thread); - + do_proc(result, p, col1, col2, is_normal, &tex, thread); } @@ -144,10 +144,10 @@ static bNodeSocketTemplate voronoi_inputs[] = { { SOCK_FLOAT, 1, N_("W2"), 0.0f, 0.0f, 0.0f, 0.0f, -2.0f, 2.0f, PROP_NONE }, { SOCK_FLOAT, 1, N_("W3"), 0.0f, 0.0f, 0.0f, 0.0f, -2.0f, 2.0f, PROP_NONE }, { SOCK_FLOAT, 1, N_("W4"), 0.0f, 0.0f, 0.0f, 0.0f, -2.0f, 2.0f, PROP_NONE }, - + { SOCK_FLOAT, 1, N_("iScale"), 1.0f, 0.0f, 0.0f, 0.0f, 0.01f, 10.0f, PROP_UNSIGNED }, { SOCK_FLOAT, 1, N_("Size"), 0.25f, 0.0f, 0.0f, 0.0f, 0.0001f, 4.0f, PROP_UNSIGNED }, - + { -1, 0, "" } }; static void voronoi_map_inputs(Tex *tex, bNodeStack **in, TexParams *p, short thread) @@ -156,7 +156,7 @@ static void voronoi_map_inputs(Tex *tex, bNodeStack **in, TexParams *p, short th tex->vn_w2 = tex_input_value(in[I + 1], p, thread); tex->vn_w3 = tex_input_value(in[I + 2], p, thread); tex->vn_w4 = tex_input_value(in[I + 3], p, thread); - + tex->ns_outscale = tex_input_value(in[I + 4], p, thread); tex->noisesize = tex_input_value(in[I + 5], p, thread); } @@ -242,7 +242,7 @@ static bNodeSocketTemplate musgrave_inputs[] = { { SOCK_FLOAT, 1, N_("H"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0001f, 2.0f, PROP_UNSIGNED }, { SOCK_FLOAT, 1, N_("Lacunarity"), 2.0f, 0.0f, 0.0f, 0.0f, 0.0f, 6.0f, PROP_UNSIGNED }, { SOCK_FLOAT, 1, N_("Octaves"), 2.0f, 0.0f, 0.0f, 0.0f, 0.0f, 8.0f, PROP_UNSIGNED }, - + { SOCK_FLOAT, 1, N_("iScale"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 10.0f, PROP_UNSIGNED }, { SOCK_FLOAT, 1, N_("Size"), 0.25f, 0.0f, 0.0f, 0.0f, 0.0001f, 2.0f, PROP_UNSIGNED }, { -1, 0, "" } @@ -285,13 +285,13 @@ static void init(bNodeTree *UNUSED(ntree), bNode *node) { Tex *tex = MEM_callocN(sizeof(Tex), "Tex"); node->storage = tex; - + BKE_texture_default(tex); tex->type = node->type - TEX_NODE_PROC; - + if (tex->type == TEX_WOOD) tex->stype = TEX_BANDNOISE; - + } /* Node type definitions */ @@ -309,10 +309,10 @@ void register_node_type_tex_proc_##name(void) \ \ nodeRegisterType(&ntype); \ } - + #define C outputs_color_only #define CV outputs_both - + TexDef(TEX_VORONOI, CV, voronoi, "Voronoi" ) TexDef(TEX_BLEND, C, blend, "Blend" ) TexDef(TEX_MAGIC, C, magic, "Magic" ) diff --git a/source/blender/nodes/texture/nodes/node_texture_rotate.c b/source/blender/nodes/texture/nodes/node_texture_rotate.c index 99648ec323f..bc4e56ea81d 100644 --- a/source/blender/nodes/texture/nodes/node_texture_rotate.c +++ b/source/blender/nodes/texture/nodes/node_texture_rotate.c @@ -52,18 +52,18 @@ static void rotate(float new_co[3], float a, float ax[3], const float co[3]) float para[3]; float perp[3]; float cp[3]; - + float cos_a = cosf(a * (float)(2 * M_PI)); float sin_a = sinf(a * (float)(2 * M_PI)); - + // x' = xcosa + n(n.x)(1-cosa) + (x*n)sina - + mul_v3_v3fl(perp, co, cos_a); mul_v3_v3fl(para, ax, dot_v3v3(co, ax) * (1 - cos_a)); - + cross_v3_v3v3(cp, ax, co); mul_v3_fl(cp, sin_a); - + new_co[0] = para[0] + perp[0] + cp[0]; new_co[1] = para[1] + perp[1] + cp[1]; new_co[2] = para[2] + perp[2] + cp[2]; @@ -72,7 +72,7 @@ static void rotate(float new_co[3], float a, float ax[3], const float co[3]) static void colorfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread) { float new_co[3], new_dxt[3], new_dyt[3], a, ax[3]; - + a = tex_input_value(in[1], p, thread); tex_input_vec(ax, in[2], p, thread); @@ -81,7 +81,7 @@ static void colorfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack ** rotate(new_dxt, a, ax, p->dxt); rotate(new_dyt, a, ax, p->dyt); } - + { TexParams np = *p; np.co = new_co; @@ -90,7 +90,7 @@ static void colorfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack ** tex_input_rgba(out, in[0], &np, thread); } } -static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out) +static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out) { tex_output(node, execdata, in, out[0], &colorfn, data); } @@ -98,10 +98,10 @@ static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *exe void register_node_type_tex_rotate(void) { static bNodeType ntype; - + tex_node_type_base(&ntype, TEX_NODE_ROTATE, "Rotate", NODE_CLASS_DISTORT, 0); node_type_socket_templates(&ntype, inputs, outputs); node_type_exec(&ntype, NULL, NULL, exec); - + nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/texture/nodes/node_texture_scale.c b/source/blender/nodes/texture/nodes/node_texture_scale.c index d623e8e159a..94ccfd01357 100644 --- a/source/blender/nodes/texture/nodes/node_texture_scale.c +++ b/source/blender/nodes/texture/nodes/node_texture_scale.c @@ -52,7 +52,7 @@ static void colorfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack ** np.co = new_co; np.dxt = new_dxt; np.dyt = new_dyt; - + tex_input_vec(scale, in[1], p, thread); mul_v3_v3v3(new_co, p->co, scale); @@ -60,10 +60,10 @@ static void colorfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack ** mul_v3_v3v3(new_dxt, p->dxt, scale); mul_v3_v3v3(new_dyt, p->dyt, scale); } - + tex_input_rgba(out, in[0], &np, thread); } -static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out) +static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out) { tex_output(node, execdata, in, out[0], &colorfn, data); } @@ -71,10 +71,10 @@ static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *exe void register_node_type_tex_scale(void) { static bNodeType ntype; - + tex_node_type_base(&ntype, TEX_NODE_SCALE, "Scale", NODE_CLASS_DISTORT, 0); node_type_socket_templates(&ntype, inputs, outputs); node_type_exec(&ntype, NULL, NULL, exec); - + nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/texture/nodes/node_texture_texture.c b/source/blender/nodes/texture/nodes/node_texture_texture.c index 04d007bbb2b..57703e3a044 100644 --- a/source/blender/nodes/texture/nodes/node_texture_texture.c +++ b/source/blender/nodes/texture/nodes/node_texture_texture.c @@ -52,7 +52,7 @@ static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor static float red[] = {1, 0, 0, 1}; static float white[] = {1, 1, 1, 1}; float co[3], dxt[3], dyt[3]; - + copy_v3_v3(co, p->co); if (p->osatex) { copy_v3_v3(dxt, p->dxt); @@ -62,7 +62,7 @@ static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor zero_v3(dxt); zero_v3(dyt); } - + if (node->custom2 || node->need_exec == 0) { /* this node refers to its own texture tree! */ copy_v4_v4(out, (fabsf(co[0] - co[1]) < 0.01f) ? white : red); @@ -72,14 +72,14 @@ static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor int textype; float nor[] = {0, 0, 0}; float col1[4], col2[4]; - + tex_input_rgba(col1, in[0], p, thread); tex_input_rgba(col2, in[1], p, thread); - + texres.nor = nor; textype = multitex_nodes(nodetex, co, dxt, dyt, p->osatex, &texres, thread, 0, p->shi, p->mtex, NULL); - + if (textype & TEX_RGB) { copy_v4_v4(out, &texres.tr); } @@ -98,10 +98,10 @@ static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *exe void register_node_type_tex_texture(void) { static bNodeType ntype; - + tex_node_type_base(&ntype, TEX_NODE_TEXTURE, "Texture", NODE_CLASS_INPUT, NODE_PREVIEW); node_type_socket_templates(&ntype, inputs, outputs); node_type_exec(&ntype, NULL, NULL, exec); - + nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/texture/nodes/node_texture_translate.c b/source/blender/nodes/texture/nodes/node_texture_translate.c index ec90029c0bf..fa8319d077b 100644 --- a/source/blender/nodes/texture/nodes/node_texture_translate.c +++ b/source/blender/nodes/texture/nodes/node_texture_translate.c @@ -50,16 +50,16 @@ static void colorfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack ** float offset[3], new_co[3]; TexParams np = *p; np.co = new_co; - + tex_input_vec(offset, in[1], p, thread); - + new_co[0] = p->co[0] + offset[0]; new_co[1] = p->co[1] + offset[1]; new_co[2] = p->co[2] + offset[2]; - + tex_input_rgba(out, in[0], &np, thread); } -static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out) +static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out) { tex_output(node, execdata, in, out[0], &colorfn, data); } @@ -67,10 +67,10 @@ static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *exe void register_node_type_tex_translate(void) { static bNodeType ntype; - + tex_node_type_base(&ntype, TEX_NODE_TRANSLATE, "Translate", NODE_CLASS_DISTORT, 0); node_type_socket_templates(&ntype, inputs, outputs); node_type_exec(&ntype, NULL, NULL, exec); - + nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/texture/nodes/node_texture_valToNor.c b/source/blender/nodes/texture/nodes/node_texture_valToNor.c index 995fb6c1782..b7d57b4d4cf 100644 --- a/source/blender/nodes/texture/nodes/node_texture_valToNor.c +++ b/source/blender/nodes/texture/nodes/node_texture_valToNor.c @@ -52,7 +52,7 @@ static void normalfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack * float nabla = tex_input_value(in[1], p, thread); float val; float nor[3]; - + TexParams np = *p; np.co = new_co; @@ -66,7 +66,7 @@ static void normalfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack * new_co[0] = co[0]; new_co[1] = co[1] + nabla; nor[1] = tex_input_value(in[0], &np, thread); - + new_co[1] = co[1]; new_co[2] = co[2] + nabla; nor[2] = tex_input_value(in[0], &np, thread); @@ -75,7 +75,7 @@ static void normalfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack * out[1] = val - nor[1]; out[2] = val - nor[2]; } -static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out) +static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out) { tex_output(node, execdata, in, out[0], &normalfn, data); } @@ -83,10 +83,10 @@ static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *exe void register_node_type_tex_valtonor(void) { static bNodeType ntype; - + tex_node_type_base(&ntype, TEX_NODE_VALTONOR, "Value to Normal", NODE_CLASS_CONVERTOR, 0); node_type_socket_templates(&ntype, inputs, outputs); node_type_exec(&ntype, NULL, NULL, exec); - + nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/texture/nodes/node_texture_valToRgb.c b/source/blender/nodes/texture/nodes/node_texture_valToRgb.c index 4041d666811..ad3c4344f34 100644 --- a/source/blender/nodes/texture/nodes/node_texture_valToRgb.c +++ b/source/blender/nodes/texture/nodes/node_texture_valToRgb.c @@ -53,7 +53,7 @@ static void valtorgb_colorfn(float *out, TexParams *p, bNode *node, bNodeStack * } } -static void valtorgb_exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out) +static void valtorgb_exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out) { tex_output(node, execdata, in, out[0], &valtorgb_colorfn, data); } @@ -66,14 +66,14 @@ static void valtorgb_init(bNodeTree *UNUSED(ntree), bNode *node) void register_node_type_tex_valtorgb(void) { static bNodeType ntype; - + tex_node_type_base(&ntype, TEX_NODE_VALTORGB, "ColorRamp", NODE_CLASS_CONVERTOR, 0); node_type_socket_templates(&ntype, valtorgb_in, valtorgb_out); node_type_size_preset(&ntype, NODE_SIZE_LARGE); node_type_init(&ntype, valtorgb_init); node_type_storage(&ntype, "ColorBand", node_free_standard_storage, node_copy_standard_storage); node_type_exec(&ntype, NULL, NULL, valtorgb_exec); - + nodeRegisterType(&ntype); } @@ -103,10 +103,10 @@ static void rgbtobw_exec(void *data, int UNUSED(thread), bNode *node, bNodeExecD void register_node_type_tex_rgbtobw(void) { static bNodeType ntype; - + tex_node_type_base(&ntype, TEX_NODE_RGBTOBW, "RGB to BW", NODE_CLASS_CONVERTOR, 0); node_type_socket_templates(&ntype, rgbtobw_in, rgbtobw_out); node_type_exec(&ntype, NULL, NULL, rgbtobw_exec); - + nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/texture/nodes/node_texture_viewer.c b/source/blender/nodes/texture/nodes/node_texture_viewer.c index fefa06b0078..69f4d3ca086 100644 --- a/source/blender/nodes/texture/nodes/node_texture_viewer.c +++ b/source/blender/nodes/texture/nodes/node_texture_viewer.c @@ -59,13 +59,13 @@ static void exec(void *data, int UNUSED(thread), bNode *UNUSED(node), bNodeExecD void register_node_type_tex_viewer(void) { static bNodeType ntype; - + tex_node_type_base(&ntype, TEX_NODE_VIEWER, "Viewer", NODE_CLASS_OUTPUT, NODE_PREVIEW); node_type_socket_templates(&ntype, inputs, outputs); node_type_exec(&ntype, NULL, NULL, exec); - + /* Do not allow muting viewer node. */ node_type_internal_links(&ntype, NULL); - + nodeRegisterType(&ntype); } |