2012-01-18 05:54:19 +00:00
|
|
|
# ##### BEGIN GPL LICENSE BLOCK #####
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU General Public License
|
|
|
|
# as published by the Free Software Foundation; either version 2
|
|
|
|
# of the License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software Foundation,
|
|
|
|
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
#
|
|
|
|
# ##### END GPL LICENSE BLOCK #####
|
|
|
|
|
|
|
|
# <pep8 compliant>
|
2014-08-28 14:40:38 +00:00
|
|
|
from bpy.types import Menu
|
2012-01-18 05:54:19 +00:00
|
|
|
|
|
|
|
|
|
|
|
class UnifiedPaintPanel():
|
|
|
|
# subclass must set
|
|
|
|
# bl_space_type = 'IMAGE_EDITOR'
|
|
|
|
# bl_region_type = 'UI'
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def paint_settings(context):
|
|
|
|
toolsettings = context.tool_settings
|
|
|
|
|
|
|
|
if context.sculpt_object:
|
|
|
|
return toolsettings.sculpt
|
|
|
|
elif context.vertex_paint_object:
|
|
|
|
return toolsettings.vertex_paint
|
|
|
|
elif context.weight_paint_object:
|
|
|
|
return toolsettings.weight_paint
|
|
|
|
elif context.image_paint_object:
|
2014-10-06 13:12:06 +00:00
|
|
|
if (toolsettings.image_paint and toolsettings.image_paint.detect_data()):
|
|
|
|
return toolsettings.image_paint
|
|
|
|
|
|
|
|
return None
|
2012-01-18 05:54:19 +00:00
|
|
|
elif context.particle_edit_object:
|
|
|
|
return toolsettings.particle_edit
|
|
|
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def unified_paint_settings(parent, context):
|
|
|
|
ups = context.tool_settings.unified_paint_settings
|
|
|
|
parent.label(text="Unified Settings:")
|
2013-09-05 13:15:29 +00:00
|
|
|
row = parent.row()
|
|
|
|
row.prop(ups, "use_unified_size", text="Size")
|
|
|
|
row.prop(ups, "use_unified_strength", text="Strength")
|
2012-04-29 20:04:25 +00:00
|
|
|
if context.weight_paint_object:
|
|
|
|
parent.prop(ups, "use_unified_weight", text="Weight")
|
2014-07-21 10:02:05 +00:00
|
|
|
elif context.vertex_paint_object or context.image_paint_object:
|
|
|
|
parent.prop(ups, "use_unified_color", text="Color")
|
|
|
|
else:
|
|
|
|
parent.prop(ups, "use_unified_color", text="Color")
|
2012-01-18 05:54:19 +00:00
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def prop_unified_size(parent, context, brush, prop_name, icon='NONE', text="", slider=False):
|
|
|
|
ups = context.tool_settings.unified_paint_settings
|
|
|
|
ptr = ups if ups.use_unified_size else brush
|
|
|
|
parent.prop(ptr, prop_name, icon=icon, text=text, slider=slider)
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def prop_unified_strength(parent, context, brush, prop_name, icon='NONE', text="", slider=False):
|
|
|
|
ups = context.tool_settings.unified_paint_settings
|
|
|
|
ptr = ups if ups.use_unified_strength else brush
|
|
|
|
parent.prop(ptr, prop_name, icon=icon, text=text, slider=slider)
|
2012-04-29 20:04:25 +00:00
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def prop_unified_weight(parent, context, brush, prop_name, icon='NONE', text="", slider=False):
|
|
|
|
ups = context.tool_settings.unified_paint_settings
|
|
|
|
ptr = ups if ups.use_unified_weight else brush
|
|
|
|
parent.prop(ptr, prop_name, icon=icon, text=text, slider=slider)
|
2012-05-15 04:50:47 +00:00
|
|
|
|
2014-07-21 10:02:05 +00:00
|
|
|
@staticmethod
|
|
|
|
def prop_unified_color(parent, context, brush, prop_name, text=""):
|
|
|
|
ups = context.tool_settings.unified_paint_settings
|
|
|
|
ptr = ups if ups.use_unified_color else brush
|
|
|
|
parent.prop(ptr, prop_name, text=text)
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def prop_unified_color_picker(parent, context, brush, prop_name, value_slider=True):
|
|
|
|
ups = context.tool_settings.unified_paint_settings
|
|
|
|
ptr = ups if ups.use_unified_color else brush
|
|
|
|
parent.template_color_picker(ptr, prop_name, value_slider=value_slider)
|
|
|
|
|
|
|
|
|
2014-08-28 14:40:38 +00:00
|
|
|
class VIEW3D_MT_tools_projectpaint_clone(Menu):
|
|
|
|
bl_label = "Clone Layer"
|
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
|
|
|
|
|
|
|
for i, tex in enumerate(context.active_object.data.uv_textures):
|
|
|
|
props = layout.operator("wm.context_set_int", text=tex.name, translate=False)
|
|
|
|
props.data_path = "active_object.data.uv_texture_clone_index"
|
|
|
|
props.value = i
|
|
|
|
|
|
|
|
|
2014-07-21 17:24:03 +00:00
|
|
|
def brush_texpaint_common(panel, context, layout, brush, settings, projpaint=False):
|
2014-07-21 10:02:05 +00:00
|
|
|
capabilities = brush.image_paint_capabilities
|
|
|
|
|
|
|
|
col = layout.column()
|
|
|
|
|
|
|
|
if brush.image_tool in {'DRAW', 'FILL'}:
|
|
|
|
if brush.blend not in {'ERASE_ALPHA', 'ADD_ALPHA'}:
|
|
|
|
if not brush.use_gradient:
|
|
|
|
panel.prop_unified_color_picker(col, context, brush, "color", value_slider=True)
|
|
|
|
|
|
|
|
if settings.palette:
|
|
|
|
col.template_palette(settings, "palette", color=True)
|
|
|
|
|
|
|
|
if brush.use_gradient:
|
|
|
|
col.label("Gradient Colors")
|
|
|
|
col.template_color_ramp(brush, "gradient", expand=True)
|
|
|
|
|
|
|
|
if brush.image_tool != 'FILL':
|
|
|
|
col.label("Background Color")
|
|
|
|
row = col.row(align=True)
|
|
|
|
panel.prop_unified_color(row, context, brush, "secondary_color", text="")
|
|
|
|
|
|
|
|
if brush.image_tool == 'DRAW':
|
|
|
|
col.prop(brush, "gradient_stroke_mode", text="Mode")
|
|
|
|
if brush.gradient_stroke_mode in {'SPACING_REPEAT', 'SPACING_CLAMP'}:
|
|
|
|
col.prop(brush, "grad_spacing")
|
|
|
|
elif brush.image_tool == 'FILL':
|
|
|
|
col.prop(brush, "gradient_fill_mode")
|
|
|
|
else:
|
|
|
|
row = col.row(align=True)
|
|
|
|
panel.prop_unified_color(row, context, brush, "color", text="")
|
|
|
|
if brush.image_tool == 'FILL':
|
|
|
|
col.prop(brush, "fill_threshold")
|
|
|
|
else:
|
|
|
|
panel.prop_unified_color(row, context, brush, "secondary_color", text="")
|
|
|
|
row.separator()
|
|
|
|
row.operator("paint.brush_colors_flip", icon='FILE_REFRESH', text="")
|
|
|
|
|
|
|
|
elif brush.image_tool == 'SOFTEN':
|
|
|
|
col = layout.column(align=True)
|
|
|
|
col.row().prop(brush, "direction", expand=True)
|
|
|
|
col.separator()
|
|
|
|
col.prop(brush, "sharp_threshold")
|
2014-08-27 13:07:57 +00:00
|
|
|
if not projpaint:
|
|
|
|
col.prop(brush, "blur_kernel_radius")
|
2014-07-21 10:02:05 +00:00
|
|
|
col.separator()
|
|
|
|
col.prop(brush, "blur_mode")
|
|
|
|
elif brush.image_tool == 'MASK':
|
|
|
|
col.prop(brush, "weight", text="Mask Value", slider=True)
|
|
|
|
|
|
|
|
elif brush.image_tool == 'CLONE':
|
|
|
|
col.separator()
|
2014-07-21 17:24:03 +00:00
|
|
|
if projpaint:
|
2014-08-28 14:40:38 +00:00
|
|
|
if settings.mode == 'MATERIAL':
|
|
|
|
col.prop(settings, "use_clone_layer", text="Clone from paint slot")
|
|
|
|
elif settings.mode == 'IMAGE':
|
|
|
|
col.prop(settings, "use_clone_layer", text="Clone from image/UV map")
|
2014-07-21 17:24:03 +00:00
|
|
|
|
|
|
|
if settings.use_clone_layer:
|
|
|
|
ob = context.active_object
|
|
|
|
col = layout.column()
|
|
|
|
|
2014-08-28 14:40:38 +00:00
|
|
|
if settings.mode == 'MATERIAL':
|
|
|
|
if len(ob.material_slots) > 1:
|
|
|
|
col.label("Materials")
|
|
|
|
col.template_list("MATERIAL_UL_matslots", "",
|
|
|
|
ob, "material_slots",
|
|
|
|
ob, "active_material_index", rows=2)
|
|
|
|
|
|
|
|
mat = ob.active_material
|
|
|
|
if mat:
|
2014-09-22 09:01:50 +00:00
|
|
|
col.label("Source Clone Slot")
|
2014-08-28 14:40:38 +00:00
|
|
|
col.template_list("TEXTURE_UL_texpaintslots", "",
|
|
|
|
mat, "texture_paint_images",
|
|
|
|
mat, "paint_clone_slot", rows=2)
|
|
|
|
|
|
|
|
elif settings.mode == 'IMAGE':
|
|
|
|
mesh = ob.data
|
|
|
|
|
|
|
|
clone_text = mesh.uv_texture_clone.name if mesh.uv_texture_clone else ""
|
2014-09-22 09:01:50 +00:00
|
|
|
col.label("Source Clone Image")
|
2014-08-28 14:40:38 +00:00
|
|
|
col.template_ID(settings, "clone_image")
|
2014-09-22 09:01:50 +00:00
|
|
|
col.label("Source Clone UV Map")
|
2014-08-28 14:40:38 +00:00
|
|
|
col.menu("VIEW3D_MT_tools_projectpaint_clone", text=clone_text, translate=False)
|
2014-07-21 17:24:03 +00:00
|
|
|
else:
|
|
|
|
col.prop(brush, "clone_image", text="Image")
|
|
|
|
col.prop(brush, "clone_alpha", text="Alpha")
|
|
|
|
|
2014-07-21 10:02:05 +00:00
|
|
|
col.separator()
|
|
|
|
|
|
|
|
if capabilities.has_radius:
|
|
|
|
row = col.row(align=True)
|
|
|
|
panel.prop_unified_size(row, context, brush, "size", slider=True, text="Radius")
|
|
|
|
panel.prop_unified_size(row, context, brush, "use_pressure_size")
|
|
|
|
|
2014-07-23 14:05:35 +00:00
|
|
|
row = col.row(align=True)
|
2014-07-21 10:02:05 +00:00
|
|
|
|
|
|
|
if capabilities.has_space_attenuation:
|
|
|
|
row.prop(brush, "use_space_attenuation", toggle=True, icon_only=True)
|
|
|
|
|
|
|
|
panel.prop_unified_strength(row, context, brush, "strength", text="Strength")
|
|
|
|
panel.prop_unified_strength(row, context, brush, "use_pressure_strength")
|
|
|
|
|
|
|
|
if brush.image_tool in {'DRAW', 'FILL'}:
|
|
|
|
col.separator()
|
|
|
|
col.prop(brush, "blend", text="Blend")
|
|
|
|
|
|
|
|
col = layout.column()
|
|
|
|
|
|
|
|
# use_accumulate
|
|
|
|
if capabilities.has_accumulate:
|
|
|
|
col = layout.column(align=True)
|
|
|
|
col.prop(brush, "use_accumulate")
|
|
|
|
|
|
|
|
col.prop(brush, "use_alpha")
|
|
|
|
col.prop(brush, "use_gradient")
|
|
|
|
|
|
|
|
col.separator()
|
|
|
|
col.template_ID(settings, "palette", new="palette.new")
|
|
|
|
|
2012-05-15 04:50:47 +00:00
|
|
|
|
|
|
|
# Used in both the View3D toolbar and texture properties
|
2013-01-16 12:57:35 +00:00
|
|
|
def brush_texture_settings(layout, brush, sculpt):
|
2012-05-15 04:50:47 +00:00
|
|
|
tex_slot = brush.texture_slot
|
|
|
|
|
|
|
|
layout.label(text="Brush Mapping:")
|
|
|
|
|
|
|
|
# map_mode
|
2013-01-16 12:57:35 +00:00
|
|
|
if sculpt:
|
|
|
|
layout.row().prop(tex_slot, "map_mode", text="")
|
|
|
|
layout.separator()
|
2012-05-15 04:50:47 +00:00
|
|
|
else:
|
2013-01-16 12:57:35 +00:00
|
|
|
layout.row().prop(tex_slot, "tex_paint_map_mode", text="")
|
|
|
|
layout.separator()
|
2013-04-07 01:38:03 +00:00
|
|
|
|
2013-04-05 13:00:16 +00:00
|
|
|
if tex_slot.map_mode == 'STENCIL':
|
2013-04-30 10:32:02 +00:00
|
|
|
if brush.texture and brush.texture.type == 'IMAGE':
|
|
|
|
layout.operator("brush.stencil_fit_image_aspect")
|
|
|
|
layout.operator("brush.stencil_reset_transform")
|
2013-02-10 08:54:10 +00:00
|
|
|
|
2013-01-16 12:57:35 +00:00
|
|
|
# angle and texture_angle_source
|
2014-12-30 17:06:59 +00:00
|
|
|
if tex_slot.has_texture_angle:
|
2014-02-12 15:57:25 +00:00
|
|
|
col = layout.column()
|
|
|
|
col.label(text="Angle:")
|
2014-12-30 17:06:59 +00:00
|
|
|
col.prop(tex_slot, "angle", text="")
|
|
|
|
if tex_slot.has_texture_angle_source:
|
2014-12-26 22:51:27 +00:00
|
|
|
col.prop(tex_slot, "use_rake", text="Rake")
|
|
|
|
|
2014-12-30 17:06:59 +00:00
|
|
|
if brush.brush_capabilities.has_random_texture_angle and tex_slot.has_random_texture_angle:
|
2014-02-12 15:57:25 +00:00
|
|
|
if sculpt:
|
|
|
|
if brush.sculpt_capabilities.has_random_texture_angle:
|
2014-12-26 22:51:27 +00:00
|
|
|
col.prop(tex_slot, "use_random", text="Random")
|
|
|
|
if tex_slot.use_random:
|
|
|
|
col.prop(tex_slot, "random_angle", text="")
|
2014-02-12 15:57:25 +00:00
|
|
|
else:
|
2014-12-26 22:51:27 +00:00
|
|
|
col.prop(tex_slot, "use_random", text="Random")
|
|
|
|
if tex_slot.use_random:
|
|
|
|
col.prop(tex_slot, "random_angle", text="")
|
2012-05-15 04:50:47 +00:00
|
|
|
|
|
|
|
# scale and offset
|
|
|
|
split = layout.split()
|
|
|
|
split.prop(tex_slot, "offset")
|
|
|
|
split.prop(tex_slot, "scale")
|
2013-02-10 08:54:10 +00:00
|
|
|
|
2013-01-16 12:57:35 +00:00
|
|
|
if sculpt:
|
|
|
|
# texture_sample_bias
|
|
|
|
col = layout.column(align=True)
|
|
|
|
col.label(text="Sample Bias:")
|
|
|
|
col.prop(brush, "texture_sample_bias", slider=True, text="")
|
2013-03-25 01:00:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
def brush_mask_texture_settings(layout, brush):
|
|
|
|
mask_tex_slot = brush.mask_texture_slot
|
|
|
|
|
Paint refactoring commit, non-disruptive (in theory :p)
* Fix precision overflow issue with overlay previews,
* Expose alpha mask mapping to UI (still not functional but coming soon).
* More overlay refactoring:
Overlay now does minimal checking for texture refresh.
Instead, we now have invalidation flags to set an aspect of the brush
overlay as invalid. This is necessary because this way we will be able to
separate and preview different brush attributes on the overlays, using
different textures:
These attributes/aspects are:
Primary texture (main texture for sculpt, vertex, imapaint)
Secondary texture (mask/alpha texture for imapaint)
Cursor texture (cursor texture. It involves brush strength and curves)
Modified the relevant RNA property update functions and C update callback
functions to call the relevant cursor invalidation functions instead
of checking every frame for multiple properties.
Properties that affect this are:
Image changes, if image is used by current brush,
Texture slot changes, similarly
Curve changes,
Object mode change invalidates the cursor
Paint tool change invalidates the cursor.
These changes give slightly more invalidation cases than simply
comparing the relevant properties each frame, but these do not occur in
performance critical moments and it's a much more elegant system than
adding more variables to check per frame each time we add something on
the system.
2013-04-12 17:21:31 +00:00
|
|
|
layout.label(text="Mask Mapping:")
|
|
|
|
|
|
|
|
# map_mode
|
|
|
|
layout.row().prop(mask_tex_slot, "mask_map_mode", text="")
|
|
|
|
layout.separator()
|
|
|
|
|
2013-04-23 11:34:18 +00:00
|
|
|
if mask_tex_slot.map_mode == 'STENCIL':
|
2013-04-30 10:32:02 +00:00
|
|
|
if brush.mask_texture and brush.mask_texture.type == 'IMAGE':
|
|
|
|
layout.operator("brush.stencil_fit_image_aspect").mask = True
|
2013-05-02 17:55:17 +00:00
|
|
|
layout.operator("brush.stencil_reset_transform").mask = True
|
2013-04-23 11:34:18 +00:00
|
|
|
|
2013-10-09 14:57:48 +00:00
|
|
|
col = layout.column()
|
2014-07-21 10:02:05 +00:00
|
|
|
col.prop(brush, "use_pressure_masking", text="")
|
2014-12-26 22:51:27 +00:00
|
|
|
# angle and texture_angle_source
|
2014-12-30 17:06:59 +00:00
|
|
|
if mask_tex_slot.has_texture_angle:
|
2014-12-26 22:51:27 +00:00
|
|
|
col = layout.column()
|
|
|
|
col.label(text="Angle:")
|
2014-12-30 17:06:59 +00:00
|
|
|
col.prop(mask_tex_slot, "angle", text="")
|
|
|
|
if mask_tex_slot.has_texture_angle_source:
|
2014-12-26 22:51:27 +00:00
|
|
|
col.prop(mask_tex_slot, "use_rake", text="Rake")
|
|
|
|
|
2014-12-30 17:06:59 +00:00
|
|
|
if brush.brush_capabilities.has_random_texture_angle and mask_tex_slot.has_random_texture_angle:
|
2014-12-26 22:51:27 +00:00
|
|
|
col.prop(mask_tex_slot, "use_random", text="Random")
|
|
|
|
if mask_tex_slot.use_random:
|
|
|
|
col.prop(mask_tex_slot, "random_angle", text="")
|
2013-10-09 14:57:48 +00:00
|
|
|
|
|
|
|
# scale and offset
|
|
|
|
split = layout.split()
|
|
|
|
split.prop(mask_tex_slot, "offset")
|
|
|
|
split.prop(mask_tex_slot, "scale")
|