diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2013-10-04 16:11:10 +0400 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2013-10-04 16:11:10 +0400 |
commit | 1dc6d8ece112ba2d9e0de8594f08ba8f29f74740 (patch) | |
tree | 9d7a34d625a75e872734000fda5ce47e934ccb06 | |
parent | ec4a7fcad12ba8106531ab02c5bc1cce213cfb86 (diff) |
Fix related to [#36926] 'scale' Node doesn't work properly.
Scene/Render "spaces" are actually absolute values, they do not use the input X/Y scale factors, hide them in this case.
Thanks to Lukas for review and improvement!
-rw-r--r-- | source/blender/makesrna/intern/rna_nodetree.c | 11 | ||||
-rw-r--r-- | source/blender/nodes/composite/nodes/node_composite_scale.c | 19 |
2 files changed, 29 insertions, 1 deletions
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 287b672d270..d2f181d41b2 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -2847,6 +2847,15 @@ static void rna_ShaderNodeSubsurface_update(Main *bmain, Scene *scene, PointerRN rna_Node_update(bmain, scene, ptr); } +static void rna_CompositorNodeScale_update(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + bNodeTree *ntree = (bNodeTree *)ptr->id.data; + bNode *node = (bNode *)ptr->data; + + nodeUpdate(ntree, node); + rna_Node_update(bmain, scene, ptr); +} + #else static EnumPropertyItem prop_image_layer_items[] = { @@ -4360,7 +4369,7 @@ static void def_cmp_scale(StructRNA *srna) RNA_def_property_enum_sdna(prop, NULL, "custom1"); RNA_def_property_enum_items(prop, space_items); RNA_def_property_ui_text(prop, "Space", "Coordinate space to scale relative to"); - RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_CompositorNodeScale_update"); /* expose 2 flags as a enum of 3 items */ prop = RNA_def_property(srna, "frame_method", PROP_ENUM, PROP_NONE); diff --git a/source/blender/nodes/composite/nodes/node_composite_scale.c b/source/blender/nodes/composite/nodes/node_composite_scale.c index 134402c00e1..8041a2e56e9 100644 --- a/source/blender/nodes/composite/nodes/node_composite_scale.c +++ b/source/blender/nodes/composite/nodes/node_composite_scale.c @@ -45,12 +45,31 @@ static bNodeSocketTemplate cmp_node_scale_out[] = { { -1, 0, "" } }; +static void node_composite_update_scale(bNodeTree *UNUSED(ntree), bNode *node) +{ + bNodeSocket *sock; + bool use_xy_scale = ELEM(node->custom1, CMP_SCALE_RELATIVE, CMP_SCALE_ABSOLUTE); + + /* Only show X/Y scale factor inputs for modes using them! */ + for (sock = node->inputs.first; sock; sock = sock->next) { + if (STREQ(sock->name, "X") || STREQ(sock->name, "Y")) { + if (use_xy_scale) { + sock->flag &= ~SOCK_UNAVAIL; + } + else { + sock->flag |= SOCK_UNAVAIL; + } + } + } +} + void register_node_type_cmp_scale(void) { static bNodeType ntype; cmp_node_type_base(&ntype, CMP_NODE_SCALE, "Scale", NODE_CLASS_DISTORT, 0); node_type_socket_templates(&ntype, cmp_node_scale_in, cmp_node_scale_out); + node_type_update(&ntype, node_composite_update_scale, NULL); nodeRegisterType(&ntype); } |