diff options
author | Lukas Toenne <lukas.toenne@googlemail.com> | 2013-03-19 00:27:39 +0400 |
---|---|---|
committer | Lukas Toenne <lukas.toenne@googlemail.com> | 2013-03-19 00:27:39 +0400 |
commit | d5c1a802946786d928b4f32f2250af3d75cb8a37 (patch) | |
tree | bf2b3fb6ed770c4671de3931d74f0d6285626faa /source/blender/makesrna | |
parent | 3147d95bdfe0eddb5d1a6df281973e9c395c001e (diff) |
Added back the custom limits for value properties in standard node socket types, to override the standard range based purely on subtype.
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r-- | source/blender/makesrna/intern/rna_nodetree.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 6fd91e8a32b..b558e6d2eeb 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -2310,6 +2310,41 @@ static void rna_NodeSocketInterfaceStandard_draw_color(ID *id, bNodeSocket *sock sock->typeinfo->interface_draw_color(C, &ptr, r_color); } +static void rna_NodeSocketStandard_float_range(PointerRNA *ptr, float *min, float *max, float *softmin, float *softmax) +{ + bNodeSocket *sock = ptr->data; + bNodeSocketValueFloat *dval = sock->default_value; + int subtype = sock->typeinfo->subtype; + + *min = (subtype == PROP_UNSIGNED ? 0.0f : -FLT_MAX); + *max = FLT_MAX; + *softmin = dval->min; + *softmax = dval->max; +} + +static void rna_NodeSocketStandard_int_range(PointerRNA *ptr, int *min, int *max, int *softmin, int *softmax) +{ + bNodeSocket *sock = ptr->data; + bNodeSocketValueFloat *dval = sock->default_value; + int subtype = sock->typeinfo->subtype; + + *min = (subtype == PROP_UNSIGNED ? 0 : INT_MIN); + *max = INT_MAX; + *softmin = dval->min; + *softmax = dval->max; +} + +static void rna_NodeSocketStandard_vector_range(PointerRNA *ptr, float *min, float *max, float *softmin, float *softmax) +{ + bNodeSocket *sock = ptr->data; + bNodeSocketValueVector *dval = sock->default_value; + + *min = -FLT_MAX; + *max = FLT_MAX; + *softmin = dval->min; + *softmax = dval->max; +} + /* using a context update function here, to avoid searching the node if possible */ static void rna_NodeSocketStandard_value_update(struct bContext *C, PointerRNA *ptr) { @@ -6033,6 +6068,7 @@ static void rna_def_node_socket_float(BlenderRNA *brna, const char *idname, cons prop = RNA_def_property(srna, "default_value", PROP_FLOAT, subtype); RNA_def_property_float_sdna(prop, NULL, "value"); + RNA_def_property_float_funcs(prop, NULL, NULL, "rna_NodeSocketStandard_float_range"); RNA_def_property_ui_text(prop, "Default Value", "Input value used for unconnected socket"); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeSocketStandard_value_update"); RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); @@ -6059,6 +6095,7 @@ static void rna_def_node_socket_int(BlenderRNA *brna, const char *identifier, co prop = RNA_def_property(srna, "default_value", PROP_INT, subtype); RNA_def_property_int_sdna(prop, NULL, "value"); + RNA_def_property_int_funcs(prop, NULL, NULL, "rna_NodeSocketStandard_int_range"); RNA_def_property_ui_text(prop, "Default Value", "Input value used for unconnected socket"); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeSocketStandard_value_update"); RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); @@ -6111,6 +6148,7 @@ static void rna_def_node_socket_vector(BlenderRNA *brna, const char *identifier, prop = RNA_def_property(srna, "default_value", PROP_FLOAT, subtype); RNA_def_property_float_sdna(prop, NULL, "value"); + RNA_def_property_float_funcs(prop, NULL, NULL, "rna_NodeSocketStandard_vector_range"); RNA_def_property_ui_text(prop, "Default Value", "Input value used for unconnected socket"); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeSocketStandard_value_update"); RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); |