cahnged actions name and custom panel tab

0.7.1

- customizable panel category name
- Change generated action name:
    - `expanded` -> `baked`
    - `autogen` -> `pinned`
master
Pullusb 2022-04-12 11:21:00 +02:00
parent cf8fdc0f71
commit 427a3ad4b2
8 changed files with 111 additions and 77 deletions

63
CHANGELOG.md Normal file
View File

@ -0,0 +1,63 @@
# Changelog
0.7.1
- customizable panel category name
- Change generated action name:
- `expanded` -> `baked`
- `autogen` -> `pinned`
0.7.0
- auto-detect foot to use for path animation
- button to go back and forth between curve edit and armature pose mode
- UI revamp showing better separation of tool categories
0.6.0
- World paste and `Jump next frame`
- more compact and improved ui for world paste
- fix errors in some operators
0.5.0
- pin feet working
0.4.2
- context manager for `expand cycle step` store / restore
0.4.1
- update fcurve after bake
0.4.0
- better curve creation
0.3.5
- partly working
0.3.3
- total wip
0.3.0
- Rework interface
- Add manual bone pinning: simple world space copy/paste + pose and jump prev/next
- Faster pin feets
- bool prop to disable end/curve stepping (interpolation as linear if needed)
- Switch action back to new curve when re-snapping to ground
- fix shrinkwrap
- fix rebake with linear
- error message when no fcurve has anim cycle
0.2.0:
- first working version
0.1.0:
- initial commit, halfway there

View File

@ -81,8 +81,8 @@ def find_best_foot(ob):
return ('ERROR', f'No action active on {ob.name}')
# use original action as ref
if '_expanded' in act.name:
base_act_name = act.name.split('_expanded')[0]
if '_baked' in act.name:
base_act_name = act.name.split('_baked')[0]
base_act = bpy.data.actions.get(base_act_name)
if base_act:
act = base_act
@ -161,8 +161,8 @@ def anim_path_from_translate():
return ('ERROR', f'No action active on {ob.name}')
# use original action as ref
if '_expanded' in act.name:
base_act_name = act.name.split('_expanded')[0]
if '_baked' in act.name:
base_act_name = act.name.split('_baked')[0]
base_act = bpy.data.actions.get(base_act_name)
if base_act:
act = base_act
@ -362,7 +362,7 @@ class UAC_OT_adjust_animation_length(bpy.types.Operator):
self.report({'ERROR'}, f'No action on {ob.name} data')
return {"CANCELLED"}
# if '_expanded' in self.act.name:
# if '_baked' in self.act.name:
# self.report({'WARNING'}, f'Action is expanded')
const = root.constraints.get("Follow Path")

View File

@ -14,7 +14,7 @@ def bake_cycle(on_selection=True):
print('ERROR', 'active is not an armature type')
return
act = fn.set_expanded_action(obj)
act = fn.set_baked_action(obj)
if not act:
return
@ -107,7 +107,7 @@ def bake_cycle(on_selection=True):
ct += 1
if ct_fcu == ct_no_cycle: # skipped because no cycle exists
rexpand = re.compile(r'_expanded\.?\d{0,3}$')
rexpand = re.compile(r'_baked\.?\d{0,3}$')
if rexpand.search(act.name):
# is an autogenerated one
org_action_name = rexpand.sub('', act.name)
@ -246,7 +246,7 @@ def pin_down_feets():
debug = fn.get_addon_prefs().debug
scn = bpy.context.scene
# Delete current action if its not the main one
# create a new '_autogen' one
# create a new '_pinned' one
act = fn.set_generated_action(obj)
if not act:
return ('ERROR', f'No action on {obj.name}')

View File

@ -52,61 +52,4 @@ Bonus:
- align curve to root
- Put curve forward motion on bones modifier's offset value as negative time offset (instead of using curve )
-->
---
## Changelog:
0.7.0
- auto-detect foot to use for path animation
- button to go back and forth between curve edit and armature pose mode
- UI revamp showing better separation of tool categories
0.6.0
- World paste and `Jump next frame`
- more compact and improved ui for world paste
- fix errors in some operators
0.5.0
- pin feet working
0.4.2
- context manager for `expand cycle step` store / restore
0.4.1
- update fcurve after bake
0.4.0
- better curve creation
0.3.5
- partly working
0.3.3
- total wip
0.3.0
- Rework interface
- Add manual bone pinning: simple world space copy/paste + pose and jump prev/next
- Faster pin feets
- bool prop to disable end/curve stepping (interpolation as linear if needed)
- Switch action back to new curve when re-snapping to ground
- fix shrinkwrap
- fix rebake with linear
- error message when no fcurve has anim cycle
0.2.0:
- first working version
0.1.0:
- initial commit, halfway there

