update fcurve after bake
parent
8f280d37e0
commit
d77ab84c06
|
@ -8,7 +8,6 @@ from time import time
|
||||||
def bake_cycle(on_selection=True):
|
def bake_cycle(on_selection=True):
|
||||||
print(fn.helper())
|
print(fn.helper())
|
||||||
debug = fn.get_addon_prefs().debug
|
debug = fn.get_addon_prefs().debug
|
||||||
print('debug: ', debug)
|
|
||||||
obj = bpy.context.object
|
obj = bpy.context.object
|
||||||
if obj.type != 'ARMATURE':
|
if obj.type != 'ARMATURE':
|
||||||
print('ERROR', 'active is not an armature type')
|
print('ERROR', 'active is not an armature type')
|
||||||
|
@ -120,12 +119,15 @@ def bake_cycle(on_selection=True):
|
||||||
if not ct:
|
if not ct:
|
||||||
return ('ERROR', 'No fcurve treated (! action duplicated to _expand !)')
|
return ('ERROR', 'No fcurve treated (! action duplicated to _expand !)')
|
||||||
|
|
||||||
|
# cleaning update
|
||||||
|
fn.update_action(act)
|
||||||
print('end of anim cycle keys baking')
|
print('end of anim cycle keys baking')
|
||||||
# C.scene.frame_current = org_frame
|
# C.scene.frame_current = org_frame
|
||||||
# detect last key in contact
|
# detect last key in contact
|
||||||
|
|
||||||
|
|
||||||
def step_path():
|
def step_path():
|
||||||
|
'''Step the path anim of the curve to constant'''
|
||||||
print(fn.helper())
|
print(fn.helper())
|
||||||
|
|
||||||
obj = bpy.context.object
|
obj = bpy.context.object
|
||||||
|
@ -140,7 +142,7 @@ def step_path():
|
||||||
act = fn.get_obj_action(obj)
|
act = fn.get_obj_action(obj)
|
||||||
if not act: return
|
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 = [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 = [k.co[0] for fcu in act.fcurves for k in fcu.keyframe_points]
|
||||||
keyframes = list(set(keyframes))
|
keyframes = list(set(keyframes))
|
||||||
|
@ -175,9 +177,10 @@ def step_path():
|
||||||
for k in t_fcu.keyframe_points:
|
for k in t_fcu.keyframe_points:
|
||||||
k.interpolation = 'CONSTANT'
|
k.interpolation = 'CONSTANT'
|
||||||
|
|
||||||
|
# cleaning update (might not be needed here)
|
||||||
|
fn.update_action(act)
|
||||||
print('end of step_anim')
|
print('end of step_anim')
|
||||||
|
|
||||||
|
|
||||||
class UAC_OT_bake_cycle_and_step(bpy.types.Operator):
|
class UAC_OT_bake_cycle_and_step(bpy.types.Operator):
|
||||||
bl_idname = "anim.bake_cycle_and_step"
|
bl_idname = "anim.bake_cycle_and_step"
|
||||||
bl_label = "Bake key and step path "
|
bl_label = "Bake key and step path "
|
||||||
|
@ -219,9 +222,6 @@ class UAC_OT_bake_cycle_and_step(bpy.types.Operator):
|
||||||
k.interpolation = 'LINEAR'
|
k.interpolation = 'LINEAR'
|
||||||
print(f'Anim path to linear : Deleted all keys ({keys_ct - 2}) on anim path except first and last')
|
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
|
# CHAINED ACTION pin feet ?? : Step the path of the curve path
|
||||||
|
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
|
@ -158,7 +158,7 @@ class UAC_OT_create_curve_path(bpy.types.Operator):
|
||||||
|
|
||||||
class UAC_OT_create_follow_path(bpy.types.Operator):
|
class UAC_OT_create_follow_path(bpy.types.Operator):
|
||||||
bl_idname = "anim.create_follow_path"
|
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_description = "Create follow path targeting curve in field"
|
||||||
bl_options = {"REGISTER", "UNDO"}
|
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):
|
class UAC_OT_snap_curve_to_ground(bpy.types.Operator):
|
||||||
bl_idname = "anim.snap_curve_to_ground"
|
bl_idname = "anim.snap_curve_to_ground"
|
||||||
bl_label = "snap_curve_to_ground"
|
bl_label = "snap_curve_to_ground"
|
||||||
bl_description = "snap curve"
|
bl_description = "Snap Curve"
|
||||||
bl_options = {"REGISTER", "UNDO"}
|
bl_options = {"REGISTER", "UNDO"}
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|
|
@ -39,6 +39,10 @@ Sidebar > Anim > unfold anim cycle
|
||||||
|
|
||||||
## Changelog:
|
## Changelog:
|
||||||
|
|
||||||
|
0.4.1
|
||||||
|
|
||||||
|
- update fcurve after bake
|
||||||
|
|
||||||
0.4.0
|
0.4.0
|
||||||
|
|
||||||
- better curve creation
|
- better curve creation
|
||||||
|
|
|
@ -2,7 +2,7 @@ bl_info = {
|
||||||
"name": "Unfold Anim Cycle",
|
"name": "Unfold Anim Cycle",
|
||||||
"description": "Anim tools to develop walk/run cycles along a curve",
|
"description": "Anim tools to develop walk/run cycles along a curve",
|
||||||
"author": "Samuel Bernou",
|
"author": "Samuel Bernou",
|
||||||
"version": (0, 4, 0),
|
"version": (0, 4, 1),
|
||||||
"blender": (3, 0, 0),
|
"blender": (3, 0, 0),
|
||||||
"location": "View3D",
|
"location": "View3D",
|
||||||
"warning": "WIP",
|
"warning": "WIP",
|
||||||
|
|
15
fn.py
15
fn.py
|
@ -297,3 +297,18 @@ def generate_curve(location=(0,0,0), direction=(1,0,0), name='curve_path', enter
|
||||||
context.space_data.overlay.normals_length = 0.2
|
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()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue