Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntony Riakiotakis <kalast@gmail.com>2013-09-12 03:28:23 +0400
committerAntony Riakiotakis <kalast@gmail.com>2013-09-12 03:28:23 +0400
commitf16047c2df1e8be56bf76524f9eb1fa5ecde2176 (patch)
treecc7fbd339fb547e163e7e2fd552d05d5e960ccbe /source/blender/makesrna/intern/rna_color.c
parent494687908c0d0a66abd17b33536dce56b8925309 (diff)
Better fix for #36688.
Throw a python error if user attempts to use CurveMap without calling CurveMapping.initialize() first. Added access to the initialize function to CurveMapping on RNA level. Thanks to Campbel for the help and remarks!
Diffstat (limited to 'source/blender/makesrna/intern/rna_color.c')
-rw-r--r--source/blender/makesrna/intern/rna_color.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/source/blender/makesrna/intern/rna_color.c b/source/blender/makesrna/intern/rna_color.c
index b184cc11286..2fba4e9ed7b 100644
--- a/source/blender/makesrna/intern/rna_color.c
+++ b/source/blender/makesrna/intern/rna_color.c
@@ -621,12 +621,19 @@ static void rna_ColorManagement_update(Main *UNUSED(bmain), Scene *UNUSED(scene)
}
/* this function only exists because #curvemap_evaluateF uses a 'const' qualifier */
-static float rna_CurveMap_evaluateF(struct CurveMap *cuma, float value)
+static float rna_CurveMap_evaluateF(struct CurveMap *cuma, ReportList *reports, float value)
{
- curvemap_initialize(cuma);
+ if (!cuma->table) {
+ BKE_reportf(reports, RPT_ERROR, "CurveMap table not initialized, call initialize() on CurveMapping owner of the CurveMap");
+ return 0.0f;
+ }
return curvemap_evaluateF(cuma, value);
}
+static void rna_CurveMap_initialize(struct CurveMapping *cumap)
+{
+ curvemapping_initialize(cumap);
+}
#else
static void rna_def_curvemappoint(BlenderRNA *brna)
@@ -712,6 +719,7 @@ static void rna_def_curvemap(BlenderRNA *brna)
rna_def_curvemap_points_api(brna, prop);
func = RNA_def_function(srna, "evaluate", "rna_CurveMap_evaluateF");
+ RNA_def_function_flag(func, FUNC_USE_REPORTS);
RNA_def_function_ui_description(func, "Evaluate curve at given location");
parm = RNA_def_float(func, "position", 0.0f, -FLT_MAX, FLT_MAX, "Position", "Position to evaluate curve at", -FLT_MAX, FLT_MAX);
RNA_def_property_flag(parm, PROP_REQUIRED);
@@ -780,6 +788,9 @@ static void rna_def_curvemapping(BlenderRNA *brna)
func = RNA_def_function(srna, "update", "curvemapping_changed_all");
RNA_def_function_ui_description(func, "Update curve mapping after making changes");
+
+ func = RNA_def_function(srna, "initialize", "rna_CurveMap_initialize");
+ RNA_def_function_ui_description(func, "Initialize curve");
}
static void rna_def_color_ramp_element(BlenderRNA *brna)