filter add cycle on prefix
1.4.1 - changed: better filter for applying cycle modifier (prevent targeting prefix-reserved bones)master
parent
8f1f1a6882
commit
31ab45865b
|
@ -1,5 +1,9 @@
|
|||
# Changelog
|
||||
|
||||
1.4.1
|
||||
|
||||
- changed: better filter for applying cycle modifier (prevent targeting prefix-reserved bones)
|
||||
|
||||
1.4.0
|
||||
|
||||
- added: preview of end frame for the cycle bake
|
||||
|
|
|
@ -77,16 +77,6 @@ def bake_cycle(on_selection=True, end=None):
|
|||
k_dic['type'] = k.type
|
||||
fcu_kfs.append(k_dic)
|
||||
|
||||
## not used
|
||||
# second = fcu_kfs[1]['co'][0]
|
||||
# before_last= fcu_kfs[-2]['co'][0]
|
||||
# first_offset = second - first
|
||||
|
||||
## old
|
||||
# first = fcu_kfs[0]['co'][0]
|
||||
# last = fcu_kfs[-1]['co'][0]
|
||||
# current_offset = offset = last - first
|
||||
|
||||
current_offset = offset
|
||||
|
||||
keys_num = len(fcu_kfs)
|
||||
|
@ -102,12 +92,8 @@ def bake_cycle(on_selection=True, end=None):
|
|||
# fcu_kfs_without_last.pop()
|
||||
|
||||
# last_kf = fcu_kfs.pop() (or just iterate with slicing [:-1])
|
||||
# print('offset: ', offset)
|
||||
|
||||
if debug >= 2: print('keys', len(fcu_kfs))
|
||||
## expand to end frame
|
||||
|
||||
# maybe add possibility define target manually ?
|
||||
|
||||
iterations = int( ((end - last) // offset) + 1 )
|
||||
if debug >= 2: print('iterations: ', iterations)
|
||||
|
@ -145,7 +131,7 @@ def bake_cycle(on_selection=True, end=None):
|
|||
if not org_action:
|
||||
return ('ERROR', 'No fcurve with anim cycle found (on baked action)')
|
||||
obj.animation_data.action = org_action
|
||||
return ('ERROR', 'No fcurve with anim cycle found (back to unexpanded)')
|
||||
return ('ERROR', 'No fcurve with cyclic modifier found (used to determine what to bake)')
|
||||
|
||||
if not ct:
|
||||
return ('ERROR', 'No fcurve treated (! action duplicated to _baked !)')
|
||||
|
@ -164,11 +150,6 @@ def step_path():
|
|||
if ob.type != 'ARMATURE':
|
||||
return ('ERROR', 'active is not an armature type')
|
||||
|
||||
## found curve through constraint
|
||||
# curve, const = fn.get_follow_curve_from_armature(ob)
|
||||
# if not const:
|
||||
# return ('ERROR', 'No constraints found')
|
||||
|
||||
act = fn.get_obj_action(ob)
|
||||
if not act:
|
||||
return
|
||||
|
@ -177,11 +158,6 @@ def step_path():
|
|||
# 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))
|
||||
|
||||
## get constraint
|
||||
# curve = const.target
|
||||
# if not curve:
|
||||
# return ('ERROR', f'no target set for {curve.name}')
|
||||
|
||||
offset_fc = None
|
||||
for fc in act.fcurves:
|
||||
|
|
|
@ -4,7 +4,7 @@ bl_info = {
|
|||
"name": "Auto Walk",
|
||||
"description": "Develop a walk/run cycles along a curve and pin feets",
|
||||
"author": "Samuel Bernou",
|
||||
"version": (1, 4, 0),
|
||||
"version": (1, 4, 1),
|
||||
"blender": (3, 0, 0),
|
||||
"location": "View3D",
|
||||
"warning": "",
|
||||
|
|
6
fn.py
6
fn.py
|
@ -645,6 +645,8 @@ def create_cycle_modifiers(ob=None):
|
|||
|
||||
name_list = [b.name for b in ob.data.bones] # if not b.use_deform (too limiting)
|
||||
|
||||
re_prefix = re.compile(r'^(mch|def|org|vis|fld|ctp)[\._-]', flags=re.I)
|
||||
|
||||
for fc in ob.animation_data.action.fcurves:
|
||||
if [m for m in fc.modifiers if m.type == 'CYCLES']:
|
||||
# skip already existing modifier
|
||||
|
@ -654,9 +656,11 @@ def create_cycle_modifiers(ob=None):
|
|||
# skip offset
|
||||
if fc.data_path.endswith('.offset') and 'constraint' in fc.data_path:
|
||||
continue
|
||||
|
||||
b_name = fc.data_path.split('"')[1]
|
||||
if b_name.lower().startswith(('mch', 'def', 'org')):
|
||||
if re_prefix.match(b_name):
|
||||
continue
|
||||
|
||||
if b_name not in name_list:
|
||||
continue
|
||||
# print(f'Adding cycle modifier {fc.data_path}')
|
||||
|
|
Loading…
Reference in New Issue