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 = {
"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",

View File

@ -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')