fix bone interpolation independent to collection set

master
pullusb 2024-01-15 12:35:08 +01:00
parent ad39b3ff5f
commit 1a6da5c4fa
2 changed files with 15 additions and 11 deletions

View File

@ -1,7 +1,7 @@
bl_info = { bl_info = {
"name": "gp interpolate", "name": "gp interpolate",
"author": "Christophe Seux, Samuel Bernou", "author": "Christophe Seux, Samuel Bernou",
"version": (0, 4, 0), "version": (0, 4, 1),
"blender": (3, 6, 0), "blender": (3, 6, 0),
"location": "Sidebar > Gpencil Tab > Interpolate", "location": "Sidebar > Gpencil Tab > Interpolate",
"description": "Interpolate Grease pencil strokes over 3D", "description": "Interpolate Grease pencil strokes over 3D",

View File

@ -86,6 +86,7 @@ class GP_OT_interpolate_stroke(bpy.types.Operator):
included_cols = [c.name for c in gp.users_collection] included_cols = [c.name for c in gp.users_collection]
start = time() start = time()
if settings.method == 'BONE': if settings.method == 'BONE':
## Follow Bone method (WIP) ## Follow Bone method (WIP)
if not settings.target_rig or not settings.target_bone: 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 ## ensure collection and plane exists
# get/create collection # get/create collection
col = bpy.data.collections.get('interpolation_tool') toolcol = bpy.data.collections.get('interpolation_tool')
if not col: if not toolcol:
col = bpy.data.collections.new('interpolation_tool') toolcol = bpy.data.collections.new('interpolation_tool')
if col.name not in bpy.context.scene.collection.children: if toolcol.name not in bpy.context.scene.collection.children:
bpy.context.scene.collection.children.link(col) bpy.context.scene.collection.children.link(toolcol)
col.hide_viewport = True toolcol.hide_viewport = True # needed ?
# get/create meshplane # get/create meshplane
plane = bpy.data.objects.get('interpolation_plane') 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 = create_plane(name='interpolation_plane')
plane.select_set(False) plane.select_set(False)
if plane.name not in col.objects: if plane.name not in toolcol.objects:
col.objects.link(plane) toolcol.objects.link(plane)
## TODO: Ensure the plane is not animated! ## TODO: Ensure the plane is not animated!
else: else:
@ -130,10 +131,13 @@ class GP_OT_interpolate_stroke(bpy.types.Operator):
# TODO : Customize below filter to use in geo mode as well # TODO : Customize below filter to use in geo mode as well
# so it does not exclude collections containing rig # so it does not exclude collections containing rig
if settings.method == 'BONE': 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: for vlc in context.view_layer.layer_collection.children:
store_list.append( store_list.append(
(vlc, 'exclude', vlc.name not in included_cols), # (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 (vlc, 'hide_viewport', vlc.name not in included_cols), # viewport viz
) )
# print(f'Preparation {time()-start:.4f}s') # print(f'Preparation {time()-start:.4f}s')