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.
This commit is contained in:
Hans Goudey 2021-01-27 11:22:55 -06:00
parent c71a8e8376
commit 4c4ccdfa36
1 changed files with 10 additions and 0 deletions

View File

@ -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) {