[Bf-blender-cvs] [4c4ccdfa366] master: RNA: Add warning to float percentage property definition
Hans Goudey
noreply at git.blender.org
Wed Jan 27 18:23:01 CET 2021
Commit: 4c4ccdfa3663695950f409ed6a07c446b9f56093
Author: Hans Goudey
Date: Wed Jan 27 11:22:55 2021 -0600
Branches: master
https://developer.blender.org/rB4c4ccdfa3663695950f409ed6a07c446b9f56093
RNA: Add warning to float percentage property definition
As a followup to rBc71a8e837616159735, add a debug-only check for
incorrect range, when the percentage and factor functions were likely
confused.
===================================================================
M source/blender/makesrna/intern/rna_define.c
===================================================================
diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c
index cec6a50d170..da04ac63ee3 100644
--- a/source/blender/makesrna/intern/rna_define.c
+++ b/source/blender/makesrna/intern/rna_define.c
@@ -4111,6 +4111,16 @@ PropertyRNA *RNA_def_float_percentage(StructOrFunctionRNA *cont_,
ASSERT_SOFT_HARD_LIMITS;
+#ifdef DEBUG
+ /* Properties with PROP_PERCENTAGE should use a range like 0 to 100, unlike PROP_FACTOR. */
+ if (hardmax < 2.0f) {
+ CLOG_WARN(&LOG,
+ "Percentage property with incorrect range: %s.%s",
+ CONTAINER_RNA_ID(cont),
+ identifier);
+ }
+#endif
+
prop = RNA_def_property(cont, identifier, PROP_FLOAT, PROP_PERCENTAGE);
RNA_def_property_float_default(prop, default_value);
if (hardmin != hardmax) {
More information about the Bf-blender-cvs
mailing list