From 61c941f040d367d18fcaa57c9e8e0c2078193d97 Mon Sep 17 00:00:00 2001 From: Alexander Gavrilov Date: Sat, 15 Dec 2018 22:37:12 +0300 Subject: RNA: support setting default values for custom properties. NLA requires a usable default value for all properties that are to be animated via it, without any exceptions. This is the real cause of T36496: using the default of 0 for a scale related custom property obviously doesn't work. Thus, to really fix this it is necessary to support configurable default values for custom properties, which are very frequently used in rigs for auxiliary settings. For common use it is enough to support this for scalar float and integer properties. The default can be set via the custom property configuration popup, or a right click menu option. In addition, to help in updating old rigs, an operator that saves current values as defaults for all object and bone properties is added. Reviewers: campbellbarton, brecht Differential Revision: https://developer.blender.org/D4084 --- release/scripts/modules/rna_prop_ui.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'release/scripts/modules/rna_prop_ui.py') diff --git a/release/scripts/modules/rna_prop_ui.py b/release/scripts/modules/rna_prop_ui.py index fc17cc60c6c..f08390cfd6d 100644 --- a/release/scripts/modules/rna_prop_ui.py +++ b/release/scripts/modules/rna_prop_ui.py @@ -96,6 +96,25 @@ def rna_idprop_has_properties(rna_item): return (nbr_props > 1) or (nbr_props and '_RNA_UI' not in keys) +def rna_idprop_ui_prop_default_set(item, prop, value): + defvalue = None + try: + prop_type = type(item[prop]) + + if prop_type in {int, float}: + defvalue = prop_type(value) + except KeyError: + pass + + if defvalue: + rna_ui = rna_idprop_ui_prop_get(item, prop, True) + rna_ui["default"] = defvalue + else: + rna_ui = rna_idprop_ui_prop_get(item, prop) + if rna_ui and "default" in rna_ui: + del rna_ui["default"] + + def draw(layout, context, context_member, property_type, use_edit=True): def assign_props(prop, val, key): -- cgit v1.2.3