From 31ab45865beb83ca0361a1eb74f49d20e137585d Mon Sep 17 00:00:00 2001 From: Pullusb Date: Tue, 26 Apr 2022 11:04:44 +0200 Subject: [PATCH] filter add cycle on prefix 1.4.1 - changed: better filter for applying cycle modifier (prevent targeting prefix-reserved bones) --- CHANGELOG.md | 4 ++++ OP_expand_cycle_step.py | 26 +------------------------- __init__.py | 2 +- fn.py | 6 +++++- 4 files changed, 11 insertions(+), 27 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 59a4794..845f753 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/OP_expand_cycle_step.py b/OP_expand_cycle_step.py index d9fa7f4..cf39d86 100644 --- a/OP_expand_cycle_step.py +++ b/OP_expand_cycle_step.py @@ -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: diff --git a/__init__.py b/__init__.py index 45a55f4..a9b78bf 100644 --- a/__init__.py +++ b/__init__.py @@ -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": "", diff --git a/fn.py b/fn.py index e5d0374..00e77c5 100644 --- a/fn.py +++ b/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}')