Brushstroke Tools: Initial Version #328
@ -1,4 +1,5 @@
|
||||
import bpy
|
||||
import random
|
||||
from . import utils
|
||||
|
||||
class BSBST_OT_new_brushstrokes(bpy.types.Operator):
|
||||
@ -118,7 +119,15 @@ class BSBST_OT_new_brushstrokes(bpy.types.Operator):
|
||||
elif link_context_type=='MATERIAL':
|
||||
brushstrokes_object.modifiers[mod.name][f'{v.identifier}'] = settings.preset_material
|
||||
elif link_context_type=='UVMAP':
|
||||
brushstrokes_object.modifiers[mod.name][f'{v.identifier}_use_attribute'] = True
|
||||
brushstrokes_object.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)
|
||||
brushstrokes_object.modifiers[mod.name][f'{v.identifier}_use_attribute'] = False
|
||||
brushstrokes_object.modifiers[mod.name][f'{v.identifier}'] = type(brushstrokes_object.modifiers[mod.name][f'{v.identifier}'])(val)
|
||||
|
||||
# refresh UI
|
||||
for mod in brushstrokes_object.modifiers:
|
||||
mod.node_group.interface_update(context)
|
||||
@ -213,6 +222,7 @@ class BSBST_OT_init_preset(bpy.types.Operator):
|
||||
|
||||
utils.mark_socket_context_type(mod_info, 'Socket_2', 'FLOW_OBJECT')
|
||||
utils.mark_socket_context_type(mod_info, 'Socket_3', 'UVMAP')
|
||||
utils.mark_socket_context_type(mod_info, 'Socket_9', 'RANDOM')
|
||||
|
||||
def init_draw(self, context):
|
||||
settings = context.scene.BSBST_settings
|
||||
@ -241,6 +251,7 @@ class BSBST_OT_init_preset(bpy.types.Operator):
|
||||
mod_info.name = mod.name
|
||||
|
||||
utils.mark_socket_context_type(mod_info, 'Socket_2', 'SURFACE_OBJECT')
|
||||
utils.mark_socket_context_type(mod_info, 'Socket_6', 'RANDOM')
|
||||
|
||||
def execute(self, context):
|
||||
|
||||
|
@ -103,7 +103,7 @@ def link_context_type_items(self, context):
|
||||
('FLOW_OBJECT', 'Flow Object', 'Link socket preset to context flow object', 'FORCE_WIND', 11),
|
||||
('MATERIAL', 'Material', 'Link socket preset to context material', 'MATERIAL', 101),
|
||||
('UVMAP', 'UV Map', 'Link socket preset to active context UVMap', 'UV', 201),
|
||||
('RANDOM', 'Random', '', icons.icon_previews['main']["RANDOM"].icon_id, 501),
|
||||
('RANDOM', 'Random', 'Randomize input value', icons.icon_previews['main']["RANDOM"].icon_id, 501),
|
||||
]
|
||||
return items
|
||||
|
||||
|
@ -53,7 +53,7 @@ def draw_panel_ui_recursive(panel, panel_name, mod, items):
|
||||
input_row.prop(mod, f'["{v.identifier}"]', text=k)
|
||||
if not mod_info:
|
||||
continue
|
||||
if type(v) in utils.linkable_sockets and (attribute_toggle or f'{v.identifier}_use_attribute' not in mod.keys()):
|
||||
if type(v) in utils.linkable_sockets:
|
||||
s = mod_info.socket_info.get(v.identifier)
|
||||
if not s:
|
||||
continue
|
||||
|
@ -13,7 +13,9 @@ ng_list = [
|
||||
linkable_sockets = [
|
||||
bpy.types.NodeTreeInterfaceSocketObject,
|
||||
bpy.types.NodeTreeInterfaceSocketMaterial,
|
||||
bpy.types.NodeTreeInterfaceSocketVector
|
||||
bpy.types.NodeTreeInterfaceSocketVector,
|
||||
bpy.types.NodeTreeInterfaceSocketFloat,
|
||||
bpy.types.NodeTreeInterfaceSocketInt,
|
||||
]
|
||||
|
||||
@persistent
|
||||
|
Loading…
Reference in New Issue
Block a user