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:
authorAlexander Gavrilov <angavrilov@gmail.com>2018-12-15 22:37:12 +0300
committerAlexander Gavrilov <angavrilov@gmail.com>2018-12-19 14:20:35 +0300
commit61c941f040d367d18fcaa57c9e8e0c2078193d97 (patch)
tree9cf843e4f19fffda991afb77595ec4d287a0b142 /release/scripts/startup/bl_operators/object.py
parent908a2742403b279cd6dfa5c27acb76d68d3f1523 (diff)
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
Diffstat (limited to 'release/scripts/startup/bl_operators/object.py')
-rw-r--r--release/scripts/startup/bl_operators/object.py44
1 files changed, 44 insertions, 0 deletions
diff --git a/release/scripts/startup/bl_operators/object.py b/release/scripts/startup/bl_operators/object.py
index 949e2baff03..660f87aea0d 100644
--- a/release/scripts/startup/bl_operators/object.py
+++ b/release/scripts/startup/bl_operators/object.py
@@ -943,6 +943,49 @@ class LoadReferenceImage(LoadImageAsEmpty, Operator):
pass
+class OBJECT_OT_assign_property_defaults(Operator):
+ """Assign the current values of custom properties as their defaults, for use as part of the rest pose state in NLA track mixing"""
+ bl_idname = "object.assign_property_defaults"
+ bl_label = "Assign Custom Property Values as Default"
+ bl_options = {'UNDO', 'REGISTER'}
+
+ process_data: BoolProperty(name="Process data properties", default=True)
+ process_bones: BoolProperty(name="Process bone properties", default=True)
+
+ @classmethod
+ def poll(cls, context):
+ obj = context.active_object
+ return obj is not None and obj.library is None and obj.mode in {'POSE', 'OBJECT'}
+
+ @staticmethod
+ def assign_defaults(obj):
+ from rna_prop_ui import rna_idprop_ui_prop_default_set
+
+ rna_properties = {'_RNA_UI'} | {prop.identifier for prop in obj.bl_rna.properties if prop.is_runtime}
+
+ for prop, value in obj.items():
+ if prop not in rna_properties:
+ rna_idprop_ui_prop_default_set(obj, prop, value)
+
+ def execute(self, context):
+ obj = context.active_object
+
+ self.assign_defaults(obj)
+
+ if self.process_bones and obj.pose:
+ for pbone in obj.pose.bones:
+ self.assign_defaults(pbone)
+
+ if self.process_data and obj.data and obj.data.library is None:
+ self.assign_defaults(obj.data)
+
+ if self.process_bones and isinstance(obj.data, bpy.types.Armature):
+ for bone in obj.data.bones:
+ self.assign_defaults(bone)
+
+ return {'FINISHED'}
+
+
classes = (
ClearAllRestrictRender,
DupliOffsetFromCursor,
@@ -958,4 +1001,5 @@ classes = (
SubdivisionSet,
TransformsToDeltas,
TransformsToDeltasAnim,
+ OBJECT_OT_assign_property_defaults,
)