Animation manager improve animated hint
2.3.1 - changed: Animation manager show icons when animation is enabled: fully, partially or not at all.
This commit is contained in:
@@ -1119,6 +1119,7 @@ def go_edit_mode(ob, context=None):
|
||||
bpy.ops.object.mode_set(mode='EDIT', toggle=False)
|
||||
|
||||
|
||||
## Not used anymore
|
||||
def all_anim_enabled(objects) -> bool:
|
||||
'''return False if at least one fcurve/group has disabled animation in passed object anim'''
|
||||
for o in objects:
|
||||
@@ -1146,6 +1147,7 @@ def all_anim_enabled(objects) -> bool:
|
||||
|
||||
return True
|
||||
|
||||
## Not used anymore
|
||||
def all_object_modifier_enabled(objects) -> bool:
|
||||
'''Return False if one modifier of one object has GP modifier disabled in viewport but enabled in render'''
|
||||
for o in objects:
|
||||
@@ -1158,5 +1160,117 @@ def all_object_modifier_enabled(objects) -> bool:
|
||||
## return False when viewport but no render ?
|
||||
# if not m.show_render and m.show_viewport:
|
||||
# return False
|
||||
return True
|
||||
|
||||
## Only used in anim_status in 'per GP object' mode
|
||||
def has_fully_enabled_anim(o):
|
||||
if o.animation_data and o.animation_data.action:
|
||||
## Skip hided object ? (missmatch)
|
||||
# if o.hide_get():
|
||||
# continue
|
||||
|
||||
## Check if groups are muted
|
||||
for grp in o.animation_data.action.groups:
|
||||
if grp.mute:
|
||||
return False
|
||||
|
||||
## Check if fcurves are muted
|
||||
for fcu in o.animation_data.action.fcurves:
|
||||
if fcu.mute:
|
||||
return False
|
||||
|
||||
if o.type in ('GPENCIL', 'CAMERA'):
|
||||
if o.data.animation_data and o.data.animation_data.action:
|
||||
## Check if object data attributes fcurves are muted
|
||||
for fcu in o.animation_data.action.fcurves:
|
||||
if fcu.mute:
|
||||
return False
|
||||
return True
|
||||
|
||||
def anim_status(objects) -> tuple((str, str)):
|
||||
'''Return a tutple of icon string status in ('ALL_ON', 'MIXED', 'ALL_OFF', 'NONE')'''
|
||||
|
||||
return True
|
||||
on_count = off_count = count = 0
|
||||
|
||||
for o in objects:
|
||||
## Skip object with no animation
|
||||
if not (o.animation_data and o.animation_data.action) and not (o.data.animation_data and o.data.animation_data.action):
|
||||
continue
|
||||
|
||||
## Also skip hidden objects
|
||||
if o.hide_get() and o.hide_render:
|
||||
continue
|
||||
|
||||
### Per Object
|
||||
# count += 1
|
||||
# if has_fully_enabled_anim(o):
|
||||
# on_count += 1
|
||||
# else:
|
||||
# off_count += 1
|
||||
|
||||
### Consider All channels individually
|
||||
for grp in o.animation_data.action.groups:
|
||||
## Check if groups are muted
|
||||
if grp.mute:
|
||||
off_count += 1
|
||||
else:
|
||||
on_count += 1
|
||||
count += 1
|
||||
|
||||
|
||||
for fcu in o.animation_data.action.fcurves:
|
||||
## Check if fcurves are muted
|
||||
if fcu.mute:
|
||||
off_count += 1
|
||||
else:
|
||||
on_count += 1
|
||||
count += 1
|
||||
|
||||
if o.type in ('GPENCIL', 'CAMERA'):
|
||||
if o.data.animation_data and o.data.animation_data.action:
|
||||
## Check if object data attributes fcurves are muted
|
||||
for fcu in o.animation_data.action.fcurves:
|
||||
if fcu.mute:
|
||||
off_count += 1
|
||||
else:
|
||||
on_count += 1
|
||||
count += 1
|
||||
|
||||
if not on_count and not off_count:
|
||||
return ('BLANK1', 'BLANK1') # 'NONE'
|
||||
elif on_count == count:
|
||||
return ('LAYER_ACTIVE', 'BLANK1') # 'ALL_ON'
|
||||
elif off_count == count:
|
||||
return ('BLANK1', 'LAYER_ACTIVE') # 'ALL_OFF'
|
||||
else:
|
||||
return ('LAYER_USED', 'LAYER_USED') # 'MIXED'
|
||||
|
||||
|
||||
def gp_modifier_status(objects) -> tuple((str, str)):
|
||||
'''return icons on/off tuple'''
|
||||
on_count = off_count = count = 0
|
||||
for o in objects:
|
||||
if o.type != 'GPENCIL':
|
||||
continue
|
||||
## Skip hided object
|
||||
if o.hide_get() and o.hide_render:
|
||||
continue
|
||||
for m in o.grease_pencil_modifiers:
|
||||
if m.show_render and not m.show_viewport:
|
||||
off_count += 1
|
||||
else:
|
||||
on_count += 1
|
||||
count += 1
|
||||
|
||||
## return False when viewport but no render ?
|
||||
# if not m.show_render and m.show_viewport:
|
||||
# return False
|
||||
|
||||
if not on_count and not off_count:
|
||||
return ('BLANK1', 'BLANK1') # 'NONE'
|
||||
elif on_count == count:
|
||||
return ('LAYER_ACTIVE', 'BLANK1') # 'ALL_ON'
|
||||
elif off_count == count:
|
||||
return ('BLANK1', 'LAYER_ACTIVE') # 'ALL_OFF'
|
||||
else:
|
||||
return ('LAYER_USED', 'LAYER_USED')
|
||||
Reference in New Issue
Block a user