[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [36021] trunk/blender/release/scripts: " Bugfix" (i.e.

Joshua Leung aligorith at gmail.com
Tue Apr 5 13:49:58 CEST 2011


Revision: 36021
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=36021
Author:   aligorith
Date:     2011-04-05 11:49:58 +0000 (Tue, 05 Apr 2011)
Log Message:
-----------
"Bugfix" (i.e. feature request in disguise!) [#26772] Delta Scaling,
Rotation and Location don't have Keying Sets

Added Keying Sets for Delta Loc/Rot/Scale settings (aka dLoc/dRot).
These settings could already be found in the Object properties, under
the collapsed "Delta Transforms" panel.

I've added these to the end of the Keying Sets list, since adding any
earlier will end up breaking active Keying Set setting in older files.
Besides, these settings aren't that frequently used either...

Modified Paths:
--------------
    trunk/blender/release/scripts/modules/keyingsets_utils.py
    trunk/blender/release/scripts/startup/keyingsets_builtins.py

Modified: trunk/blender/release/scripts/modules/keyingsets_utils.py
===================================================================
--- trunk/blender/release/scripts/modules/keyingsets_utils.py	2011-04-05 11:04:00 UTC (rev 36020)
+++ trunk/blender/release/scripts/modules/keyingsets_utils.py	2011-04-05 11:49:58 UTC (rev 36021)
@@ -52,9 +52,12 @@
 # Poll Callbacks
 
 
-# selected objects
+# selected objects (active object must be in object mode)
 def RKS_POLL_selected_objects(ksi, context):
-    return context.active_object or len(context.selected_objects)
+    if context.active_object:
+        return context.active_object.mode == 'OBJECT'
+    else:
+        return len(context.selected_objects) != 0
 
 
 # selected bones
@@ -84,6 +87,11 @@
     else:
         for ob in context.selected_objects:
             ksi.generate(context, ks, ob)
+            
+# all select objects only
+def RKS_ITER_selected_objects(ksi, context, ks):
+    for ob in context.selected_objects:
+        ksi.generate(context, ks, ob)
 
 ###########################
 # Generate Callbacks

Modified: trunk/blender/release/scripts/startup/keyingsets_builtins.py
===================================================================
--- trunk/blender/release/scripts/startup/keyingsets_builtins.py	2011-04-05 11:04:00 UTC (rev 36020)
+++ trunk/blender/release/scripts/startup/keyingsets_builtins.py	2011-04-05 11:49:58 UTC (rev 36021)
@@ -23,6 +23,11 @@
 None of these Keying Sets should be removed, as these
 are needed by various parts of Blender in order for them
 to work correctly.
+
+Beware also about changing the order that these are defined
+here, since this can result in old files referring to the
+wrong Keying Set as the active one, potentially resulting
+in lost (i.e. unkeyed) animation.
 """
 
 import bpy
@@ -352,7 +357,93 @@
             # for now, just add all of 'em
             ksi.addProp(ks, bone, '["%s"]' % (prop))
 
+###############################
 
+# Delta Location
+class BUILTIN_KSI_DeltaLocation(bpy.types.KeyingSetInfo):
+    bl_label = "Delta Location"
+    
+    # poll - selected objects only (and only if active object in object mode)
+    poll = keyingsets_utils.RKS_POLL_selected_objects
+
+    # iterator - selected objects only
+    iterator = keyingsets_utils.RKS_ITER_selected_objects
+
+    # generator - delta location channels only
+    def generate(ksi, context, ks, data):
+        # get id-block and path info
+        id_block, base_path, grouping = keyingsets_utils.get_transform_generators_base_info(data)
+
+        # add the property name to the base path
+        path = keyingsets_utils.path_add_property(base_path, "delta_location")
+
+        # add Keying Set entry for this...
+        if grouping:
+            ks.paths.add(id_block, path, group_method='NAMED', group_name=grouping)
+        else:
+            ks.paths.add(id_block, path)
+
+
+# Delta Rotation
+class BUILTIN_KSI_DeltaRotation(bpy.types.KeyingSetInfo):
+    bl_label = "Delta Rotation"
+    
+    # poll - selected objects only (and only if active object in object mode)
+    poll = keyingsets_utils.RKS_POLL_selected_objects
+
+    # iterator - selected objects only
+    iterator = keyingsets_utils.RKS_ITER_selected_objects
+
+    # generator - delta location channels only
+    def generate(ksi, context, ks, data):
+        # get id-block and path info
+        id_block, base_path, grouping = keyingsets_utils.get_transform_generators_base_info(data)
+
+        # add the property name to the base path
+        #   rotation mode affects the property used
+        if data.rotation_mode == 'QUATERNION':
+            path = path_add_property(base_path, "delta_rotation_quaternion")
+        elif data.rotation_mode == 'AXIS_ANGLE':
+            # XXX: for now, this is not available yet
+            #path = path_add_property(base_path, "delta_rotation_axis_angle")
+            return;
+        else:
+            path = keyingsets_utils.path_add_property(base_path, "delta_rotation_euler")
+
+        # add Keying Set entry for this...
+        if grouping:
+            ks.paths.add(id_block, path, group_method='NAMED', group_name=grouping)
+        else:
+            ks.paths.add(id_block, path)
+    
+
+# Delta Scale
+class BUILTIN_KSI_DeltaScale(bpy.types.KeyingSetInfo):
+    bl_label = "Delta Scale"
+    
+    # poll - selected objects only (and only if active object in object mode)
+    poll = keyingsets_utils.RKS_POLL_selected_objects
+
+    # iterator - selected objects only
+    iterator = keyingsets_utils.RKS_ITER_selected_objects
+
+    # generator - delta location channels only
+    def generate(ksi, context, ks, data):
+        # get id-block and path info
+        id_block, base_path, grouping = keyingsets_utils.get_transform_generators_base_info(data)
+
+        # add the property name to the base path
+        path = keyingsets_utils.path_add_property(base_path, "delta_scale")
+
+        # add Keying Set entry for this...
+        if grouping:
+            ks.paths.add(id_block, path, group_method='NAMED', group_name=grouping)
+        else:
+            ks.paths.add(id_block, path)
+
+###############################
+
+
 def register():
     bpy.utils.register_module(__name__)
 




More information about the Bf-blender-cvs mailing list