update fcurve after bake

master
Pullusb 2022-04-01 12:12:05 +02:00
parent 8f280d37e0
commit d77ab84c06
5 changed files with 30 additions and 11 deletions

View File

@ -8,7 +8,6 @@ from time import time
def bake_cycle(on_selection=True):
print(fn.helper())
debug = fn.get_addon_prefs().debug
print('debug: ', debug)
obj = bpy.context.object
if obj.type != 'ARMATURE':
print('ERROR', 'active is not an armature type')
@ -120,12 +119,15 @@ def bake_cycle(on_selection=True):
if not ct:
return ('ERROR', 'No fcurve treated (! action duplicated to _expand !)')
# cleaning update
fn.update_action(act)
print('end of anim cycle keys baking')
# C.scene.frame_current = org_frame
# detect last key in contact
def step_path():
'''Step the path anim of the curve to constant'''
print(fn.helper())
obj = bpy.context.object
@ -140,7 +142,7 @@ def step_path():
act = fn.get_obj_action(obj)
if not act: return
# CHANGE - retiré le int de la frame
# CHANGE - removed int from frame
# keyframes = [int(k.co[0]) for fcu in act.fcurves for k in fcu.keyframe_points]
keyframes = [k.co[0] for fcu in act.fcurves for k in fcu.keyframe_points]
keyframes = list(set(keyframes))
@ -175,9 +177,10 @@ def step_path():
for k in t_fcu.keyframe_points:
k.interpolation = 'CONSTANT'
# cleaning update (might not be needed here)
fn.update_action(act)
print('end of step_anim')
class UAC_OT_bake_cycle_and_step(bpy.types.Operator):
bl_idname = "anim.bake_cycle_and_step"
bl_label = "Bake key and step path "
@ -218,10 +221,7 @@ class UAC_OT_bake_cycle_and_step(bpy.types.Operator):
for k in timef.keyframe_points:
k.interpolation = 'LINEAR'
print(f'Anim path to linear : Deleted all keys ({keys_ct - 2}) on anim path except first and last')
# CHAINED ACTION pin feet ?? : Step the path of the curve path
return {"FINISHED"}

View File

@ -158,7 +158,7 @@ class UAC_OT_create_curve_path(bpy.types.Operator):
class UAC_OT_create_follow_path(bpy.types.Operator):
bl_idname = "anim.create_follow_path"
bl_label = "Create follow path constraint"
bl_label = "Create Follow Path Constraint"
bl_description = "Create follow path targeting curve in field"
bl_options = {"REGISTER", "UNDO"}
@ -178,7 +178,7 @@ class UAC_OT_create_follow_path(bpy.types.Operator):
class UAC_OT_snap_curve_to_ground(bpy.types.Operator):
bl_idname = "anim.snap_curve_to_ground"
bl_label = "snap_curve_to_ground"
bl_description = "snap curve"
bl_description = "Snap Curve"
bl_options = {"REGISTER", "UNDO"}
@classmethod

View File

@ -39,6 +39,10 @@ Sidebar > Anim > unfold anim cycle
## Changelog:
0.4.1
- update fcurve after bake
0.4.0
- better curve creation

View File

@ -2,7 +2,7 @@ bl_info = {
"name": "Unfold Anim Cycle",
"description": "Anim tools to develop walk/run cycles along a curve",
"author": "Samuel Bernou",
"version": (0, 4, 0),
"version": (0, 4, 1),
"blender": (3, 0, 0),
"location": "View3D",
"warning": "WIP",

17
fn.py
View File

@ -296,4 +296,19 @@ def generate_curve(location=(0,0,0), direction=(1,0,0), name='curve_path', enter
context.space_data.overlay.show_curve_normals = True
context.space_data.overlay.normals_length = 0.2
return curve
return curve
def update_action(act):
'''update fcurves (often broken after generation through API)'''
# update fcurves
for fcu in act.fcurves:
fcu.update()
# redraw graph area
for window in bpy.context.window_manager.windows:
screen = window.screen
for area in screen.areas:
if area.type == 'GRAPH_EDITOR':
area.tag_redraw()