Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 30 additions & 30 deletions Blender/coa_tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,12 +201,14 @@ def update_sprites(dummy):
update_scene = False

context = bpy.context
objects = []

## fix to work with linked group. Objects inside a linked group is not the context.visible_objects list.
objects = [x for x in bpy.data.objects if x.is_visible(context.scene)]

if hasattr(context,"visible_objects"):
objects = context.visible_objects
else:
objects = bpy.data.objects
# if hasattr(context,"visible_objects"):
# objects = context.visible_objects
# else:
# objects = bpy.data.objects

alpha_update_frequency = get_addon_prefs(context).alpha_update_frequency
for obj in objects:
Expand Down Expand Up @@ -235,11 +237,12 @@ def update_sprites(dummy):

if update_scene:
bpy.context.scene.update()

### animation wrap mode
if hasattr(context,"active_object"):
sprite_object = get_sprite_object(context.active_object)
if sprite_object != None and sprite_object.coa_animation_loop:
print("active")
if context.scene.frame_current > context.scene.frame_end:
context.scene.frame_current = context.scene.frame_start
if context.scene.frame_current == context.scene.coa_frame_last and context.scene.frame_current == context.scene.frame_start:
Expand All @@ -253,33 +256,30 @@ def scene_update(dummy):
global ticker
ticker += 1
context = bpy.context
if hasattr(context,"visible_objects"):
objects = context.visible_objects
else:
objects = bpy.data.objects

if hasattr(context,"window_manager"):
wm = bpy.context.window_manager
if wm.coa_update_uv:
for obj in objects:
if "coa_sprite" in obj and obj.animation_data != None and obj.type == "MESH":
if obj.coa_sprite_frame != obj.coa_sprite_frame_last:
update_uv(bpy.context,obj)
obj.coa_sprite_frame_last = obj.coa_sprite_frame
if obj.coa_slot_index != obj.coa_slot_index_last:
change_slot_mesh_data(context,obj)
obj.coa_slot_index_last = obj.coa_slot_index
if obj.coa_z_value != obj.coa_z_value_last:
set_z_value(context,obj,obj.coa_z_value)
obj.coa_z_value_last = obj.coa_z_value
if ticker%5 == 0:
if obj.coa_alpha != obj.coa_alpha_last:
set_alpha(obj,bpy.context,obj.coa_alpha)
obj.coa_alpha_last = obj.coa_alpha
actOb = context.active_object
# change to update only when a coa armature is moved. Handy for driver update. This function seemed to be deprecated

if actOb.type == 'ARMATURE' and 'coa_hide' in actOb:
for obj in [x for x in bpy.data.objects if x.is_visible(context.scene)]:
if "coa_slot" in obj:
# if obj.coa_sprite_frame != obj.coa_sprite_frame_last:
# update_uv(bpy.context,obj)
# obj.coa_sprite_frame_last = obj.coa_sprite_frame
if obj.coa_slot_index != obj.coa_slot_index_last:
change_slot_mesh_data(context,obj)
obj.coa_slot_index_last = obj.coa_slot_index
if obj.coa_z_value != obj.coa_z_value_last:
set_z_value(context,obj,obj.coa_z_value)
obj.coa_z_value_last = obj.coa_z_value
# if ticker%5 == 0:
# if obj.coa_alpha != obj.coa_alpha_last:
# set_alpha(obj,bpy.context,obj.coa_alpha)
# obj.coa_alpha_last = obj.coa_alpha

if hasattr(bpy.context,"active_object"):
obj = bpy.context.active_object
if obj != None and not obj.coa_sprite_updated and "coa_sprite" in obj:
print(obj)
for thumb in preview_collections["coa_thumbs"]:
preview_collections["coa_thumbs"][thumb].reload()
obj.coa_sprite_updated = True
Expand Down Expand Up @@ -339,4 +339,4 @@ def delete_thumb_previews():
thumb_dir_path = os.path.join(tempfile.gettempdir(),"coa_thumbs")
if os.path.exists(thumb_dir_path):
shutil.rmtree(thumb_dir_path, ignore_errors=True)
atexit.register(delete_thumb_previews)
atexit.register(delete_thumb_previews)