From 1a6da5c4fa731e4f5f5609df483019263a3a2eab Mon Sep 17 00:00:00 2001 From: pullusb Date: Mon, 15 Jan 2024 12:35:08 +0100 Subject: [PATCH] fix bone interpolation independent to collection set --- __init__.py | 2 +- interpolate_strokes/operators.py | 24 ++++++++++++++---------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/__init__.py b/__init__.py index fa5e12f..628f48a 100755 --- a/__init__.py +++ b/__init__.py @@ -1,7 +1,7 @@ bl_info = { "name": "gp interpolate", "author": "Christophe Seux, Samuel Bernou", - "version": (0, 4, 0), + "version": (0, 4, 1), "blender": (3, 6, 0), "location": "Sidebar > Gpencil Tab > Interpolate", "description": "Interpolate Grease pencil strokes over 3D", diff --git a/interpolate_strokes/operators.py b/interpolate_strokes/operators.py index 89bac60..7bacace 100644 --- a/interpolate_strokes/operators.py +++ b/interpolate_strokes/operators.py @@ -86,6 +86,7 @@ class GP_OT_interpolate_stroke(bpy.types.Operator): included_cols = [c.name for c in gp.users_collection] start = time() + if settings.method == 'BONE': ## Follow Bone method (WIP) if not settings.target_rig or not settings.target_bone: @@ -96,13 +97,13 @@ class GP_OT_interpolate_stroke(bpy.types.Operator): ## ensure collection and plane exists # get/create collection - col = bpy.data.collections.get('interpolation_tool') - if not col: - col = bpy.data.collections.new('interpolation_tool') + toolcol = bpy.data.collections.get('interpolation_tool') + if not toolcol: + toolcol = bpy.data.collections.new('interpolation_tool') - if col.name not in bpy.context.scene.collection.children: - bpy.context.scene.collection.children.link(col) - col.hide_viewport = True + if toolcol.name not in bpy.context.scene.collection.children: + bpy.context.scene.collection.children.link(toolcol) + toolcol.hide_viewport = True # needed ? # get/create meshplane plane = bpy.data.objects.get('interpolation_plane') @@ -110,8 +111,8 @@ class GP_OT_interpolate_stroke(bpy.types.Operator): plane = create_plane(name='interpolation_plane') plane.select_set(False) - if plane.name not in col.objects: - col.objects.link(plane) + if plane.name not in toolcol.objects: + toolcol.objects.link(plane) ## TODO: Ensure the plane is not animated! else: @@ -130,10 +131,13 @@ class GP_OT_interpolate_stroke(bpy.types.Operator): # TODO : Customize below filter to use in geo mode as well # so it does not exclude collections containing rig if settings.method == 'BONE': + ## TEST: Add collections containing rig (cannot be excluded) + # rig_parent_cols = [c.name for c in scn.collection.children_recursive if settings.target_rig.name in c.all_objects] + # included_cols += rig_parent_cols for vlc in context.view_layer.layer_collection.children: store_list.append( - (vlc, 'exclude', vlc.name not in included_cols), - # (vlc, 'hide_viewport', vlc.name not in included_cols), # viewport viz + # (vlc, 'exclude', vlc.name not in included_cols), # If excluded rig does not update ! + (vlc, 'hide_viewport', vlc.name not in included_cols), # viewport viz ) # print(f'Preparation {time()-start:.4f}s')