View File

@ -4,7 +4,7 @@ bl_info = {
"name": "Unfold Anim Cycle",
"description": "Anim tools to develop walk/run cycles along a curve",
"author": "Samuel Bernou",
"version": (0, 7, 0),
"version": (0, 7, 1),
"blender": (3, 0, 0),
"location": "View3D",
"warning": "WIP",
@ -34,6 +34,7 @@ else:
from . import panels
import bpy
from . import fn
mods = (
properties,
@ -47,12 +48,16 @@ mods = (
panels,
)
def register():
if bpy.app.background:
return
for module in mods:
module.register()
panels.update_panel(fn.get_addon_prefs(), bpy.context)
def unregister():
if bpy.app.background:
return

12
fn.py
View File

@ -107,14 +107,14 @@ def get_obj_action(obj):
return act
def set_generated_action(obj):
'''Backup object action and return a new action suffixed '_autogen'
'''Backup object action and return a new action suffixed '_pinned'
associated with the object
'''
print(helper())
act = get_obj_action(obj)
if not act: return
regen = re.compile(r'_autogen\.?\d{0,3}$')
regen = re.compile(r'_pinned\.?\d{0,3}$')
if regen.search(act.name):
# is an autogenerated one
@ -132,18 +132,18 @@ def set_generated_action(obj):
# backup action before doing anything crazy
act.use_fake_user = True
new_act = act.copy()
new_act.name = act.name + '_autogen'
new_act.name = act.name + '_pinned'
obj.animation_data.action = new_act
return new_act
def set_expanded_action(obj):
def set_baked_action(obj):
'''Backup object action and return a new action
associated with the object
'''
print(helper())
rexpand = re.compile(r'_expanded\.?\d{0,3}$')
rexpand = re.compile(r'_baked\.?\d{0,3}$')
act = obj.animation_data.action
if rexpand.search(act.name):
@ -162,7 +162,7 @@ def set_expanded_action(obj):
# backup action before doing anything crazy
act.use_fake_user = True
new_act = act.copy()
new_act.name = act.name + '_expanded'
new_act.name = act.name + '_baked'
obj.animation_data.action = new_act
return new_act

View File

@ -4,7 +4,7 @@ from . import fn
class UAC_PT_walk_cycle_anim_panel(bpy.types.Panel):
bl_space_type = "VIEW_3D"
bl_region_type = "UI"
bl_category = "Anim"
bl_category = "Walk"
bl_label = "Walk Cycle Anim"
def draw(self, context):
@ -86,12 +86,16 @@ class UAC_PT_walk_cycle_anim_panel(bpy.types.Panel):
# Pin feet
col.operator('anim.pin_feets', text='Pin feets', icon='PINNED')
## show a dropdown allowing to go back to unpinned, unbaked version of the animation
# if ob.type == 'ARMATURE':
# pass
class UAC_PT_anim_tools_panel(bpy.types.Panel):
bl_space_type = "VIEW_3D"
bl_region_type = "UI"
bl_category = "Anim"
bl_category = "Walk"
bl_label = "Tools"
def draw(self, context):
@ -120,12 +124,21 @@ class UAC_PT_anim_tools_panel(bpy.types.Panel):
row.scale_x = 2
classes=(
UAC_PT_walk_cycle_anim_panel,
UAC_PT_anim_tools_panel,
)
## Addons Preferences Update Panel
def update_panel(self, context):
for cls in classes:
try:
bpy.utils.unregister_class(cls)
except:
pass
cls.bl_category = self.category#fn.get_addon_prefs().category
bpy.utils.register_class(cls)
def register():
for cls in classes:
bpy.utils.register_class(cls)

View File

@ -1,10 +1,17 @@
import bpy
from .panels import update_panel
class UAC_addon_prefs(bpy.types.AddonPreferences):
## can be just __name__ if prefs are in the __init__ mainfile
# Else need the splitext '__name__ = addonname.subfile' (or use a static name)
bl_idname = __name__.split('.')[0] # or with: os.path.splitext(__name__)[0]
category : bpy.props.StringProperty(
name="Category",
description="Choose a name for the category of the panel",
default="Walk",
update=update_panel)
# some_bool_prop to display in the addon pref
debug : bpy.props.IntProperty(
name='Debug',
@ -37,6 +44,9 @@ class UAC_addon_prefs(bpy.types.AddonPreferences):
layout = self.layout
layout.use_property_split = True
box = layout.box()
box.prop(self, "category")
box = layout.box()
box.label(text='Curve creation parameters:')
box.prop(self, "tgt_bone")