Brushstroke Tools: Initial Version #328

Merged
Simon Thommes merged 229 commits from SimonThommes/blender-studio-tools:brushstroke_tools-initial-version into main 2024-11-06 15:03:47 +01:00
Showing only changes of commit a5cf5bc12a - Show all commits

View File

@ -346,20 +346,51 @@ class BSBST_OT_copy_brushstrokes(bpy.types.Operator):
bpy.ops.object.mode_set(mode='OBJECT')
for surface_object in surface_objects:
for ob in bpy.data.objects:
ob.select_set(False)
for bs_ob in bs_objects:
flow_object = utils.get_flow_object(bs_ob)
bpy.context.view_layer.objects.active = bs_ob
for ob in bpy.data.objects:
ob.select_set(False)
bs_ob.select_set(True)
flow_object.select_set(True)
bpy.ops.object.duplicate_move()
# remap surface pointers and context linked data
bs_ob.parent = surface_object
utils.set_surface_object(bs_ob, surface_object)
# TODO
all_obj = set(bpy.data.objects[:])
context.view_layer.depsgraph.update()
bpy.ops.object.duplicate_move()
new_bs = list(set(bpy.data.objects[:]) - all_obj)
del all_obj
# remap surface pointers and context linked data
for ob in new_bs:
ob.parent = surface_object
utils.set_surface_object(ob, surface_object)
for mod in ob.modifiers:
if not mod.type:
continue
if not mod.node_group:
continue
mod_info = ob.modifier_info.get(mod.name)
if not mod_info:
continue
for v in mod.node_group.interface.items_tree.values():
if type(v) not in utils.linkable_sockets:
continue
if not mod_info.socket_info[v.identifier].link_context:
continue
# re-initialize linked context parameters
link_context_type = settings.preset_object.modifier_info[mod.name].socket_info[v.identifier].link_context_type
if link_context_type=='SURFACE_OBJECT':
ob.modifiers[mod.name][f'{v.identifier}'] = surface_object
elif link_context_type=='UVMAP':
ob.modifiers[mod.name][f'{v.identifier}_use_attribute'] = True
ob.modifiers[mod.name][f'{v.identifier}_attribute_name'] = surface_object.data.uv_layers.active.name
elif link_context_type=='RANDOM':
vmin = v.min_value
vmax = v.max_value
val = vmin + random.random() * (vmax - vmin)
ob.modifiers[mod.name][f'{v.identifier}_use_attribute'] = False
ob.modifiers[mod.name][f'{v.identifier}'] = type(ob.modifiers[mod.name][f'{v.identifier}'])(val)
# enable rest position
surface_object.add_rest_position_attribute = True