[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [39061] branches/soc-2011-pepper/release/ scripts: Post Retarget fixes - added an Update Constraints button, that recalculates all fixes.

Benjy Cook benjycook at hotmail.com
Fri Aug 5 10:44:16 CEST 2011


Revision: 39061
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=39061
Author:   benjycook
Date:     2011-08-05 08:44:16 +0000 (Fri, 05 Aug 2011)
Log Message:
-----------
Post Retarget fixes - added an Update Constraints button, that recalculates all fixes. Useful for when the user makes some external change to the animation

Modified Paths:
--------------
    branches/soc-2011-pepper/release/scripts/modules/mocap_constraints.py
    branches/soc-2011-pepper/release/scripts/startup/ui_mocap.py

Modified: branches/soc-2011-pepper/release/scripts/modules/mocap_constraints.py
===================================================================
--- branches/soc-2011-pepper/release/scripts/modules/mocap_constraints.py	2011-08-05 08:41:16 UTC (rev 39060)
+++ branches/soc-2011-pepper/release/scripts/modules/mocap_constraints.py	2011-08-05 08:44:16 UTC (rev 39061)
@@ -419,3 +419,10 @@
             if ik_con:
                 ik_con.mute = False
         m_constraint.active = True
+
+
+def updateConstraints(obj, context):
+    fixes = obj.data.mocap_constraints
+    for fix in fixes:
+        fix.active = False
+        fix.active = True

Modified: branches/soc-2011-pepper/release/scripts/startup/ui_mocap.py
===================================================================
--- branches/soc-2011-pepper/release/scripts/startup/ui_mocap.py	2011-08-05 08:41:16 UTC (rev 39060)
+++ branches/soc-2011-pepper/release/scripts/startup/ui_mocap.py	2011-08-05 08:44:16 UTC (rev 39061)
@@ -264,9 +264,10 @@
                     enduser_obj = context.active_object
                     enduser_arm = enduser_obj.data
                     layout.operator_menu_enum("mocap.addmocapfix", "type")
+                    layout.operator("mocap.updateconstraints", text='Update Fixes')
                     bakeRow = layout.row()
-                    bakeRow.operator("mocap.bakeconstraints")
-                    bakeRow.operator("mocap.unbakeconstraints")
+                    bakeRow.operator("mocap.bakeconstraints", text='Bake Fixes')
+                    bakeRow.operator("mocap.unbakeconstraints", text='Unbake Fixes')
                     layout.separator()
                     for i, m_constraint in enumerate(enduser_arm.mocap_constraints):
                         box = layout.box()
@@ -588,6 +589,21 @@
             return isinstance(context.active_object.data, bpy.types.Armature)
 
 
+class OBJECT_OT_UpdateMocapConstraints(bpy.types.Operator):
+    '''Updates all post-retarget fixes - needed after changes to armature object or pose'''
+    bl_idname = "mocap.updateconstraints"
+    bl_label = "Updates all fixes to target armature - neccesary to take under consideration changes to armature object or pose"
+
+    def execute(self, context):
+        updateConstraints(context.active_object, context)
+        return {"FINISHED"}
+
+    @classmethod
+    def poll(cls, context):
+        if context.active_object:
+            return isinstance(context.active_object.data, bpy.types.Armature)
+
+
 class OBJECT_OT_GuessHierachyMapping(bpy.types.Operator):
     '''Attemps to auto figure out hierarchy mapping'''
     bl_idname = "mocap.guessmapping"
@@ -623,7 +639,7 @@
     @classmethod
     def poll(cls, context):
         if context.active_object:
-            selected_objs = [obj for obj in context.selected_objects if obj != context.active_object]
+            selected_objs = [obj for obj in context.selected_objects if obj != context.active_object and isinstance(obj.data, bpy.types.Curve)]
             return selected_objs
         else:
             return False




More information about the Bf-blender-cvs mailing list