Added baking/unbaking functionality to constraint system. Retargeting now adds/manages 2 new NLA Tracks as planned. Modified bl_operatores/nla.py slightly to use it instead of creating my own bake function (now supports baking to a specific action, vs always creating a new one), but this does not break using the function in the old way.
This commit is contained in:
@@ -83,7 +83,7 @@ def bake(frame_start,
|
||||
do_pose=True,
|
||||
do_object=True,
|
||||
do_constraint_clear=False,
|
||||
):
|
||||
action=None):
|
||||
|
||||
scene = bpy.context.scene
|
||||
obj = bpy.context.object
|
||||
@@ -120,7 +120,8 @@ def bake(frame_start,
|
||||
|
||||
# incase animation data hassnt been created
|
||||
atd = obj.animation_data_create()
|
||||
action = bpy.data.actions.new("Action")
|
||||
if action == None:
|
||||
action = bpy.data.actions.new("Action")
|
||||
atd.action = action
|
||||
|
||||
if do_pose:
|
||||
@@ -253,37 +254,38 @@ class BakeAction(bpy.types.Operator):
|
||||
def invoke(self, context, event):
|
||||
wm = context.window_manager
|
||||
return wm.invoke_props_dialog(self)
|
||||
|
||||
|
||||
#################################
|
||||
|
||||
|
||||
class ClearUselessActions(bpy.types.Operator):
|
||||
'''Mark actions with no F-Curves for deletion after save+reload of file preserving "action libraries"'''
|
||||
bl_idname = "anim.clear_useless_actions"
|
||||
bl_label = "Clear Useless Actions"
|
||||
bl_options = {'REGISTER', 'UNDO'}
|
||||
|
||||
only_unused = BoolProperty(name="Only Unused",
|
||||
|
||||
only_unused = BoolProperty(name="Only Unused",
|
||||
description="Only unused (Fake User only) actions get considered",
|
||||
default=True)
|
||||
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
return len(bpy.data.actions) != 0
|
||||
|
||||
|
||||
def execute(self, context):
|
||||
removed = 0
|
||||
|
||||
|
||||
for action in bpy.data.actions:
|
||||
# if only user is "fake" user...
|
||||
if ((self.only_unused is False) or
|
||||
if ((self.only_unused is False) or
|
||||
(action.use_fake_user and action.users == 1)):
|
||||
|
||||
# if it has F-Curves, then it's a "action library" (i.e. walk, wave, jump, etc.)
|
||||
|
||||
# if it has F-Curves, then it's a "action library" (i.e. walk, wave, jump, etc.)
|
||||
# and should be left alone as that's what fake users are for!
|
||||
if not action.fcurves:
|
||||
# mark action for deletion
|
||||
action.user_clear()
|
||||
removed += 1
|
||||
|
||||
|
||||
self.report({'INFO'}, "Removed %d empty and/or fake-user only Actions" % (removed))
|
||||
return {'FINISHED'}
|
||||
|
||||
Reference in New Issue
Block a user