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
This commit is contained in:
Alexander Gavrilov
2018-12-15 22:37:12 +03:00
parent 908a274240
commit 61c941f040
8 changed files with 350 additions and 9 deletions

View File

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