Brushstroke Tools: Initial Version #328
@ -134,8 +134,10 @@ def set_brush_style(self, value):
|
||||
ng_name = f'BSBST-BS.{value}'
|
||||
ng = utils.ensure_node_group(ng_name, [bs for bs in addon_prefs.brush_styles if bs.name==value][0].filepath)
|
||||
|
||||
# if ng.preview:
|
||||
# utils.set_preview(ng.preview.image_pixels_float, ng.preview.image_size[:])
|
||||
if ng.preview:
|
||||
utils.set_preview(ng.preview.image_pixels_float, ng.preview.image_size[:])
|
||||
else:
|
||||
utils.set_preview(None)
|
||||
|
||||
node = self.node_tree.nodes['Brush Style']
|
||||
node_prev_inputs = [input.name for input in node.inputs]
|
||||
|
@ -214,8 +214,7 @@ def draw_material_settings(layout, material, surface_object=None):
|
||||
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
|
||||
brush_panel.prop(settings.preview_texture, 'use_flip_axis')
|
||||
row.template_preview(settings.preview_texture, show_buttons=False, preview_id='brushstroke_preview')
|
||||
|
||||
row = brush_panel.row(align=True)
|
||||
row.prop_search(material, 'brush_style', addon_prefs, 'brush_styles', text='', icon='BRUSHES_ALL')
|
||||
|
@ -586,18 +586,22 @@ def round_n(val, n):
|
||||
return round(val, n-int(math.floor(math.log10(abs(val))))-1)
|
||||
|
||||
def set_preview(pixels, size = (256, 256)):
|
||||
if not pixels:
|
||||
return
|
||||
preview_name = 'BSBST-preview'
|
||||
preview_name = '.BSBST-preview'
|
||||
preview_img = bpy.data.images.get(preview_name)
|
||||
preview_texture = bpy.data.textures.get(preview_name)
|
||||
if not pixels:
|
||||
if preview_img:
|
||||
bpy.data.images.remove(preview_img)
|
||||
if preview_texture:
|
||||
bpy.data.textures.remove(preview_texture)
|
||||
return
|
||||
if preview_img:
|
||||
if not len(preview_img.pixels) == len(pixels):
|
||||
bpy.data.images.remove(preview_img)
|
||||
preview_img = None
|
||||
if not preview_img:
|
||||
preview_img = bpy.data.images.new(preview_name, width=size[0], height=size[1])
|
||||
|
||||
preview_texture = bpy.data.textures.get(preview_name)
|
||||
|
||||
if not preview_texture:
|
||||
preview_texture = bpy.data.textures.new(name=preview_name, type="IMAGE")
|
||||
settings = bpy.context.scene.BSBST_settings
|
||||
|
Loading…
Reference in New Issue
Block a user