diff options
author | Miika Hamalainen <blender@miikah.org> | 2011-06-27 12:11:05 +0400 |
---|---|---|
committer | Miika Hamalainen <blender@miikah.org> | 2011-06-27 12:11:05 +0400 |
commit | c896fcae7963fb35124ef3fefe0f12679228fa39 (patch) | |
tree | f4435bd39a36228a71c9142e4c26bacd482683f3 /source/blender/makesrna/intern/makesrna.c | |
parent | cb12648656fc001e8c4c6d00df73e52d452f8787 (diff) | |
parent | 93bb6238e0c6b7ea008776f4e1c3958ef5382c09 (diff) |
Merge with trunk r37849
Diffstat (limited to 'source/blender/makesrna/intern/makesrna.c')
-rw-r--r-- | source/blender/makesrna/intern/makesrna.c | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index 36411f64ec4..3af4e8308d6 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -644,6 +644,25 @@ static char *rna_def_property_get_func(FILE *f, StructRNA *srna, PropertyRNA *pr return func; } +/* defined min/max variables to be used by rna_clamp_value() */ +static void rna_clamp_value_range(FILE *f, PropertyRNA *prop) +{ + if(prop->type == PROP_FLOAT) { + FloatPropertyRNA *fprop= (FloatPropertyRNA*)prop; + if(fprop->range) { + fprintf(f, " float prop_clamp_min, prop_clamp_max;\n"); + fprintf(f, " %s(ptr, &prop_clamp_min, &prop_clamp_max);\n", rna_function_string(fprop->range)); + } + } + else if(prop->type == PROP_INT) { + IntPropertyRNA *iprop= (IntPropertyRNA*)prop; + if(iprop->range) { + fprintf(f, " int prop_clamp_min, prop_clamp_max;\n"); + fprintf(f, " %s(ptr, &prop_clamp_min, &prop_clamp_max);\n", rna_function_string(iprop->range)); + } + } +} + static void rna_clamp_value(FILE *f, PropertyRNA *prop, int array) { if(prop->type == PROP_INT) { @@ -652,8 +671,13 @@ static void rna_clamp_value(FILE *f, PropertyRNA *prop, int array) if(iprop->hardmin != INT_MIN || iprop->hardmax != INT_MAX) { if(array) fprintf(f, "CLAMPIS(values[i], "); else fprintf(f, "CLAMPIS(value, "); - rna_int_print(f, iprop->hardmin); fprintf(f, ", "); - rna_int_print(f, iprop->hardmax); fprintf(f, ");\n"); + if(iprop->range) { + fprintf(f, "prop_clamp_min, prop_clamp_max);"); + } + else { + rna_int_print(f, iprop->hardmin); fprintf(f, ", "); + rna_int_print(f, iprop->hardmax); fprintf(f, ");\n"); + } return; } } @@ -663,8 +687,13 @@ static void rna_clamp_value(FILE *f, PropertyRNA *prop, int array) if(fprop->hardmin != -FLT_MAX || fprop->hardmax != FLT_MAX) { if(array) fprintf(f, "CLAMPIS(values[i], "); else fprintf(f, "CLAMPIS(value, "); - rna_float_print(f, fprop->hardmin); fprintf(f, ", "); - rna_float_print(f, fprop->hardmax); fprintf(f, ");\n"); + if(fprop->range) { + fprintf(f, "prop_clamp_min, prop_clamp_max);"); + } + else { + rna_float_print(f, fprop->hardmin); fprintf(f, ", "); + rna_float_print(f, fprop->hardmax); fprintf(f, ");\n"); + } return; } } @@ -767,11 +796,13 @@ static char *rna_def_property_set_func(FILE *f, StructRNA *srna, PropertyRNA *pr char *lenfunc= rna_alloc_function_name(srna->identifier, rna_safe_id(prop->identifier), "set_length"); fprintf(f, " int i, arraylen[RNA_MAX_ARRAY_DIMENSION];\n"); fprintf(f, " int len= %s(ptr, arraylen);\n\n", lenfunc); + rna_clamp_value_range(f, prop); fprintf(f, " for(i=0; i<len; i++) {\n"); MEM_freeN(lenfunc); } else { fprintf(f, " int i;\n\n"); + rna_clamp_value_range(f, prop); fprintf(f, " for(i=0; i<%d; i++) {\n", prop->totarraylength); } @@ -833,6 +864,7 @@ static char *rna_def_property_set_func(FILE *f, StructRNA *srna, PropertyRNA *pr fprintf(f, " data->%s |= value;\n", dp->dnaname); } else { + rna_clamp_value_range(f, prop); fprintf(f, " data->%s= %s", dp->dnaname, (dp->booleannegative)? "!": ""); rna_clamp_value(f, prop, 0); } |