Brushstroke Tools: Initial Version #328
@ -233,6 +233,7 @@ class BSBST_Settings(bpy.types.PropertyGroup):
|
||||
description="Estimate the length, width and distribution density of the brush strokes based on the bounding box to provide a reasonable starting point regardless of scale")
|
||||
|
||||
silent_switch: bpy.props.BoolProperty(default=False)
|
||||
preview_texture: bpy.props.PointerProperty(type=bpy.types.Texture)
|
||||
|
||||
classes = [
|
||||
BSBST_socket_info,
|
||||
|
@ -212,6 +212,10 @@ def draw_material_settings(layout, material, surface_object=None):
|
||||
brush_header, brush_panel = layout.panel('brush_panel', default_closed = True)
|
||||
brush_header.label(text='Brush Style', icon='BRUSHES_ALL')
|
||||
if brush_panel:
|
||||
if settings.preview_texture:
|
||||
row = brush_panel.row(align=True)
|
||||
row.template_preview(settings.preview_texture, show_buttons=False, preview_id='brushstroke_preview') # TODO: Figure out how to redraw the preview on style change
|
||||
|
||||
row = brush_panel.row(align=True)
|
||||
row.prop_search(material, 'brush_style', addon_prefs, 'brush_styles', text='', icon='BRUSHES_ALL')
|
||||
row.operator('brushstroke_tools.refresh_styles', text='', icon='FILE_REFRESH')
|
||||
|
@ -531,12 +531,24 @@ def round_n(val, n):
|
||||
def set_preview(pixels):
|
||||
if not pixels:
|
||||
return
|
||||
preview_name = '.BSBST-preview'
|
||||
preview_name = 'BSBST-preview'
|
||||
preview_img = bpy.data.images.get(preview_name)
|
||||
if not preview_img:
|
||||
preview_img = bpy.data.images.new(preview_name, width=256, height=256, float_buffer=True, is_data=True)
|
||||
preview_img = bpy.data.images.new(preview_name, width=256, height=256)
|
||||
if not len(preview_img.pixels) == len(pixels):
|
||||
return # TODO handle different sizes
|
||||
|
||||
preview_img.pixels.foreach_set(pixels)
|
||||
preview_texture = bpy.data.textures.get(preview_name)
|
||||
if preview_texture:
|
||||
bpy.data.textures.remove(preview_texture)
|
||||
preview_texture = bpy.data.textures.new(name=preview_name, type="IMAGE")
|
||||
preview_texture.extension = 'EXTEND'
|
||||
preview_texture.image = preview_img
|
||||
|
||||
settings = bpy.context.scene.BSBST_settings
|
||||
settings.preview_texture = preview_texture
|
||||
|
||||
preview_img.pixels.foreach_set(numpy.array(pixels, dtype=numpy.float32))
|
||||
|
||||
def register():
|
||||
bpy.app.handlers.depsgraph_update_post.append(refresh_preset)
|
||||
|
Loading…
Reference in New Issue
Block a user