From 4a522d353a585e6986ac7c98c1d0decadc7db916 Mon Sep 17 00:00:00 2001 From: Pablo Vazquez Date: Sun, 24 Jul 2022 04:26:46 +0200 Subject: Amaranth: Fix Debug feature to list users of image datablocks The code was looking for background images in the 3D Viewport, which have been moved to Camera objects in 2.8. Fixes T98252 --- amaranth/scene/debug.py | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) (limited to 'amaranth/scene/debug.py') diff --git a/amaranth/scene/debug.py b/amaranth/scene/debug.py index 38692743..a73d688e 100755 --- a/amaranth/scene/debug.py +++ b/amaranth/scene/debug.py @@ -65,7 +65,7 @@ class AMTH_store_data(): 'TEXTURE': [], # Textures (Psys, Brushes) 'MODIFIER': [], # Modifiers 'MESH_DATA': [], # Vertex Colors - 'VIEW3D': [], # Background Images + 'OUTLINER_OB_CAMERA': [], # Background Images 'NODETREE': [], # Compositor } libraries = [] # Libraries x type @@ -632,6 +632,7 @@ class AMTH_SCENE_OT_list_users_for_x(Operator): if name not in AMTH_store_data.users['MATERIAL']: AMTH_store_data.users['MATERIAL'].append(name) + # Check Lights for la in d.lights: # Cycles @@ -643,6 +644,7 @@ class AMTH_SCENE_OT_list_users_for_x(Operator): no.image and no.image.name == x: if la.name not in AMTH_store_data.users['LIGHT']: AMTH_store_data.users['LIGHT'].append(la.name) + # Check World for wo in d.worlds: # Cycles @@ -654,6 +656,7 @@ class AMTH_SCENE_OT_list_users_for_x(Operator): no.image and no.image.name == x: if wo.name not in AMTH_store_data.users['WORLD']: AMTH_store_data.users['WORLD'].append(wo.name) + # Check Textures for te in d.textures: if te and te.type == 'IMAGE' and te.image: @@ -662,6 +665,7 @@ class AMTH_SCENE_OT_list_users_for_x(Operator): if name == x and \ name not in AMTH_store_data.users['TEXTURE']: AMTH_store_data.users['TEXTURE'].append(te.name) + # Check Modifiers in Objects for ob in d.objects: for mo in ob.modifiers: @@ -672,21 +676,19 @@ class AMTH_SCENE_OT_list_users_for_x(Operator): name = '"{0}" modifier in {1}'.format(mo.name, ob.name) if name not in AMTH_store_data.users['MODIFIER']: AMTH_store_data.users['MODIFIER'].append(name) - # Check Background Images in Viewports - for scr in d.screens: - for ar in scr.areas: - if ar.type == 'VIEW_3D': - if ar.spaces and \ - ar.spaces.active and \ - ar.spaces.active.background_images: - for bg in ar.spaces.active.background_images: - image = bg.image - - if bg and image and image.name == x: - name = 'Background for 3D Viewport in Screen "{0}"'\ - .format(scr.name) - if name not in AMTH_store_data.users['VIEW3D']: - AMTH_store_data.users['VIEW3D'].append(name) + + # Check Background Images in Cameras + for ob in d.objects: + if ob and ob.type == 'CAMERA' and ob.data.background_images: + for bg in ob.data.background_images: + image = bg.image + + if bg and image and image.name == x: + name = 'Used as background for Camera "{0}"'\ + .format(ob.name) + if name not in AMTH_store_data.users['OUTLINER_OB_CAMERA']: + AMTH_store_data.users['OUTLINER_OB_CAMERA'].append(name) + # Check the Compositor for sce in d.scenes: if sce.node_tree and sce.node_tree.nodes: -- cgit v1.2.3 From 8d609fc7e68def4f9c43bada22d930d4b257c7e6 Mon Sep 17 00:00:00 2001 From: Pablo Vazquez Date: Sun, 24 Jul 2022 04:35:54 +0200 Subject: Amaranth: support listing images used by Empty objects in Debug tool Related to T98252 --- amaranth/scene/debug.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'amaranth/scene/debug.py') diff --git a/amaranth/scene/debug.py b/amaranth/scene/debug.py index a73d688e..4f702d08 100755 --- a/amaranth/scene/debug.py +++ b/amaranth/scene/debug.py @@ -65,7 +65,8 @@ class AMTH_store_data(): 'TEXTURE': [], # Textures (Psys, Brushes) 'MODIFIER': [], # Modifiers 'MESH_DATA': [], # Vertex Colors - 'OUTLINER_OB_CAMERA': [], # Background Images + 'OUTLINER_OB_CAMERA': [], # Background Images in Cameras + 'OUTLINER_OB_EMPTY': [], # Empty type Image 'NODETREE': [], # Compositor } libraries = [] # Libraries x type @@ -689,6 +690,18 @@ class AMTH_SCENE_OT_list_users_for_x(Operator): if name not in AMTH_store_data.users['OUTLINER_OB_CAMERA']: AMTH_store_data.users['OUTLINER_OB_CAMERA'].append(name) + # Check Empties type Image + for ob in d.objects: + if ob and ob.type == 'EMPTY' and ob.image_user: + if ob.image_user.id_data.data: + image = ob.image_user.id_data.data + + if image and image.name == x: + name = 'Used in Empty "{0}"'\ + .format(ob.name) + if name not in AMTH_store_data.users['OUTLINER_OB_EMPTY']: + AMTH_store_data.users['OUTLINER_OB_EMPTY'].append(name) + # Check the Compositor for sce in d.scenes: if sce.node_tree and sce.node_tree.nodes: -- cgit v1.2.3