mirror of
https://github.com/blender/blender
synced 2026-09-29 04:37:17 +03:00
Paint: Make UnifiedPaintSettings a per-mode instead of scene-wide value
Historically, the `UnifiedPaintSettings` struct has been used to provide users the ability to set brush values at a scene level. Examples of such attributes are the brush size, strength, and color, to name a few. Instead of these values being shared across all of the grease pencil, mesh painting, and curves sculpting modes. This commit migrates the data to the `Paint` struct, meaning that each individual mode (e.g. Sculpt, Vertex Paint, Grease Pencil Draw) now has the ability to change these values without affecting other modes. While this change is large, the majority of the work is simply refactoring access to the `UnifiedPaintSetting` struct. to ensure the correct property is being retrieved. Resolves #134077 Pull Request: https://projects.blender.org/blender/blender/pulls/139766
This commit is contained in:
parent
68b35b3ee0
commit
4434a30d40
84 changed files with 1094 additions and 897 deletions
|
|
@ -4617,7 +4617,7 @@ def km_paint_curve(params):
|
|||
|
||||
def radial_control_properties(paint, prop, secondary_prop, secondary_rotation=False, color=False, zoom=False):
|
||||
brush_path = "tool_settings." + paint + ".brush"
|
||||
unified_path = "tool_settings.unified_paint_settings"
|
||||
unified_path = "tool_settings." + paint + ".unified_paint_settings"
|
||||
rotation = "mask_texture_slot.angle" if secondary_rotation else "texture_slot.angle"
|
||||
return {
|
||||
"properties": [
|
||||
|
|
|
|||
|
|
@ -2647,7 +2647,7 @@ def km_curve(params):
|
|||
|
||||
def radial_control_properties(paint, prop, secondary_prop, secondary_rotation=False, color=False, zoom=False):
|
||||
brush_path = "tool_settings." + paint + ".brush"
|
||||
unified_path = "tool_settings.unified_paint_settings"
|
||||
unified_path = "tool_settings." + paint + ".unified_paint_settings"
|
||||
rotation = "mask_texture_slot.angle" if secondary_rotation else "texture_slot.angle"
|
||||
return {
|
||||
"properties": [
|
||||
|
|
|
|||
|
|
@ -271,7 +271,7 @@ class UnifiedPaintPanel:
|
|||
""" Generalized way of adding brush options to the UI,
|
||||
along with their pen pressure setting and global toggle, if they exist. """
|
||||
row = layout.row(align=True)
|
||||
ups = context.tool_settings.unified_paint_settings
|
||||
ups = UnifiedPaintPanel.paint_settings(context).unified_paint_settings
|
||||
prop_owner = brush
|
||||
if unified_name and getattr(ups, unified_name):
|
||||
prop_owner = ups
|
||||
|
|
@ -289,13 +289,13 @@ class UnifiedPaintPanel:
|
|||
|
||||
@staticmethod
|
||||
def prop_unified_color(parent, context, brush, prop_name, *, text=None):
|
||||
ups = context.tool_settings.unified_paint_settings
|
||||
ups = UnifiedPaintPanel.paint_settings(context).unified_paint_settings
|
||||
prop_owner = ups if ups.use_unified_color else brush
|
||||
parent.prop(prop_owner, 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
|
||||
ups = UnifiedPaintPanel.paint_settings(context).unified_paint_settings
|
||||
prop_owner = ups if ups.use_unified_color else brush
|
||||
parent.template_color_picker(prop_owner, prop_name, value_slider=value_slider)
|
||||
|
||||
|
|
@ -832,7 +832,7 @@ def brush_settings(layout, context, brush, popover=False):
|
|||
layout.separator()
|
||||
|
||||
if capabilities.has_color:
|
||||
ups = context.scene.tool_settings.unified_paint_settings
|
||||
ups = UnifiedPaintPanel.paint_settings(context).unified_paint_settings
|
||||
row = layout.row(align=True)
|
||||
UnifiedPaintPanel.prop_unified_color(row, context, brush, "color", text="")
|
||||
UnifiedPaintPanel.prop_unified_color(row, context, brush, "secondary_color", text="")
|
||||
|
|
@ -1124,7 +1124,7 @@ def brush_shared_settings(layout, context, brush, popover=False):
|
|||
strength = True
|
||||
|
||||
### Draw settings. ###
|
||||
ups = context.scene.tool_settings.unified_paint_settings
|
||||
ups = UnifiedPaintPanel.paint_settings(context).unified_paint_settings
|
||||
|
||||
if blend_mode:
|
||||
layout.prop(brush, "blend", text="Blend")
|
||||
|
|
@ -1179,7 +1179,7 @@ def brush_shared_settings(layout, context, brush, popover=False):
|
|||
|
||||
def color_jitter_panel(layout, context, brush):
|
||||
mode = UnifiedPaintPanel.get_brush_mode(context)
|
||||
ups = context.scene.tool_settings.unified_paint_settings
|
||||
ups = UnifiedPaintPanel.paint_settings(context).unified_paint_settings
|
||||
|
||||
is_sculpt_paint_mode = mode == 'SCULPT' and brush.sculpt_capabilities.has_color
|
||||
if mode in {'PAINT_TEXTURE', 'PAINT_2D', 'PAINT_VERTEX'} or is_sculpt_paint_mode:
|
||||
|
|
@ -1414,7 +1414,7 @@ def brush_settings_advanced(layout, context, settings, brush, popover=False):
|
|||
|
||||
def draw_color_settings(context, layout, brush, color_type=False):
|
||||
"""Draw color wheel and gradient settings."""
|
||||
ups = context.scene.tool_settings.unified_paint_settings
|
||||
ups = UnifiedPaintPanel.paint_settings(context).unified_paint_settings
|
||||
|
||||
if color_type:
|
||||
row = layout.row()
|
||||
|
|
|
|||
|
|
@ -2078,8 +2078,9 @@ class _defs_weight_paint:
|
|||
@ToolDef.from_fn
|
||||
def sample_weight():
|
||||
def draw_settings(context, layout, _tool):
|
||||
if context.tool_settings.unified_paint_settings.use_unified_weight:
|
||||
weight = context.tool_settings.unified_paint_settings.weight
|
||||
ups = context.tool_settings.weight_paint.unified_paint_settings
|
||||
if ups.use_unified_weight:
|
||||
weight = ups.weight
|
||||
elif context.tool_settings.weight_paint.brush:
|
||||
weight = context.tool_settings.weight_paint.brush.weight
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -253,7 +253,7 @@ class _draw_tool_settings_context_mode:
|
|||
tool_settings = context.tool_settings
|
||||
capabilities = brush.sculpt_capabilities
|
||||
|
||||
ups = tool_settings.unified_paint_settings
|
||||
ups = paint.unified_paint_settings
|
||||
|
||||
if capabilities.has_color:
|
||||
row = layout.row(align=True)
|
||||
|
|
@ -396,7 +396,7 @@ class _draw_tool_settings_context_mode:
|
|||
tool_settings = context.tool_settings
|
||||
capabilities = brush.sculpt_capabilities
|
||||
|
||||
ups = tool_settings.unified_paint_settings
|
||||
ups = paint.unified_paint_settings
|
||||
|
||||
size = "size"
|
||||
size_owner = ups if ups.use_unified_size else brush
|
||||
|
|
@ -487,7 +487,7 @@ class _draw_tool_settings_context_mode:
|
|||
|
||||
if brush.gpencil_vertex_brush_type not in {'BLUR', 'AVERAGE', 'SMEAR'}:
|
||||
layout.separator(factor=0.4)
|
||||
ups = context.tool_settings.unified_paint_settings
|
||||
ups = paint.unified_paint_settings
|
||||
prop_owner = ups if ups.use_unified_color else brush
|
||||
layout.prop_with_popover(prop_owner, "color", text="", panel="TOPBAR_PT_grease_pencil_vertex_color")
|
||||
|
||||
|
|
@ -8491,10 +8491,11 @@ class VIEW3D_PT_greasepencil_sculpt_context_menu(Panel):
|
|||
|
||||
def draw(self, context):
|
||||
tool_settings = context.tool_settings
|
||||
brush = tool_settings.gpencil_sculpt_paint.brush
|
||||
paint = tool_settings.gpencil_sculpt_paint
|
||||
brush = paint.brush
|
||||
layout = self.layout
|
||||
|
||||
ups = tool_settings.unified_paint_settings
|
||||
ups = paint.unified_paint_settings
|
||||
size_owner = ups if ups.use_unified_size else brush
|
||||
strength_owner = ups if ups.use_unified_strength else brush
|
||||
layout.prop(size_owner, "size", text="")
|
||||
|
|
@ -8528,8 +8529,8 @@ class VIEW3D_PT_greasepencil_vertex_paint_context_menu(Panel):
|
|||
|
||||
if brush.gpencil_vertex_brush_type in {'DRAW', 'REPLACE'}:
|
||||
split = layout.split(factor=0.1)
|
||||
split.prop(tool_settings.unified_paint_settings, "color", text="")
|
||||
split.template_color_picker(tool_settings.unified_paint_settings, "color", value_slider=True)
|
||||
split.prop(settings.unified_paint_settings, "color", text="")
|
||||
split.template_color_picker(settings.unified_paint_settings, "color", value_slider=True)
|
||||
|
||||
col = layout.column()
|
||||
col.separator()
|
||||
|
|
@ -8537,7 +8538,7 @@ class VIEW3D_PT_greasepencil_vertex_paint_context_menu(Panel):
|
|||
col.separator()
|
||||
|
||||
row = col.row(align=True)
|
||||
row.prop(tool_settings.unified_paint_settings, "size", text="Radius")
|
||||
row.prop(settings.unified_paint_settings, "size", text="Radius")
|
||||
row.prop(brush, "use_pressure_size", text="", icon='STYLUS_PRESSURE')
|
||||
|
||||
if brush.gpencil_vertex_brush_type in {'DRAW', 'BLUR', 'SMEAR'}:
|
||||
|
|
@ -8802,7 +8803,8 @@ class VIEW3D_PT_sculpt_context_menu(Panel):
|
|||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
brush = context.tool_settings.sculpt.brush
|
||||
paint = context.tool_settings.sculpt
|
||||
brush = paint.brush
|
||||
capabilities = brush.sculpt_capabilities
|
||||
|
||||
if capabilities.has_color:
|
||||
|
|
@ -8811,7 +8813,7 @@ class VIEW3D_PT_sculpt_context_menu(Panel):
|
|||
UnifiedPaintPanel.prop_unified_color_picker(split, context, brush, "color", value_slider=True)
|
||||
layout.prop(brush, "blend", text="")
|
||||
|
||||
ups = context.tool_settings.unified_paint_settings
|
||||
ups = paint.unified_paint_settings
|
||||
size = "size"
|
||||
size_owner = ups if ups.use_unified_size else brush
|
||||
if size_owner.use_locked_size == 'SCENE':
|
||||
|
|
@ -8895,7 +8897,7 @@ class TOPBAR_PT_grease_pencil_vertex_color(Panel):
|
|||
paint = context.scene.tool_settings.gpencil_vertex_paint
|
||||
use_unified_paint = (ob.mode != 'PAINT_GREASE_PENCIL')
|
||||
|
||||
ups = context.tool_settings.unified_paint_settings
|
||||
ups = paint.unified_paint_settings
|
||||
brush = paint.brush
|
||||
prop_owner = ups if use_unified_paint and ups.use_unified_color else brush
|
||||
|
||||
|
|
|
|||
|
|
@ -2159,7 +2159,7 @@ class VIEW3D_PT_tools_grease_pencil_brush_vertex_color(View3DPanel, Panel):
|
|||
settings = tool_settings.gpencil_vertex_paint
|
||||
brush = settings.brush
|
||||
use_unified_paint = (context.object.mode != 'PAINT_GREASE_PENCIL')
|
||||
ups = context.tool_settings.unified_paint_settings
|
||||
ups = settings.unified_paint_settings
|
||||
prop_owner = ups if use_unified_paint and ups.use_unified_color else brush
|
||||
|
||||
col = layout.column()
|
||||
|
|
@ -2820,7 +2820,7 @@ class VIEW3D_PT_tools_grease_pencil_v3_brush_mixcolor(View3DPanel, Panel):
|
|||
brush = settings.brush
|
||||
gp_settings = brush.gpencil_settings
|
||||
use_unified_paint = (context.object.mode != 'PAINT_GREASE_PENCIL')
|
||||
ups = context.tool_settings.unified_paint_settings
|
||||
ups = settings.unified_paint_settings
|
||||
prop_owner = ups if use_unified_paint and ups.use_unified_color else brush
|
||||
|
||||
row = layout.row()
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
/* Blender file format version. */
|
||||
#define BLENDER_FILE_VERSION BLENDER_VERSION
|
||||
#define BLENDER_FILE_SUBVERSION 25
|
||||
#define BLENDER_FILE_SUBVERSION 26
|
||||
|
||||
/* Minimum Blender version that supports reading file written with the current
|
||||
* version. Older Blender versions will test this and cancel loading the file, showing a warning to
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ void BKE_brush_tag_unsaved_changes(Brush *brush);
|
|||
|
||||
Brush *BKE_brush_first_search(Main *bmain, eObjectMode ob_mode);
|
||||
|
||||
void BKE_brush_jitter_pos(const Scene &scene,
|
||||
void BKE_brush_jitter_pos(const Paint &paint,
|
||||
const Brush &brush,
|
||||
const float pos[2],
|
||||
float jitterpos[2]);
|
||||
|
|
@ -133,7 +133,7 @@ float BKE_brush_curve_strength(const Brush *br, float p, float len);
|
|||
*
|
||||
* RGBA outputs straight alpha.
|
||||
*/
|
||||
float BKE_brush_sample_tex_3d(const Scene *scene,
|
||||
float BKE_brush_sample_tex_3d(const Paint *paint,
|
||||
const Brush *br,
|
||||
const MTex *mtex,
|
||||
const float point[3],
|
||||
|
|
@ -141,7 +141,7 @@ float BKE_brush_sample_tex_3d(const Scene *scene,
|
|||
int thread,
|
||||
ImagePool *pool);
|
||||
float BKE_brush_sample_masktex(
|
||||
const Scene *scene, Brush *br, const float point[2], int thread, ImagePool *pool);
|
||||
const Paint *paint, Brush *br, const float point[2], int thread, ImagePool *pool);
|
||||
|
||||
/**
|
||||
* Get the mask texture for this given object mode.
|
||||
|
|
@ -179,30 +179,27 @@ struct BrushColorJitterSettings {
|
|||
CurveMapping *curve_val_jitter;
|
||||
};
|
||||
|
||||
const float *BKE_brush_color_get(const Scene *scene, const Paint *paint, const Brush *brush);
|
||||
std::optional<BrushColorJitterSettings> BKE_brush_color_jitter_get_settings(const Scene *scene,
|
||||
const Paint *paint,
|
||||
const float *BKE_brush_color_get(const Paint *paint, const Brush *brush);
|
||||
std::optional<BrushColorJitterSettings> BKE_brush_color_jitter_get_settings(const Paint *paint,
|
||||
const Brush *brush);
|
||||
const float *BKE_brush_secondary_color_get(const Scene *scene,
|
||||
const Paint *paint,
|
||||
const Brush *brush);
|
||||
void BKE_brush_color_set(Scene *scene, const Paint *paint, Brush *brush, const float color[3]);
|
||||
const float *BKE_brush_secondary_color_get(const Paint *paint, const Brush *brush);
|
||||
void BKE_brush_color_set(Paint *paint, Brush *brush, const float color[3]);
|
||||
|
||||
int BKE_brush_size_get(const Scene *scene, const Brush *brush);
|
||||
void BKE_brush_size_set(Scene *scene, Brush *brush, int size);
|
||||
int BKE_brush_size_get(const Paint *paint, const Brush *brush);
|
||||
void BKE_brush_size_set(Paint *paint, Brush *brush, int size);
|
||||
|
||||
float BKE_brush_unprojected_radius_get(const Scene *scene, const Brush *brush);
|
||||
void BKE_brush_unprojected_radius_set(Scene *scene, Brush *brush, float unprojected_radius);
|
||||
float BKE_brush_unprojected_radius_get(const Paint *paint, const Brush *brush);
|
||||
void BKE_brush_unprojected_radius_set(Paint *paint, Brush *brush, float unprojected_radius);
|
||||
|
||||
float BKE_brush_alpha_get(const Scene *scene, const Brush *brush);
|
||||
void BKE_brush_alpha_set(Scene *scene, Brush *brush, float alpha);
|
||||
float BKE_brush_weight_get(const Scene *scene, const Brush *brush);
|
||||
void BKE_brush_weight_set(const Scene *scene, Brush *brush, float value);
|
||||
float BKE_brush_alpha_get(const Paint *paint, const Brush *brush);
|
||||
void BKE_brush_alpha_set(Paint *paint, Brush *brush, float alpha);
|
||||
float BKE_brush_weight_get(const Paint *paint, const Brush *brush);
|
||||
void BKE_brush_weight_set(Paint *paint, Brush *brush, float value);
|
||||
|
||||
int BKE_brush_input_samples_get(const Scene *scene, const Brush *brush);
|
||||
void BKE_brush_input_samples_set(const Scene *scene, Brush *brush, int value);
|
||||
int BKE_brush_input_samples_get(const Paint *paint, const Brush *brush);
|
||||
void BKE_brush_input_samples_set(Paint *paint, Brush *brush, int value);
|
||||
|
||||
bool BKE_brush_use_locked_size(const Scene *scene, const Brush *brush);
|
||||
bool BKE_brush_use_locked_size(const Paint *paint, const Brush *brush);
|
||||
bool BKE_brush_use_alpha_pressure(const Brush *brush);
|
||||
bool BKE_brush_use_size_pressure(const Brush *brush);
|
||||
|
||||
|
|
|
|||
|
|
@ -200,7 +200,7 @@ Paint *BKE_paint_get_active(Scene *sce, ViewLayer *view_layer);
|
|||
Paint *BKE_paint_get_active_from_context(const bContext *C);
|
||||
PaintMode BKE_paintmode_get_active_from_context(const bContext *C);
|
||||
PaintMode BKE_paintmode_get_from_tool(const bToolRef *tref);
|
||||
bool BKE_paint_use_unified_color(const ToolSettings *tool_settings, const Paint *paint);
|
||||
bool BKE_paint_use_unified_color(const Paint *paint);
|
||||
|
||||
/* Paint brush retrieval and assignment. */
|
||||
|
||||
|
|
@ -328,7 +328,7 @@ void paint_update_brush_rake_rotation(UnifiedPaintSettings &ups,
|
|||
const Brush &brush,
|
||||
float rotation);
|
||||
|
||||
void BKE_paint_stroke_get_average(const Scene *scene, const Object *ob, float stroke[3]);
|
||||
void BKE_paint_stroke_get_average(const Paint *paint, const Object *ob, float stroke[3]);
|
||||
|
||||
blender::float3 BKE_paint_randomize_color(const BrushColorJitterSettings &color_jitter,
|
||||
const blender::float3 &initial_hsv_jitter,
|
||||
|
|
|
|||
|
|
@ -865,7 +865,7 @@ const MTex *BKE_brush_color_texture_get(const Brush *brush, const eObjectMode ob
|
|||
return &brush->mtex;
|
||||
}
|
||||
|
||||
float BKE_brush_sample_tex_3d(const Scene *scene,
|
||||
float BKE_brush_sample_tex_3d(const Paint *paint,
|
||||
const Brush *br,
|
||||
const MTex *mtex,
|
||||
const float point[3],
|
||||
|
|
@ -873,7 +873,7 @@ float BKE_brush_sample_tex_3d(const Scene *scene,
|
|||
const int thread,
|
||||
ImagePool *pool)
|
||||
{
|
||||
UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
|
||||
const UnifiedPaintSettings *ups = &paint->unified_paint_settings;
|
||||
float intensity = 1.0;
|
||||
bool hasrgb = false;
|
||||
|
||||
|
|
@ -989,9 +989,9 @@ float BKE_brush_sample_tex_3d(const Scene *scene,
|
|||
}
|
||||
|
||||
float BKE_brush_sample_masktex(
|
||||
const Scene *scene, Brush *br, const float point[2], const int thread, ImagePool *pool)
|
||||
const Paint *paint, Brush *br, const float point[2], const int thread, ImagePool *pool)
|
||||
{
|
||||
UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
|
||||
const UnifiedPaintSettings *ups = &paint->unified_paint_settings;
|
||||
MTex *mtex = &br->mask_mtex;
|
||||
float rgba[4], intensity;
|
||||
|
||||
|
|
@ -1116,25 +1116,24 @@ float BKE_brush_sample_masktex(
|
|||
* In any case, a better solution is needed to prevent
|
||||
* inconsistency. */
|
||||
|
||||
const float *BKE_brush_color_get(const Scene *scene, const Paint *paint, const Brush *brush)
|
||||
const float *BKE_brush_color_get(const Paint *paint, const Brush *brush)
|
||||
{
|
||||
if (BKE_paint_use_unified_color(scene->toolsettings, paint)) {
|
||||
return scene->toolsettings->unified_paint_settings.rgb;
|
||||
if (BKE_paint_use_unified_color(paint)) {
|
||||
return paint->unified_paint_settings.rgb;
|
||||
}
|
||||
return brush->rgb;
|
||||
}
|
||||
|
||||
/** Get color jitter settings if enabled. */
|
||||
std::optional<BrushColorJitterSettings> BKE_brush_color_jitter_get_settings(const Scene *scene,
|
||||
const Paint *paint,
|
||||
std::optional<BrushColorJitterSettings> BKE_brush_color_jitter_get_settings(const Paint *paint,
|
||||
const Brush *brush)
|
||||
{
|
||||
if (BKE_paint_use_unified_color(scene->toolsettings, paint)) {
|
||||
if ((scene->toolsettings->unified_paint_settings.flag & UNIFIED_PAINT_COLOR_JITTER) == 0) {
|
||||
if (BKE_paint_use_unified_color(paint)) {
|
||||
if ((paint->unified_paint_settings.flag & UNIFIED_PAINT_COLOR_JITTER) == 0) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
const UnifiedPaintSettings settings = scene->toolsettings->unified_paint_settings;
|
||||
const UnifiedPaintSettings settings = paint->unified_paint_settings;
|
||||
return BrushColorJitterSettings{
|
||||
settings.color_jitter_flag,
|
||||
settings.hsv_jitter[0],
|
||||
|
|
@ -1161,20 +1160,18 @@ std::optional<BrushColorJitterSettings> BKE_brush_color_jitter_get_settings(cons
|
|||
};
|
||||
}
|
||||
|
||||
const float *BKE_brush_secondary_color_get(const Scene *scene,
|
||||
const Paint *paint,
|
||||
const Brush *brush)
|
||||
const float *BKE_brush_secondary_color_get(const Paint *paint, const Brush *brush)
|
||||
{
|
||||
if (BKE_paint_use_unified_color(scene->toolsettings, paint)) {
|
||||
return scene->toolsettings->unified_paint_settings.secondary_rgb;
|
||||
if (BKE_paint_use_unified_color(paint)) {
|
||||
return paint->unified_paint_settings.secondary_rgb;
|
||||
}
|
||||
return brush->secondary_rgb;
|
||||
}
|
||||
|
||||
void BKE_brush_color_set(Scene *scene, const Paint *paint, Brush *brush, const float color[3])
|
||||
void BKE_brush_color_set(Paint *paint, Brush *brush, const float color[3])
|
||||
{
|
||||
if (BKE_paint_use_unified_color(scene->toolsettings, paint)) {
|
||||
UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
|
||||
if (BKE_paint_use_unified_color(paint)) {
|
||||
UnifiedPaintSettings *ups = &paint->unified_paint_settings;
|
||||
copy_v3_v3(ups->rgb, color);
|
||||
}
|
||||
else {
|
||||
|
|
@ -1183,9 +1180,9 @@ void BKE_brush_color_set(Scene *scene, const Paint *paint, Brush *brush, const f
|
|||
}
|
||||
}
|
||||
|
||||
void BKE_brush_size_set(Scene *scene, Brush *brush, int size)
|
||||
void BKE_brush_size_set(Paint *paint, Brush *brush, int size)
|
||||
{
|
||||
UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
|
||||
UnifiedPaintSettings *ups = &paint->unified_paint_settings;
|
||||
|
||||
/* make sure range is sane */
|
||||
CLAMP(size, 1, MAX_BRUSH_PIXEL_RADIUS);
|
||||
|
|
@ -1199,17 +1196,17 @@ void BKE_brush_size_set(Scene *scene, Brush *brush, int size)
|
|||
}
|
||||
}
|
||||
|
||||
int BKE_brush_size_get(const Scene *scene, const Brush *brush)
|
||||
int BKE_brush_size_get(const Paint *paint, const Brush *brush)
|
||||
{
|
||||
UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
|
||||
const UnifiedPaintSettings *ups = &paint->unified_paint_settings;
|
||||
int size = (ups->flag & UNIFIED_PAINT_SIZE) ? ups->size : brush->size;
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
bool BKE_brush_use_locked_size(const Scene *scene, const Brush *brush)
|
||||
bool BKE_brush_use_locked_size(const Paint *paint, const Brush *brush)
|
||||
{
|
||||
const short us_flag = scene->toolsettings->unified_paint_settings.flag;
|
||||
const short us_flag = paint->unified_paint_settings.flag;
|
||||
|
||||
return (us_flag & UNIFIED_PAINT_SIZE) ? (us_flag & UNIFIED_PAINT_BRUSH_LOCK_SIZE) :
|
||||
(brush->flag & BRUSH_LOCK_SIZE);
|
||||
|
|
@ -1225,9 +1222,9 @@ bool BKE_brush_use_alpha_pressure(const Brush *brush)
|
|||
return brush->flag & BRUSH_ALPHA_PRESSURE;
|
||||
}
|
||||
|
||||
void BKE_brush_unprojected_radius_set(Scene *scene, Brush *brush, float unprojected_radius)
|
||||
void BKE_brush_unprojected_radius_set(Paint *paint, Brush *brush, float unprojected_radius)
|
||||
{
|
||||
UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
|
||||
UnifiedPaintSettings *ups = &paint->unified_paint_settings;
|
||||
|
||||
if (ups->flag & UNIFIED_PAINT_SIZE) {
|
||||
ups->unprojected_radius = unprojected_radius;
|
||||
|
|
@ -1238,16 +1235,16 @@ void BKE_brush_unprojected_radius_set(Scene *scene, Brush *brush, float unprojec
|
|||
}
|
||||
}
|
||||
|
||||
float BKE_brush_unprojected_radius_get(const Scene *scene, const Brush *brush)
|
||||
float BKE_brush_unprojected_radius_get(const Paint *paint, const Brush *brush)
|
||||
{
|
||||
UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
|
||||
const UnifiedPaintSettings *ups = &paint->unified_paint_settings;
|
||||
|
||||
return (ups->flag & UNIFIED_PAINT_SIZE) ? ups->unprojected_radius : brush->unprojected_radius;
|
||||
}
|
||||
|
||||
void BKE_brush_alpha_set(Scene *scene, Brush *brush, float alpha)
|
||||
void BKE_brush_alpha_set(Paint *paint, Brush *brush, float alpha)
|
||||
{
|
||||
UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
|
||||
UnifiedPaintSettings *ups = &paint->unified_paint_settings;
|
||||
|
||||
if (ups->flag & UNIFIED_PAINT_ALPHA) {
|
||||
ups->alpha = alpha;
|
||||
|
|
@ -1258,23 +1255,23 @@ void BKE_brush_alpha_set(Scene *scene, Brush *brush, float alpha)
|
|||
}
|
||||
}
|
||||
|
||||
float BKE_brush_alpha_get(const Scene *scene, const Brush *brush)
|
||||
float BKE_brush_alpha_get(const Paint *paint, const Brush *brush)
|
||||
{
|
||||
UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
|
||||
const UnifiedPaintSettings *ups = &paint->unified_paint_settings;
|
||||
|
||||
return (ups->flag & UNIFIED_PAINT_ALPHA) ? ups->alpha : brush->alpha;
|
||||
}
|
||||
|
||||
float BKE_brush_weight_get(const Scene *scene, const Brush *brush)
|
||||
float BKE_brush_weight_get(const Paint *paint, const Brush *brush)
|
||||
{
|
||||
UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
|
||||
const UnifiedPaintSettings *ups = &paint->unified_paint_settings;
|
||||
|
||||
return (ups->flag & UNIFIED_PAINT_WEIGHT) ? ups->weight : brush->weight;
|
||||
}
|
||||
|
||||
void BKE_brush_weight_set(const Scene *scene, Brush *brush, float value)
|
||||
void BKE_brush_weight_set(Paint *paint, Brush *brush, float value)
|
||||
{
|
||||
UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
|
||||
UnifiedPaintSettings *ups = &paint->unified_paint_settings;
|
||||
|
||||
if (ups->flag & UNIFIED_PAINT_WEIGHT) {
|
||||
ups->weight = value;
|
||||
|
|
@ -1285,16 +1282,16 @@ void BKE_brush_weight_set(const Scene *scene, Brush *brush, float value)
|
|||
}
|
||||
}
|
||||
|
||||
int BKE_brush_input_samples_get(const Scene *scene, const Brush *brush)
|
||||
int BKE_brush_input_samples_get(const Paint *paint, const Brush *brush)
|
||||
{
|
||||
UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
|
||||
const UnifiedPaintSettings *ups = &paint->unified_paint_settings;
|
||||
|
||||
return (ups->flag & UNIFIED_PAINT_INPUT_SAMPLES) ? ups->input_samples : brush->input_samples;
|
||||
}
|
||||
|
||||
void BKE_brush_input_samples_set(const Scene *scene, Brush *brush, int value)
|
||||
void BKE_brush_input_samples_set(Paint *paint, Brush *brush, int value)
|
||||
{
|
||||
UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
|
||||
UnifiedPaintSettings *ups = &paint->unified_paint_settings;
|
||||
|
||||
if (ups->flag & UNIFIED_PAINT_INPUT_SAMPLES) {
|
||||
ups->input_samples = value;
|
||||
|
|
@ -1329,7 +1326,7 @@ void BKE_brush_scale_size(int *r_brush_size,
|
|||
(*r_brush_size) = int(float(*r_brush_size) * scale);
|
||||
}
|
||||
|
||||
void BKE_brush_jitter_pos(const Scene &scene,
|
||||
void BKE_brush_jitter_pos(const Paint &paint,
|
||||
const Brush &brush,
|
||||
const float pos[2],
|
||||
float jitterpos[2])
|
||||
|
|
@ -1348,7 +1345,7 @@ void BKE_brush_jitter_pos(const Scene &scene,
|
|||
spread = 1.0;
|
||||
}
|
||||
else {
|
||||
diameter = 2 * BKE_brush_size_get(&scene, &brush);
|
||||
diameter = 2 * BKE_brush_size_get(&paint, &brush);
|
||||
spread = brush.jitter;
|
||||
}
|
||||
/* find random position within a circle of diameter 1 */
|
||||
|
|
|
|||
|
|
@ -589,14 +589,14 @@ PaintMode BKE_paintmode_get_from_tool(const bToolRef *tref)
|
|||
return PaintMode::Invalid;
|
||||
}
|
||||
|
||||
bool BKE_paint_use_unified_color(const ToolSettings *tool_settings, const Paint *paint)
|
||||
bool BKE_paint_use_unified_color(const Paint *paint)
|
||||
{
|
||||
/* Grease pencil draw mode never uses unified paint. */
|
||||
if (paint->runtime.ob_mode == OB_MODE_PAINT_GREASE_PENCIL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return tool_settings->unified_paint_settings.flag & UNIFIED_PAINT_COLOR;
|
||||
return paint->unified_paint_settings.flag & UNIFIED_PAINT_COLOR;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1672,6 +1672,28 @@ eObjectMode BKE_paint_object_mode_from_paintmode(const PaintMode mode)
|
|||
}
|
||||
}
|
||||
|
||||
static void paint_init_data(Paint &paint)
|
||||
{
|
||||
const UnifiedPaintSettings &default_ups = *DNA_struct_default_get(UnifiedPaintSettings);
|
||||
paint.unified_paint_settings.size = default_ups.size;
|
||||
paint.unified_paint_settings.input_samples = default_ups.input_samples;
|
||||
paint.unified_paint_settings.unprojected_radius = default_ups.unprojected_radius;
|
||||
paint.unified_paint_settings.alpha = default_ups.alpha;
|
||||
paint.unified_paint_settings.weight = default_ups.weight;
|
||||
paint.unified_paint_settings.flag = default_ups.flag;
|
||||
if (!paint.unified_paint_settings.curve_rand_hue) {
|
||||
paint.unified_paint_settings.curve_rand_hue = BKE_paint_default_curve();
|
||||
}
|
||||
if (!paint.unified_paint_settings.curve_rand_saturation) {
|
||||
paint.unified_paint_settings.curve_rand_saturation = BKE_paint_default_curve();
|
||||
}
|
||||
if (!paint.unified_paint_settings.curve_rand_value) {
|
||||
paint.unified_paint_settings.curve_rand_value = BKE_paint_default_curve();
|
||||
}
|
||||
copy_v3_v3(paint.unified_paint_settings.rgb, default_ups.rgb);
|
||||
copy_v3_v3(paint.unified_paint_settings.secondary_rgb, default_ups.secondary_rgb);
|
||||
}
|
||||
|
||||
bool BKE_paint_ensure(ToolSettings *ts, Paint **r_paint)
|
||||
{
|
||||
Paint *paint = nullptr;
|
||||
|
|
@ -1708,6 +1730,7 @@ bool BKE_paint_ensure(ToolSettings *ts, Paint **r_paint)
|
|||
if (((VPaint **)r_paint == &ts->vpaint) || ((VPaint **)r_paint == &ts->wpaint)) {
|
||||
VPaint *data = MEM_callocN<VPaint>(__func__);
|
||||
paint = &data->paint;
|
||||
paint_init_data(*paint);
|
||||
}
|
||||
else if ((Sculpt **)r_paint == &ts->sculpt) {
|
||||
Sculpt *data = MEM_callocN<Sculpt>(__func__);
|
||||
|
|
@ -1715,29 +1738,36 @@ bool BKE_paint_ensure(ToolSettings *ts, Paint **r_paint)
|
|||
*data = *DNA_struct_default_get(Sculpt);
|
||||
|
||||
paint = &data->paint;
|
||||
paint_init_data(*paint);
|
||||
}
|
||||
else if ((GpPaint **)r_paint == &ts->gp_paint) {
|
||||
GpPaint *data = MEM_callocN<GpPaint>(__func__);
|
||||
paint = &data->paint;
|
||||
paint_init_data(*paint);
|
||||
}
|
||||
else if ((GpVertexPaint **)r_paint == &ts->gp_vertexpaint) {
|
||||
GpVertexPaint *data = MEM_callocN<GpVertexPaint>(__func__);
|
||||
paint = &data->paint;
|
||||
paint_init_data(*paint);
|
||||
}
|
||||
else if ((GpSculptPaint **)r_paint == &ts->gp_sculptpaint) {
|
||||
GpSculptPaint *data = MEM_callocN<GpSculptPaint>(__func__);
|
||||
paint = &data->paint;
|
||||
paint_init_data(*paint);
|
||||
}
|
||||
else if ((GpWeightPaint **)r_paint == &ts->gp_weightpaint) {
|
||||
GpWeightPaint *data = MEM_callocN<GpWeightPaint>(__func__);
|
||||
paint = &data->paint;
|
||||
paint_init_data(*paint);
|
||||
}
|
||||
else if ((CurvesSculpt **)r_paint == &ts->curves_sculpt) {
|
||||
CurvesSculpt *data = MEM_callocN<CurvesSculpt>(__func__);
|
||||
paint = &data->paint;
|
||||
paint_init_data(*paint);
|
||||
}
|
||||
else if (*r_paint == &ts->imapaint.paint) {
|
||||
paint = &ts->imapaint.paint;
|
||||
paint_init_data(*paint);
|
||||
}
|
||||
|
||||
paint->flags |= PAINT_SHOW_BRUSH;
|
||||
|
|
@ -1769,10 +1799,10 @@ void BKE_paint_brushes_ensure(Main *bmain, Paint *paint)
|
|||
void BKE_paint_init(
|
||||
Main *bmain, Scene *sce, PaintMode mode, const uchar col[3], const bool ensure_brushes)
|
||||
{
|
||||
UnifiedPaintSettings *ups = &sce->toolsettings->unified_paint_settings;
|
||||
|
||||
BKE_paint_ensure_from_paintmode(sce, mode);
|
||||
Paint *paint = BKE_paint_get_active_from_paintmode(sce, mode);
|
||||
UnifiedPaintSettings *ups = &paint->unified_paint_settings;
|
||||
|
||||
if (ensure_brushes) {
|
||||
BKE_paint_brushes_ensure(bmain, paint);
|
||||
|
|
@ -1804,6 +1834,10 @@ void BKE_paint_free(Paint *paint)
|
|||
MEM_delete(brush_ref);
|
||||
}
|
||||
MEM_delete(paint->runtime.previous_active_brush_reference);
|
||||
|
||||
BKE_curvemapping_free(paint->unified_paint_settings.curve_rand_hue);
|
||||
BKE_curvemapping_free(paint->unified_paint_settings.curve_rand_saturation);
|
||||
BKE_curvemapping_free(paint->unified_paint_settings.curve_rand_value);
|
||||
}
|
||||
|
||||
void BKE_paint_copy(const Paint *src, Paint *dst, const int flag)
|
||||
|
|
@ -1833,14 +1867,21 @@ void BKE_paint_copy(const Paint *src, Paint *dst, const int flag)
|
|||
__func__, *brush_ref->brush_asset_reference);
|
||||
}
|
||||
|
||||
dst->unified_paint_settings.curve_rand_hue = BKE_curvemapping_copy(
|
||||
src->unified_paint_settings.curve_rand_hue);
|
||||
dst->unified_paint_settings.curve_rand_saturation = BKE_curvemapping_copy(
|
||||
src->unified_paint_settings.curve_rand_saturation);
|
||||
dst->unified_paint_settings.curve_rand_value = BKE_curvemapping_copy(
|
||||
src->unified_paint_settings.curve_rand_value);
|
||||
|
||||
if ((flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0) {
|
||||
id_us_plus((ID *)dst->palette);
|
||||
}
|
||||
}
|
||||
|
||||
void BKE_paint_stroke_get_average(const Scene *scene, const Object *ob, float stroke[3])
|
||||
void BKE_paint_stroke_get_average(const Paint *paint, const Object *ob, float stroke[3])
|
||||
{
|
||||
const UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
|
||||
const UnifiedPaintSettings *ups = &paint->unified_paint_settings;
|
||||
if (ups->last_stroke_valid && ups->average_stroke_counter > 0) {
|
||||
float fac = 1.0f / ups->average_stroke_counter;
|
||||
mul_v3_v3fl(stroke, ups->average_stroke_accum, fac);
|
||||
|
|
@ -1936,6 +1977,18 @@ void BKE_paint_blend_write(BlendWriter *writer, Paint *paint)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (paint->unified_paint_settings.curve_rand_hue) {
|
||||
BKE_curvemapping_blend_write(writer, paint->unified_paint_settings.curve_rand_hue);
|
||||
}
|
||||
|
||||
if (paint->unified_paint_settings.curve_rand_saturation) {
|
||||
BKE_curvemapping_blend_write(writer, paint->unified_paint_settings.curve_rand_saturation);
|
||||
}
|
||||
|
||||
if (paint->unified_paint_settings.curve_rand_value) {
|
||||
BKE_curvemapping_blend_write(writer, paint->unified_paint_settings.curve_rand_value);
|
||||
}
|
||||
}
|
||||
|
||||
void BKE_paint_blend_read_data(BlendDataReader *reader, const Scene *scene, Paint *paint)
|
||||
|
|
@ -1979,8 +2032,32 @@ void BKE_paint_blend_read_data(BlendDataReader *reader, const Scene *scene, Pain
|
|||
}
|
||||
}
|
||||
}
|
||||
UnifiedPaintSettings *ups = &paint->unified_paint_settings;
|
||||
BLO_read_struct(reader, CurveMapping, &ups->curve_rand_hue);
|
||||
if (ups->curve_rand_hue) {
|
||||
BKE_curvemapping_blend_read(reader, ups->curve_rand_hue);
|
||||
BKE_curvemapping_init(ups->curve_rand_hue);
|
||||
}
|
||||
|
||||
BLO_read_struct(reader, CurveMapping, &ups->curve_rand_saturation);
|
||||
if (ups->curve_rand_saturation) {
|
||||
BKE_curvemapping_blend_read(reader, ups->curve_rand_saturation);
|
||||
BKE_curvemapping_init(ups->curve_rand_saturation);
|
||||
}
|
||||
|
||||
BLO_read_struct(reader, CurveMapping, &ups->curve_rand_value);
|
||||
if (ups->curve_rand_value) {
|
||||
BKE_curvemapping_blend_read(reader, ups->curve_rand_value);
|
||||
BKE_curvemapping_init(ups->curve_rand_value);
|
||||
}
|
||||
|
||||
paint->paint_cursor = nullptr;
|
||||
|
||||
/* Reset last_location and last_hit, so they are not remembered across sessions. In some files
|
||||
* these are also NaN, which could lead to crashes in painting. */
|
||||
zero_v3(ups->last_location);
|
||||
ups->last_hit = 0;
|
||||
|
||||
paint_runtime_init(scene->toolsettings, paint);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
#include "BLI_sys_types.h"
|
||||
|
||||
#include "BKE_attribute_legacy_convert.hh"
|
||||
#include "BKE_colortools.hh"
|
||||
#include "BKE_main.hh"
|
||||
#include "BKE_mesh_legacy_convert.hh"
|
||||
#include "BKE_node.hh"
|
||||
|
|
@ -458,6 +459,44 @@ static void version_seq_text_from_legacy(Main *bmain)
|
|||
}
|
||||
}
|
||||
|
||||
static void apply_unified_paint_settings_to_all_modes(Scene &scene)
|
||||
{
|
||||
const UnifiedPaintSettings &scene_ups = scene.toolsettings->unified_paint_settings;
|
||||
auto apply_to_paint = [&](Paint *paint) {
|
||||
if (paint == nullptr) {
|
||||
return;
|
||||
}
|
||||
UnifiedPaintSettings &ups = paint->unified_paint_settings;
|
||||
|
||||
ups.size = scene_ups.size;
|
||||
ups.unprojected_radius = scene_ups.unprojected_radius;
|
||||
ups.alpha = scene_ups.alpha;
|
||||
ups.weight = scene_ups.weight;
|
||||
copy_v3_v3(ups.rgb, scene_ups.rgb);
|
||||
copy_v3_v3(ups.secondary_rgb, scene_ups.secondary_rgb);
|
||||
ups.color_jitter_flag = scene_ups.color_jitter_flag;
|
||||
copy_v3_v3(ups.hsv_jitter, scene_ups.hsv_jitter);
|
||||
|
||||
BLI_assert(ups.curve_rand_hue == nullptr);
|
||||
BLI_assert(ups.curve_rand_saturation == nullptr);
|
||||
BLI_assert(ups.curve_rand_value == nullptr);
|
||||
ups.curve_rand_hue = BKE_curvemapping_copy(scene_ups.curve_rand_hue);
|
||||
ups.curve_rand_saturation = BKE_curvemapping_copy(scene_ups.curve_rand_saturation);
|
||||
ups.curve_rand_value = BKE_curvemapping_copy(scene_ups.curve_rand_value);
|
||||
ups.flag = scene_ups.flag;
|
||||
};
|
||||
|
||||
apply_to_paint(reinterpret_cast<Paint *>(scene.toolsettings->vpaint));
|
||||
apply_to_paint(reinterpret_cast<Paint *>(scene.toolsettings->wpaint));
|
||||
apply_to_paint(reinterpret_cast<Paint *>(scene.toolsettings->sculpt));
|
||||
apply_to_paint(reinterpret_cast<Paint *>(scene.toolsettings->gp_paint));
|
||||
apply_to_paint(reinterpret_cast<Paint *>(scene.toolsettings->gp_vertexpaint));
|
||||
apply_to_paint(reinterpret_cast<Paint *>(scene.toolsettings->gp_sculptpaint));
|
||||
apply_to_paint(reinterpret_cast<Paint *>(scene.toolsettings->gp_weightpaint));
|
||||
apply_to_paint(reinterpret_cast<Paint *>(scene.toolsettings->curves_sculpt));
|
||||
apply_to_paint(reinterpret_cast<Paint *>(&scene.toolsettings->imapaint));
|
||||
}
|
||||
|
||||
void do_versions_after_linking_500(FileData * /*fd*/, Main * /*bmain*/)
|
||||
{
|
||||
/**
|
||||
|
|
@ -622,6 +661,12 @@ void blo_do_versions_500(FileData * /*fd*/, Library * /*lib*/, Main *bmain)
|
|||
version_seq_text_from_legacy(bmain);
|
||||
}
|
||||
|
||||
if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 26)) {
|
||||
LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
|
||||
apply_unified_paint_settings_to_all_modes(*scene);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Always bump subversion in BKE_blender_version.h when adding versioning
|
||||
* code here, and wrap it inside a MAIN_VERSION_FILE_ATLEAST check.
|
||||
|
|
|
|||
|
|
@ -347,6 +347,38 @@ void BLO_update_defaults_workspace(WorkSpace *workspace, const char *app_templat
|
|||
}
|
||||
}
|
||||
|
||||
static void blo_update_defaults_paint(Paint *paint)
|
||||
{
|
||||
if (!paint) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Ensure input_samples has a correct default value of 1. */
|
||||
if (paint->unified_paint_settings.input_samples == 0) {
|
||||
paint->unified_paint_settings.input_samples = 1;
|
||||
}
|
||||
|
||||
const UnifiedPaintSettings &default_ups = *DNA_struct_default_get(UnifiedPaintSettings);
|
||||
paint->unified_paint_settings.size = default_ups.size;
|
||||
paint->unified_paint_settings.input_samples = default_ups.input_samples;
|
||||
paint->unified_paint_settings.unprojected_radius = default_ups.unprojected_radius;
|
||||
paint->unified_paint_settings.alpha = default_ups.alpha;
|
||||
paint->unified_paint_settings.weight = default_ups.weight;
|
||||
paint->unified_paint_settings.flag = default_ups.flag;
|
||||
copy_v3_v3(paint->unified_paint_settings.rgb, default_ups.rgb);
|
||||
copy_v3_v3(paint->unified_paint_settings.secondary_rgb, default_ups.secondary_rgb);
|
||||
|
||||
if (paint->unified_paint_settings.curve_rand_hue == nullptr) {
|
||||
paint->unified_paint_settings.curve_rand_hue = BKE_paint_default_curve();
|
||||
}
|
||||
if (paint->unified_paint_settings.curve_rand_saturation == nullptr) {
|
||||
paint->unified_paint_settings.curve_rand_saturation = BKE_paint_default_curve();
|
||||
}
|
||||
if (paint->unified_paint_settings.curve_rand_value == nullptr) {
|
||||
paint->unified_paint_settings.curve_rand_value = BKE_paint_default_curve();
|
||||
}
|
||||
}
|
||||
|
||||
static void blo_update_defaults_scene(Main *bmain, Scene *scene)
|
||||
{
|
||||
ToolSettings *ts = scene->toolsettings;
|
||||
|
|
@ -470,6 +502,15 @@ static void blo_update_defaults_scene(Main *bmain, Scene *scene)
|
|||
if (ts->unified_paint_settings.curve_rand_value == nullptr) {
|
||||
ts->unified_paint_settings.curve_rand_value = BKE_paint_default_curve();
|
||||
}
|
||||
|
||||
blo_update_defaults_paint(reinterpret_cast<Paint *>(ts->vpaint));
|
||||
blo_update_defaults_paint(reinterpret_cast<Paint *>(ts->wpaint));
|
||||
blo_update_defaults_paint(reinterpret_cast<Paint *>(ts->sculpt));
|
||||
blo_update_defaults_paint(reinterpret_cast<Paint *>(ts->gp_paint));
|
||||
blo_update_defaults_paint(reinterpret_cast<Paint *>(ts->gp_vertexpaint));
|
||||
blo_update_defaults_paint(reinterpret_cast<Paint *>(ts->gp_sculptpaint));
|
||||
blo_update_defaults_paint(reinterpret_cast<Paint *>(ts->curves_sculpt));
|
||||
blo_update_defaults_paint(reinterpret_cast<Paint *>(&ts->imapaint));
|
||||
}
|
||||
|
||||
void BLO_update_defaults_startup_blend(Main *bmain, const char *app_template)
|
||||
|
|
|
|||
|
|
@ -368,7 +368,7 @@ static wmOperatorStatus grease_pencil_vertex_paint_set_exec(bContext *C, wmOpera
|
|||
eGP_vertex_SelectMaskFlag(scene.toolsettings->gpencil_selectmode_vertex));
|
||||
|
||||
float3 color_linear;
|
||||
srgb_to_linearrgb_v3_v3(color_linear, BKE_brush_color_get(&scene, &paint, &brush));
|
||||
srgb_to_linearrgb_v3_v3(color_linear, BKE_brush_color_get(&paint, &brush));
|
||||
const ColorGeometry4f target_color(color_linear[0], color_linear[1], color_linear[2], 1.0f);
|
||||
|
||||
std::atomic<bool> any_changed;
|
||||
|
|
|
|||
|
|
@ -539,7 +539,7 @@ static wmOperatorStatus weight_sample_invoke(bContext *C,
|
|||
/* Set the new brush weight. */
|
||||
const ToolSettings *ts = vc.scene->toolsettings;
|
||||
Brush *brush = BKE_paint_brush(&ts->gp_weightpaint->paint);
|
||||
BKE_brush_weight_set(vc.scene, brush, new_weight);
|
||||
BKE_brush_weight_set(&ts->gp_weightpaint->paint, brush, new_weight);
|
||||
|
||||
/* Update brush settings in UI. */
|
||||
WM_main_add_notifier(NC_BRUSH | NA_EDITED, nullptr);
|
||||
|
|
|
|||
|
|
@ -6646,20 +6646,19 @@ static int ui_do_but_COLOR(bContext *C, uiBut *but, uiHandleButtonData *data, co
|
|||
BKE_brush_tag_unsaved_changes(brush);
|
||||
}
|
||||
else {
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
bool updated = false;
|
||||
|
||||
if (but->rnaprop && RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA) {
|
||||
RNA_property_float_get_array_at_most(
|
||||
&but->rnapoin, but->rnaprop, color, ARRAY_SIZE(color));
|
||||
BKE_brush_color_set(scene, paint, brush, color);
|
||||
BKE_brush_color_set(paint, brush, color);
|
||||
updated = true;
|
||||
}
|
||||
else if (but->rnaprop && RNA_property_subtype(but->rnaprop) == PROP_COLOR) {
|
||||
RNA_property_float_get_array_at_most(
|
||||
&but->rnapoin, but->rnaprop, color, ARRAY_SIZE(color));
|
||||
IMB_colormanagement_scene_linear_to_srgb_v3(color, color);
|
||||
BKE_brush_color_set(scene, paint, brush, color);
|
||||
BKE_brush_color_set(paint, brush, color);
|
||||
updated = true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -395,14 +395,14 @@ static bool object_transfer_mode_poll(bContext *C)
|
|||
|
||||
/* Update the viewport rotation origin to the mouse cursor. */
|
||||
static void object_transfer_mode_reposition_view_pivot(ARegion *region,
|
||||
Scene *scene,
|
||||
Paint *paint,
|
||||
const int mval[2])
|
||||
{
|
||||
float global_loc[3];
|
||||
if (!ED_view3d_autodist_simple(region, mval, global_loc, 0, nullptr)) {
|
||||
return;
|
||||
}
|
||||
UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
|
||||
UnifiedPaintSettings *ups = &paint->unified_paint_settings;
|
||||
copy_v3_v3(ups->average_stroke_accum, global_loc);
|
||||
ups->average_stroke_counter = 1;
|
||||
ups->last_stroke_valid = true;
|
||||
|
|
@ -554,7 +554,8 @@ static wmOperatorStatus object_transfer_mode_invoke(bContext *C,
|
|||
|
||||
WM_toolsystem_update_from_context_view3d(C);
|
||||
if (mode_src & OB_MODE_ALL_PAINT) {
|
||||
object_transfer_mode_reposition_view_pivot(region, scene, event->mval);
|
||||
Paint *paint = BKE_paint_get_active_from_context(C);
|
||||
object_transfer_mode_reposition_view_pivot(region, paint, event->mval);
|
||||
}
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
|
|
|
|||
|
|
@ -71,12 +71,10 @@ void do_clay_thumb_brush(const Depsgraph &depsgraph,
|
|||
float clay_thumb_get_stabilized_pressure(const StrokeCache &cache);
|
||||
|
||||
void do_crease_brush(const Depsgraph &depsgraph,
|
||||
const Scene &scene,
|
||||
const Sculpt &sd,
|
||||
Object &ob,
|
||||
const IndexMask &node_mask);
|
||||
void do_blob_brush(const Depsgraph &depsgraph,
|
||||
const Scene &scene,
|
||||
const Sculpt &sd,
|
||||
Object &ob,
|
||||
const IndexMask &node_mask);
|
||||
|
|
|
|||
|
|
@ -185,7 +185,6 @@ static void calc_bmesh(const Depsgraph &depsgraph,
|
|||
}
|
||||
|
||||
static void do_crease_or_blob_brush(const Depsgraph &depsgraph,
|
||||
const Scene &scene,
|
||||
const Sculpt &sd,
|
||||
const bool invert_strength,
|
||||
Object &object,
|
||||
|
|
@ -202,7 +201,7 @@ static void do_crease_or_blob_brush(const Depsgraph &depsgraph,
|
|||
/* We divide out the squared alpha and multiply by the squared crease
|
||||
* to give us the pinch strength. */
|
||||
float crease_correction = brush.crease_pinch_factor * brush.crease_pinch_factor;
|
||||
float brush_alpha = BKE_brush_alpha_get(&scene, &brush);
|
||||
float brush_alpha = BKE_brush_alpha_get(&sd.paint, &brush);
|
||||
if (brush_alpha > 0.0f) {
|
||||
crease_correction /= brush_alpha * brush_alpha;
|
||||
}
|
||||
|
|
@ -264,21 +263,19 @@ static void do_crease_or_blob_brush(const Depsgraph &depsgraph,
|
|||
} // namespace crease_cc
|
||||
|
||||
void do_crease_brush(const Depsgraph &depsgraph,
|
||||
const Scene &scene,
|
||||
const Sculpt &sd,
|
||||
Object &object,
|
||||
const IndexMask &node_mask)
|
||||
{
|
||||
do_crease_or_blob_brush(depsgraph, scene, sd, false, object, node_mask);
|
||||
do_crease_or_blob_brush(depsgraph, sd, false, object, node_mask);
|
||||
}
|
||||
|
||||
void do_blob_brush(const Depsgraph &depsgraph,
|
||||
const Scene &scene,
|
||||
const Sculpt &sd,
|
||||
Object &object,
|
||||
const IndexMask &node_mask)
|
||||
{
|
||||
do_crease_or_blob_brush(depsgraph, scene, sd, true, object, node_mask);
|
||||
do_crease_or_blob_brush(depsgraph, sd, true, object, node_mask);
|
||||
}
|
||||
|
||||
} // namespace blender::ed::sculpt_paint::brushes
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ struct AddOperationExecutor {
|
|||
VArraySpan<float2> surface_uv_map_eval_;
|
||||
bke::BVHTreeFromMesh surface_bvh_eval_;
|
||||
|
||||
const CurvesSculpt *curves_sculpt_ = nullptr;
|
||||
CurvesSculpt *curves_sculpt_ = nullptr;
|
||||
const Brush *brush_ = nullptr;
|
||||
const BrushCurvesSculptSettings *brush_settings_ = nullptr;
|
||||
int add_amount_;
|
||||
|
|
@ -144,7 +144,7 @@ struct AddOperationExecutor {
|
|||
curves_sculpt_ = ctx_.scene->toolsettings->curves_sculpt;
|
||||
brush_ = BKE_paint_brush_for_read(&curves_sculpt_->paint);
|
||||
brush_settings_ = brush_->curves_sculpt_settings;
|
||||
brush_radius_re_ = brush_radius_get(*ctx_.scene, *brush_, stroke_extension);
|
||||
brush_radius_re_ = brush_radius_get(curves_sculpt_->paint, *brush_, stroke_extension);
|
||||
brush_pos_re_ = stroke_extension.mouse_position;
|
||||
|
||||
use_front_face_ = brush_->flag & BRUSH_FRONTFACE;
|
||||
|
|
@ -241,7 +241,8 @@ struct AddOperationExecutor {
|
|||
curves_orig_->positions().slice(add_outputs.new_points_range)))
|
||||
{
|
||||
remember_stroke_position(
|
||||
*ctx_.scene, math::transform_point(transforms_.curves_to_world, center_cu->center()));
|
||||
*curves_sculpt_,
|
||||
math::transform_point(transforms_.curves_to_world, center_cu->center()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -345,9 +345,9 @@ Vector<float4x4> get_symmetry_brush_transforms(const eCurvesSymmetryType symmetr
|
|||
return matrices;
|
||||
}
|
||||
|
||||
void remember_stroke_position(Scene &scene, const float3 &brush_position_wo)
|
||||
void remember_stroke_position(CurvesSculpt &curves_sculpt, const float3 &brush_position_wo)
|
||||
{
|
||||
UnifiedPaintSettings &ups = scene.toolsettings->unified_paint_settings;
|
||||
UnifiedPaintSettings &ups = curves_sculpt.paint.unified_paint_settings;
|
||||
copy_v3_v3(ups.average_stroke_accum, brush_position_wo);
|
||||
ups.average_stroke_counter = 1;
|
||||
ups.last_stroke_valid = true;
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ struct CombOperationExecutor {
|
|||
CombOperation *self_ = nullptr;
|
||||
CurvesSculptCommonContext ctx_;
|
||||
|
||||
const CurvesSculpt *curves_sculpt_ = nullptr;
|
||||
CurvesSculpt *curves_sculpt_ = nullptr;
|
||||
const Brush *brush_ = nullptr;
|
||||
float brush_radius_base_re_;
|
||||
float brush_radius_factor_;
|
||||
|
|
@ -113,9 +113,9 @@ struct CombOperationExecutor {
|
|||
|
||||
curves_sculpt_ = ctx_.scene->toolsettings->curves_sculpt;
|
||||
brush_ = BKE_paint_brush_for_read(&curves_sculpt_->paint);
|
||||
brush_radius_base_re_ = BKE_brush_size_get(ctx_.scene, brush_);
|
||||
brush_radius_base_re_ = BKE_brush_size_get(&curves_sculpt_->paint, brush_);
|
||||
brush_radius_factor_ = brush_radius_factor(*brush_, stroke_extension);
|
||||
brush_strength_ = brush_strength_get(*ctx_.scene, *brush_, stroke_extension);
|
||||
brush_strength_ = brush_strength_get(curves_sculpt_->paint, *brush_, stroke_extension);
|
||||
|
||||
const eBrushFalloffShape falloff_shape = eBrushFalloffShape(brush_->falloff_shape);
|
||||
|
||||
|
|
@ -388,7 +388,7 @@ struct CombOperationExecutor {
|
|||
if (brush_3d.has_value()) {
|
||||
self_->brush_3d_ = *brush_3d;
|
||||
remember_stroke_position(
|
||||
*ctx_.scene,
|
||||
*curves_sculpt_,
|
||||
math::transform_point(transforms_.curves_to_world, self_->brush_3d_.position_cu));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ struct DeleteOperationExecutor {
|
|||
IndexMaskMemory selected_curve_memory_;
|
||||
IndexMask curve_selection_;
|
||||
|
||||
const CurvesSculpt *curves_sculpt_ = nullptr;
|
||||
CurvesSculpt *curves_sculpt_ = nullptr;
|
||||
const Brush *brush_ = nullptr;
|
||||
float brush_radius_base_re_;
|
||||
float brush_radius_factor_;
|
||||
|
|
@ -89,7 +89,7 @@ struct DeleteOperationExecutor {
|
|||
|
||||
curves_sculpt_ = ctx_.scene->toolsettings->curves_sculpt;
|
||||
brush_ = BKE_paint_brush_for_read(&curves_sculpt_->paint);
|
||||
brush_radius_base_re_ = BKE_brush_size_get(ctx_.scene, brush_);
|
||||
brush_radius_base_re_ = BKE_brush_size_get(&curves_sculpt_->paint, brush_);
|
||||
brush_radius_factor_ = brush_radius_factor(*brush_, stroke_extension);
|
||||
|
||||
brush_pos_re_ = stroke_extension.mouse_position;
|
||||
|
|
@ -255,7 +255,7 @@ struct DeleteOperationExecutor {
|
|||
if (brush_3d.has_value()) {
|
||||
self_->brush_3d_ = *brush_3d;
|
||||
remember_stroke_position(
|
||||
*ctx_.scene,
|
||||
*curves_sculpt_,
|
||||
math::transform_point(transforms_.curves_to_world, self_->brush_3d_.position_cu));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ struct DensityAddOperationExecutor {
|
|||
VArraySpan<float2> surface_uv_map_eval_;
|
||||
bke::BVHTreeFromMesh surface_bvh_eval_;
|
||||
|
||||
const CurvesSculpt *curves_sculpt_ = nullptr;
|
||||
CurvesSculpt *curves_sculpt_ = nullptr;
|
||||
const Brush *brush_ = nullptr;
|
||||
const BrushCurvesSculptSettings *brush_settings_ = nullptr;
|
||||
|
||||
|
|
@ -153,8 +153,8 @@ struct DensityAddOperationExecutor {
|
|||
curves_sculpt_ = ctx_.scene->toolsettings->curves_sculpt;
|
||||
brush_ = BKE_paint_brush_for_read(&curves_sculpt_->paint);
|
||||
brush_settings_ = brush_->curves_sculpt_settings;
|
||||
brush_strength_ = brush_strength_get(*ctx_.scene, *brush_, stroke_extension);
|
||||
brush_radius_re_ = brush_radius_get(*ctx_.scene, *brush_, stroke_extension);
|
||||
brush_strength_ = brush_strength_get(curves_sculpt_->paint, *brush_, stroke_extension);
|
||||
brush_radius_re_ = brush_radius_get(curves_sculpt_->paint, *brush_, stroke_extension);
|
||||
brush_pos_re_ = stroke_extension.mouse_position;
|
||||
|
||||
const eBrushFalloffShape falloff_shape = eBrushFalloffShape(brush_->falloff_shape);
|
||||
|
|
@ -291,7 +291,8 @@ struct DensityAddOperationExecutor {
|
|||
curves_orig_->positions().slice(add_outputs.new_points_range)))
|
||||
{
|
||||
remember_stroke_position(
|
||||
*ctx_.scene, math::transform_point(transforms_.curves_to_world, center_cu->center()));
|
||||
*curves_sculpt_,
|
||||
math::transform_point(transforms_.curves_to_world, center_cu->center()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -560,9 +561,9 @@ struct DensitySubtractOperationExecutor {
|
|||
|
||||
curves_sculpt_ = ctx_.scene->toolsettings->curves_sculpt;
|
||||
brush_ = BKE_paint_brush_for_read(&curves_sculpt_->paint);
|
||||
brush_radius_base_re_ = BKE_brush_size_get(ctx_.scene, brush_);
|
||||
brush_radius_base_re_ = BKE_brush_size_get(&curves_sculpt_->paint, brush_);
|
||||
brush_radius_factor_ = brush_radius_factor(*brush_, stroke_extension);
|
||||
brush_strength_ = brush_strength_get(*ctx_.scene, *brush_, stroke_extension);
|
||||
brush_strength_ = brush_strength_get(curves_sculpt_->paint, *brush_, stroke_extension);
|
||||
brush_pos_re_ = stroke_extension.mouse_position;
|
||||
|
||||
minimum_distance_ = brush_->curves_sculpt_settings->minimum_distance;
|
||||
|
|
@ -801,6 +802,7 @@ static bool use_add_density_mode(const BrushStrokeMode brush_mode,
|
|||
const StrokeExtension &stroke_start)
|
||||
{
|
||||
const Scene &scene = *CTX_data_scene(&C);
|
||||
const Paint &paint = scene.toolsettings->curves_sculpt->paint;
|
||||
const Brush &brush = *BKE_paint_brush_for_read(&scene.toolsettings->curves_sculpt->paint);
|
||||
const Depsgraph &depsgraph = *CTX_data_depsgraph_on_load(&C);
|
||||
const ARegion ®ion = *CTX_wm_region(&C);
|
||||
|
|
@ -841,7 +843,7 @@ static bool use_add_density_mode(const BrushStrokeMode brush_mode,
|
|||
|
||||
const float2 brush_pos_re = stroke_start.mouse_position;
|
||||
/* Reduce radius so that only an inner circle is used to determine the existing density. */
|
||||
const float brush_radius_re = BKE_brush_size_get(&scene, &brush) * 0.5f;
|
||||
const float brush_radius_re = BKE_brush_size_get(&paint, &brush) * 0.5f;
|
||||
|
||||
/* Find the surface point under the brush. */
|
||||
const std::optional<CurvesBrush3D> brush_3d = sample_curves_surface_3d_brush(
|
||||
|
|
|
|||
|
|
@ -240,6 +240,7 @@ struct CurvesEffectOperationExecutor {
|
|||
IndexMaskMemory selected_curve_memory_;
|
||||
IndexMask curve_selection_;
|
||||
|
||||
CurvesSculpt *curves_sculpt_ = nullptr;
|
||||
const Brush *brush_ = nullptr;
|
||||
float brush_radius_base_re_;
|
||||
float brush_radius_factor_;
|
||||
|
|
@ -273,11 +274,11 @@ struct CurvesEffectOperationExecutor {
|
|||
".selection", bke::AttrDomain::Curve, 1.0f);
|
||||
curve_selection_ = curves::retrieve_selected_curves(*curves_id_, selected_curve_memory_);
|
||||
|
||||
const CurvesSculpt &curves_sculpt = *ctx_.scene->toolsettings->curves_sculpt;
|
||||
brush_ = BKE_paint_brush_for_read(&curves_sculpt.paint);
|
||||
brush_radius_base_re_ = BKE_brush_size_get(ctx_.scene, brush_);
|
||||
curves_sculpt_ = ctx_.scene->toolsettings->curves_sculpt;
|
||||
brush_ = BKE_paint_brush_for_read(&curves_sculpt_->paint);
|
||||
brush_radius_base_re_ = BKE_brush_size_get(&curves_sculpt_->paint, brush_);
|
||||
brush_radius_factor_ = brush_radius_factor(*brush_, stroke_extension);
|
||||
brush_strength_ = brush_strength_get(*ctx_.scene, *brush_, stroke_extension);
|
||||
brush_strength_ = brush_strength_get(curves_sculpt_->paint, *brush_, stroke_extension);
|
||||
|
||||
falloff_shape_ = eBrushFalloffShape(brush_->falloff_shape);
|
||||
|
||||
|
|
@ -299,7 +300,7 @@ struct CurvesEffectOperationExecutor {
|
|||
{
|
||||
self.brush_3d_ = *brush_3d;
|
||||
remember_stroke_position(
|
||||
*ctx_.scene,
|
||||
*curves_sculpt_,
|
||||
math::transform_point(transforms_.curves_to_world, self_->brush_3d_.position_cu));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@
|
|||
#include "BKE_attribute.hh"
|
||||
#include "BKE_crazyspace.hh"
|
||||
#include "BKE_curves.hh"
|
||||
#include "DNA_brush_types.h"
|
||||
#include "DNA_scene_types.h"
|
||||
|
||||
#include "ED_curves.hh"
|
||||
|
||||
|
|
@ -43,12 +45,12 @@ struct StrokeExtension {
|
|||
};
|
||||
|
||||
float brush_radius_factor(const Brush &brush, const StrokeExtension &stroke_extension);
|
||||
float brush_radius_get(const Scene &scene,
|
||||
float brush_radius_get(const Paint &paint,
|
||||
const Brush &brush,
|
||||
const StrokeExtension &stroke_extension);
|
||||
|
||||
float brush_strength_factor(const Brush &brush, const StrokeExtension &stroke_extension);
|
||||
float brush_strength_get(const Scene &scene,
|
||||
float brush_strength_get(const Paint &paint,
|
||||
const Brush &brush,
|
||||
const StrokeExtension &stroke_extension);
|
||||
|
||||
|
|
@ -97,7 +99,7 @@ std::optional<CurvesBrush3D> sample_curves_3d_brush(const Depsgraph &depsgraph,
|
|||
* Updates the position of the stroke so that it can be used by the orbit-around-selection
|
||||
* navigation method.
|
||||
*/
|
||||
void remember_stroke_position(Scene &scene, const float3 &brush_position_wo);
|
||||
void remember_stroke_position(CurvesSculpt &curves_sculpt, const float3 &brush_position_wo);
|
||||
|
||||
Vector<float4x4> get_symmetry_brush_transforms(eCurvesSymmetryType symmetry);
|
||||
|
||||
|
|
|
|||
|
|
@ -95,11 +95,11 @@ float brush_radius_factor(const Brush &brush, const StrokeExtension &stroke_exte
|
|||
return 1.0f;
|
||||
}
|
||||
|
||||
float brush_radius_get(const Scene &scene,
|
||||
float brush_radius_get(const Paint &paint,
|
||||
const Brush &brush,
|
||||
const StrokeExtension &stroke_extension)
|
||||
{
|
||||
return BKE_brush_size_get(&scene, &brush) * brush_radius_factor(brush, stroke_extension);
|
||||
return BKE_brush_size_get(&paint, &brush) * brush_radius_factor(brush, stroke_extension);
|
||||
}
|
||||
|
||||
float brush_strength_factor(const Brush &brush, const StrokeExtension &stroke_extension)
|
||||
|
|
@ -110,11 +110,11 @@ float brush_strength_factor(const Brush &brush, const StrokeExtension &stroke_ex
|
|||
return 1.0f;
|
||||
}
|
||||
|
||||
float brush_strength_get(const Scene &scene,
|
||||
float brush_strength_get(const Paint &paint,
|
||||
const Brush &brush,
|
||||
const StrokeExtension &stroke_extension)
|
||||
{
|
||||
return BKE_brush_alpha_get(&scene, &brush) * brush_strength_factor(brush, stroke_extension);
|
||||
return BKE_brush_alpha_get(&paint, &brush) * brush_strength_factor(brush, stroke_extension);
|
||||
}
|
||||
|
||||
static std::unique_ptr<CurvesSculptStrokeOperation> start_brush_operation(
|
||||
|
|
@ -309,7 +309,7 @@ static void curves_sculptmode_enter(bContext *C)
|
|||
paint->paint_cursor_col[3] = 128;
|
||||
|
||||
ED_paint_cursor_start(&curves_sculpt->paint, curves_sculpt_poll_view3d);
|
||||
paint_init_pivot(ob, scene);
|
||||
paint_init_pivot(ob, scene, paint);
|
||||
|
||||
/* Necessary to change the object mode on the evaluated object. */
|
||||
DEG_id_tag_update(&ob->id, ID_RECALC_SYNC_TO_EVAL);
|
||||
|
|
@ -871,11 +871,11 @@ struct MinDistanceEditData {
|
|||
|
||||
static int calculate_points_per_side(bContext *C, MinDistanceEditData &op_data)
|
||||
{
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
Paint *paint = BKE_paint_get_active_from_context(C);
|
||||
ARegion *region = op_data.region;
|
||||
|
||||
const float min_distance = op_data.brush->curves_sculpt_settings->minimum_distance;
|
||||
const float brush_radius = BKE_brush_size_get(scene, op_data.brush);
|
||||
const float brush_radius = BKE_brush_size_get(paint, op_data.brush);
|
||||
|
||||
float3 tangent_x_cu = math::cross(op_data.normal_cu, float3{0, 0, 1});
|
||||
if (math::is_zero(tangent_x_cu)) {
|
||||
|
|
@ -918,7 +918,7 @@ static void min_distance_edit_draw(bContext *C,
|
|||
const blender::float2 & /*tilt*/,
|
||||
void *customdata)
|
||||
{
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
Paint *paint = BKE_paint_get_active_from_context(C);
|
||||
MinDistanceEditData &op_data = *static_cast<MinDistanceEditData *>(customdata);
|
||||
|
||||
const float min_distance = op_data.brush->curves_sculpt_settings->minimum_distance;
|
||||
|
|
@ -948,7 +948,7 @@ static void min_distance_edit_draw(bContext *C,
|
|||
|
||||
float4 circle_col = float4(op_data.brush->add_col);
|
||||
float circle_alpha = op_data.brush->cursor_overlay_alpha;
|
||||
float brush_radius_re = BKE_brush_size_get(scene, op_data.brush);
|
||||
float brush_radius_re = BKE_brush_size_get(paint, op_data.brush);
|
||||
|
||||
/* Draw the grid. */
|
||||
GPU_matrix_push();
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ struct PinchOperationExecutor {
|
|||
|
||||
CurvesSurfaceTransforms transforms_;
|
||||
|
||||
const CurvesSculpt *curves_sculpt_ = nullptr;
|
||||
CurvesSculpt *curves_sculpt_ = nullptr;
|
||||
const Brush *brush_ = nullptr;
|
||||
float brush_radius_base_re_;
|
||||
float brush_radius_factor_;
|
||||
|
|
@ -93,9 +93,9 @@ struct PinchOperationExecutor {
|
|||
|
||||
curves_sculpt_ = ctx_.scene->toolsettings->curves_sculpt;
|
||||
brush_ = BKE_paint_brush_for_read(&curves_sculpt_->paint);
|
||||
brush_radius_base_re_ = BKE_brush_size_get(ctx_.scene, brush_);
|
||||
brush_radius_base_re_ = BKE_brush_size_get(&curves_sculpt_->paint, brush_);
|
||||
brush_radius_factor_ = brush_radius_factor(*brush_, stroke_extension);
|
||||
brush_strength_ = BKE_brush_alpha_get(ctx_.scene, brush_);
|
||||
brush_strength_ = BKE_brush_alpha_get(&curves_sculpt_->paint, brush_);
|
||||
|
||||
invert_factor_ = self_->invert_pinch_ ? -1.0f : 1.0f;
|
||||
|
||||
|
|
@ -118,7 +118,7 @@ struct PinchOperationExecutor {
|
|||
brush_pos_re_,
|
||||
brush_radius_base_re_);
|
||||
remember_stroke_position(
|
||||
*ctx_.scene,
|
||||
*curves_sculpt_,
|
||||
math::transform_point(transforms_.curves_to_world, self_->brush_3d_.position_cu));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ struct PuffOperationExecutor {
|
|||
IndexMaskMemory selected_curve_memory_;
|
||||
IndexMask curve_selection_;
|
||||
|
||||
const CurvesSculpt *curves_sculpt_ = nullptr;
|
||||
CurvesSculpt *curves_sculpt_ = nullptr;
|
||||
const Brush *brush_ = nullptr;
|
||||
float brush_radius_base_re_;
|
||||
float brush_radius_factor_;
|
||||
|
|
@ -97,9 +97,9 @@ struct PuffOperationExecutor {
|
|||
|
||||
curves_sculpt_ = ctx_.scene->toolsettings->curves_sculpt;
|
||||
brush_ = BKE_paint_brush_for_read(&curves_sculpt_->paint);
|
||||
brush_radius_base_re_ = BKE_brush_size_get(ctx_.scene, brush_);
|
||||
brush_radius_base_re_ = BKE_brush_size_get(&curves_sculpt_->paint, brush_);
|
||||
brush_radius_factor_ = brush_radius_factor(*brush_, stroke_extension);
|
||||
brush_strength_ = brush_strength_get(*ctx_.scene, *brush_, stroke_extension);
|
||||
brush_strength_ = brush_strength_get(curves_sculpt_->paint, *brush_, stroke_extension);
|
||||
brush_pos_re_ = stroke_extension.mouse_position;
|
||||
|
||||
point_factors_ = *curves_->attributes().lookup_or_default<float>(
|
||||
|
|
@ -129,7 +129,7 @@ struct PuffOperationExecutor {
|
|||
brush_pos_re_,
|
||||
brush_radius_base_re_);
|
||||
remember_stroke_position(
|
||||
*ctx_.scene,
|
||||
*curves_sculpt_,
|
||||
math::transform_point(transforms_.curves_to_world, self_->brush_3d_.position_cu));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@ struct SelectionPaintOperationExecutor {
|
|||
|
||||
bke::SpanAttributeWriter<float> selection_;
|
||||
|
||||
CurvesSculpt *curves_sculpt_ = nullptr;
|
||||
const Brush *brush_ = nullptr;
|
||||
float brush_radius_base_re_;
|
||||
float brush_radius_factor_;
|
||||
|
|
@ -93,10 +94,11 @@ struct SelectionPaintOperationExecutor {
|
|||
return;
|
||||
}
|
||||
|
||||
brush_ = BKE_paint_brush_for_read(&ctx_.scene->toolsettings->curves_sculpt->paint);
|
||||
brush_radius_base_re_ = BKE_brush_size_get(ctx_.scene, brush_);
|
||||
curves_sculpt_ = ctx_.scene->toolsettings->curves_sculpt;
|
||||
brush_ = BKE_paint_brush_for_read(&curves_sculpt_->paint);
|
||||
brush_radius_base_re_ = BKE_brush_size_get(&curves_sculpt_->paint, brush_);
|
||||
brush_radius_factor_ = brush_radius_factor(*brush_, stroke_extension);
|
||||
brush_strength_ = brush_strength_get(*ctx_.scene, *brush_, stroke_extension);
|
||||
brush_strength_ = brush_strength_get(curves_sculpt_->paint, *brush_, stroke_extension);
|
||||
|
||||
brush_pos_re_ = stroke_extension.mouse_position;
|
||||
|
||||
|
|
@ -376,7 +378,7 @@ struct SelectionPaintOperationExecutor {
|
|||
if (brush_3d.has_value()) {
|
||||
self_->brush_3d_ = *brush_3d;
|
||||
remember_stroke_position(
|
||||
*ctx_.scene,
|
||||
*curves_sculpt_,
|
||||
math::transform_point(transforms_.curves_to_world, self_->brush_3d_.position_cu));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ struct SlideOperationExecutor {
|
|||
SlideOperation *self_ = nullptr;
|
||||
CurvesSculptCommonContext ctx_;
|
||||
|
||||
const CurvesSculpt *curves_sculpt_ = nullptr;
|
||||
CurvesSculpt *curves_sculpt_ = nullptr;
|
||||
const Brush *brush_ = nullptr;
|
||||
float brush_radius_base_re_;
|
||||
float brush_radius_factor_;
|
||||
|
|
@ -146,9 +146,9 @@ struct SlideOperationExecutor {
|
|||
|
||||
curves_sculpt_ = ctx_.scene->toolsettings->curves_sculpt;
|
||||
brush_ = BKE_paint_brush_for_read(&curves_sculpt_->paint);
|
||||
brush_radius_base_re_ = BKE_brush_size_get(ctx_.scene, brush_);
|
||||
brush_radius_base_re_ = BKE_brush_size_get(&curves_sculpt_->paint, brush_);
|
||||
brush_radius_factor_ = brush_radius_factor(*brush_, stroke_extension);
|
||||
brush_strength_ = BKE_brush_alpha_get(ctx_.scene, brush_);
|
||||
brush_strength_ = BKE_brush_alpha_get(&curves_sculpt_->paint, brush_);
|
||||
|
||||
curve_factors_ = *curves_orig_->attributes().lookup_or_default(
|
||||
".selection", bke::AttrDomain::Curve, 1.0f);
|
||||
|
|
@ -236,7 +236,8 @@ struct SlideOperationExecutor {
|
|||
return;
|
||||
}
|
||||
remember_stroke_position(
|
||||
*ctx_.scene, math::transform_point(transforms_.curves_to_world, brush_3d->position_cu));
|
||||
*curves_sculpt_,
|
||||
math::transform_point(transforms_.curves_to_world, brush_3d->position_cu));
|
||||
|
||||
const ReverseUVSampler reverse_uv_sampler_orig{surface_uv_map_orig_,
|
||||
surface_corner_tris_orig_};
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ struct SmoothOperationExecutor {
|
|||
IndexMaskMemory selected_curve_memory_;
|
||||
IndexMask curve_selection_;
|
||||
|
||||
const CurvesSculpt *curves_sculpt_ = nullptr;
|
||||
CurvesSculpt *curves_sculpt_ = nullptr;
|
||||
const Brush *brush_ = nullptr;
|
||||
float brush_radius_base_re_;
|
||||
float brush_radius_factor_;
|
||||
|
|
@ -74,9 +74,9 @@ struct SmoothOperationExecutor {
|
|||
|
||||
curves_sculpt_ = ctx_.scene->toolsettings->curves_sculpt;
|
||||
brush_ = BKE_paint_brush_for_read(&curves_sculpt_->paint);
|
||||
brush_radius_base_re_ = BKE_brush_size_get(ctx_.scene, brush_);
|
||||
brush_radius_base_re_ = BKE_brush_size_get(&curves_sculpt_->paint, brush_);
|
||||
brush_radius_factor_ = brush_radius_factor(*brush_, stroke_extension);
|
||||
brush_strength_ = brush_strength_get(*ctx_.scene, *brush_, stroke_extension);
|
||||
brush_strength_ = brush_strength_get(curves_sculpt_->paint, *brush_, stroke_extension);
|
||||
brush_pos_re_ = stroke_extension.mouse_position;
|
||||
|
||||
point_factors_ = *curves_->attributes().lookup_or_default<float>(
|
||||
|
|
@ -95,7 +95,7 @@ struct SmoothOperationExecutor {
|
|||
brush_pos_re_,
|
||||
brush_radius_base_re_);
|
||||
remember_stroke_position(
|
||||
*ctx_.scene,
|
||||
*curves_sculpt_,
|
||||
math::transform_point(transforms_.curves_to_world, self_->brush_3d_.position_cu));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ struct SnakeHookOperatorExecutor {
|
|||
SnakeHookOperation *self_ = nullptr;
|
||||
CurvesSculptCommonContext ctx_;
|
||||
|
||||
const CurvesSculpt *curves_sculpt_ = nullptr;
|
||||
CurvesSculpt *curves_sculpt_ = nullptr;
|
||||
const Brush *brush_ = nullptr;
|
||||
float brush_radius_base_re_;
|
||||
float brush_radius_factor_;
|
||||
|
|
@ -98,9 +98,9 @@ struct SnakeHookOperatorExecutor {
|
|||
curves_sculpt_ = ctx_.scene->toolsettings->curves_sculpt;
|
||||
brush_ = BKE_paint_brush_for_read(&curves_sculpt_->paint);
|
||||
|
||||
brush_radius_base_re_ = BKE_brush_size_get(ctx_.scene, brush_);
|
||||
brush_radius_base_re_ = BKE_brush_size_get(&curves_sculpt_->paint, brush_);
|
||||
brush_radius_factor_ = brush_radius_factor(*brush_, stroke_extension);
|
||||
brush_strength_ = brush_strength_get(*ctx_.scene, *brush_, stroke_extension);
|
||||
brush_strength_ = brush_strength_get(curves_sculpt_->paint, *brush_, stroke_extension);
|
||||
|
||||
const eBrushFalloffShape falloff_shape = eBrushFalloffShape(brush_->falloff_shape);
|
||||
|
||||
|
|
@ -132,7 +132,7 @@ struct SnakeHookOperatorExecutor {
|
|||
if (brush_3d.has_value()) {
|
||||
self_->brush_3d_ = *brush_3d;
|
||||
remember_stroke_position(
|
||||
*ctx_.scene,
|
||||
*curves_sculpt_,
|
||||
math::transform_point(transforms_.curves_to_world, self_->brush_3d_.position_cu));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,13 +52,13 @@ Vector<ed::greasepencil::MutableDrawingInfo> get_drawings_for_stroke_operation(c
|
|||
Vector<ed::greasepencil::MutableDrawingInfo> get_drawings_with_masking_for_stroke_operation(
|
||||
const bContext &C);
|
||||
/* Get the brush radius accounting for pen pressure. */
|
||||
float brush_radius(const Scene &scene, const Brush &brush, float pressure);
|
||||
float brush_radius(const Paint &paint, const Brush &brush, float pressure);
|
||||
|
||||
/* Make sure the brush has all necessary grease pencil settings. */
|
||||
void init_brush(Brush &brush);
|
||||
|
||||
/* Index mask of all points within the brush radius. */
|
||||
IndexMask brush_point_influence_mask(const Scene &scene,
|
||||
IndexMask brush_point_influence_mask(const Paint &paint,
|
||||
const Brush &brush,
|
||||
const float2 &mouse_position,
|
||||
float pressure,
|
||||
|
|
@ -69,7 +69,7 @@ IndexMask brush_point_influence_mask(const Scene &scene,
|
|||
IndexMaskMemory &memory);
|
||||
|
||||
/* Influence value at point co for the brush. */
|
||||
float brush_point_influence(const Scene &scene,
|
||||
float brush_point_influence(const Paint &paint,
|
||||
const Brush &brush,
|
||||
const float2 &co,
|
||||
const InputSample &sample,
|
||||
|
|
@ -81,7 +81,7 @@ float brush_point_influence(const Scene &scene,
|
|||
*/
|
||||
float closest_distance_to_surface_2d(const float2 pt, const Span<float2> verts);
|
||||
/* Influence value for an entire fill. */
|
||||
float brush_fill_influence(const Scene &scene,
|
||||
float brush_fill_influence(const Paint &paint,
|
||||
const Brush &brush,
|
||||
Span<float2> fill_positions,
|
||||
const InputSample &sample,
|
||||
|
|
|
|||
|
|
@ -85,25 +85,25 @@ void init_brush(Brush &brush)
|
|||
BKE_curvemapping_init(brush.gpencil_settings->curve_rand_value);
|
||||
}
|
||||
|
||||
float brush_radius(const Scene &scene, const Brush &brush, const float pressure = 1.0f)
|
||||
float brush_radius(const Paint &paint, const Brush &brush, const float pressure = 1.0f)
|
||||
{
|
||||
float radius = BKE_brush_size_get(&scene, &brush);
|
||||
float radius = BKE_brush_size_get(&paint, &brush);
|
||||
if (BKE_brush_use_size_pressure(&brush)) {
|
||||
radius *= BKE_curvemapping_evaluateF(brush.gpencil_settings->curve_sensitivity, 0, pressure);
|
||||
}
|
||||
return radius;
|
||||
}
|
||||
|
||||
float brush_point_influence(const Scene &scene,
|
||||
float brush_point_influence(const Paint &paint,
|
||||
const Brush &brush,
|
||||
const float2 &co,
|
||||
const InputSample &sample,
|
||||
const float multi_frame_falloff)
|
||||
{
|
||||
const float radius = brush_radius(scene, brush, sample.pressure);
|
||||
const float radius = brush_radius(paint, brush, sample.pressure);
|
||||
/* Basic strength factor from brush settings. */
|
||||
const float brush_pressure = BKE_brush_use_alpha_pressure(&brush) ? sample.pressure : 1.0f;
|
||||
const float influence_base = BKE_brush_alpha_get(&scene, &brush) * brush_pressure *
|
||||
const float influence_base = BKE_brush_alpha_get(&paint, &brush) * brush_pressure *
|
||||
multi_frame_falloff;
|
||||
|
||||
/* Distance falloff. */
|
||||
|
|
@ -133,16 +133,16 @@ float closest_distance_to_surface_2d(const float2 pt, const Span<float2> verts)
|
|||
return isect ? 0.0f : distance;
|
||||
}
|
||||
|
||||
float brush_fill_influence(const Scene &scene,
|
||||
float brush_fill_influence(const Paint &paint,
|
||||
const Brush &brush,
|
||||
const Span<float2> fill_positions,
|
||||
const InputSample &sample,
|
||||
const float multi_frame_falloff)
|
||||
{
|
||||
const float radius = brush_radius(scene, brush, sample.pressure);
|
||||
const float radius = brush_radius(paint, brush, sample.pressure);
|
||||
/* Basic strength factor from brush settings. */
|
||||
const float brush_pressure = BKE_brush_use_alpha_pressure(&brush) ? sample.pressure : 1.0f;
|
||||
const float influence_base = BKE_brush_alpha_get(&scene, &brush) * brush_pressure *
|
||||
const float influence_base = BKE_brush_alpha_get(&paint, &brush) * brush_pressure *
|
||||
multi_frame_falloff;
|
||||
|
||||
/* Distance falloff. */
|
||||
|
|
@ -153,7 +153,7 @@ float brush_fill_influence(const Scene &scene,
|
|||
return influence_base * brush_falloff;
|
||||
}
|
||||
|
||||
IndexMask brush_point_influence_mask(const Scene &scene,
|
||||
IndexMask brush_point_influence_mask(const Paint &paint,
|
||||
const Brush &brush,
|
||||
const float2 &mouse_position,
|
||||
const float pressure,
|
||||
|
|
@ -167,10 +167,10 @@ IndexMask brush_point_influence_mask(const Scene &scene,
|
|||
return {};
|
||||
}
|
||||
|
||||
const float radius = brush_radius(scene, brush, pressure);
|
||||
const float radius = brush_radius(paint, brush, pressure);
|
||||
const float radius_squared = radius * radius;
|
||||
const float brush_pressure = BKE_brush_use_alpha_pressure(&brush) ? pressure : 1.0f;
|
||||
const float influence_base = BKE_brush_alpha_get(&scene, &brush) * brush_pressure *
|
||||
const float influence_base = BKE_brush_alpha_get(&paint, &brush) * brush_pressure *
|
||||
multi_frame_falloff;
|
||||
const int2 mval_i = int2(math::round(mouse_position));
|
||||
|
||||
|
|
|
|||
|
|
@ -158,7 +158,7 @@ void GrabOperation::on_stroke_begin(const bContext &C, const InputSample &start_
|
|||
|
||||
/* Cache points under brush influence. */
|
||||
Vector<float> weights;
|
||||
IndexMask point_mask = brush_point_influence_mask(scene,
|
||||
IndexMask point_mask = brush_point_influence_mask(paint,
|
||||
brush,
|
||||
start_sample.mouse_position,
|
||||
1.0f,
|
||||
|
|
|
|||
|
|
@ -36,7 +36,6 @@ void PinchOperation::on_stroke_begin(const bContext &C, const InputSample &start
|
|||
|
||||
void PinchOperation::on_stroke_extended(const bContext &C, const InputSample &extension_sample)
|
||||
{
|
||||
const Scene &scene = *CTX_data_scene(&C);
|
||||
Paint &paint = *BKE_paint_get_active_from_context(&C);
|
||||
const Brush &brush = *BKE_paint_brush(&paint);
|
||||
const bool invert = this->is_inverted(brush);
|
||||
|
|
@ -56,7 +55,7 @@ void PinchOperation::on_stroke_extended(const bContext &C, const InputSample &ex
|
|||
point_mask.foreach_index(GrainSize(4096), [&](const int64_t point_i) {
|
||||
const float2 &co = view_positions[point_i];
|
||||
const float influence = brush_point_influence(
|
||||
scene, brush, co, extension_sample, params.multi_frame_falloff);
|
||||
paint, brush, co, extension_sample, params.multi_frame_falloff);
|
||||
if (influence <= 0.0f) {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,6 @@ void PushOperation::on_stroke_begin(const bContext &C, const InputSample &start_
|
|||
|
||||
void PushOperation::on_stroke_extended(const bContext &C, const InputSample &extension_sample)
|
||||
{
|
||||
const Scene &scene = *CTX_data_scene(&C);
|
||||
Paint &paint = *BKE_paint_get_active_from_context(&C);
|
||||
const Brush &brush = *BKE_paint_brush(&paint);
|
||||
|
||||
|
|
@ -55,7 +54,7 @@ void PushOperation::on_stroke_extended(const bContext &C, const InputSample &ext
|
|||
point_mask.foreach_index(GrainSize(4096), [&](const int64_t point_i) {
|
||||
const float2 &co = view_positions[point_i];
|
||||
const float influence = brush_point_influence(
|
||||
scene, brush, co, extension_sample, params.multi_frame_falloff);
|
||||
paint, brush, co, extension_sample, params.multi_frame_falloff);
|
||||
if (influence <= 0.0f) {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,7 +57,6 @@ void RandomizeOperation::on_stroke_begin(const bContext &C, const InputSample &s
|
|||
|
||||
void RandomizeOperation::on_stroke_extended(const bContext &C, const InputSample &extension_sample)
|
||||
{
|
||||
const Scene &scene = *CTX_data_scene(&C);
|
||||
Paint &paint = *BKE_paint_get_active_from_context(&C);
|
||||
const Brush &brush = *BKE_paint_brush(&paint);
|
||||
const int sculpt_mode_flag = brush.gpencil_settings->sculpt_mode_flag;
|
||||
|
|
@ -85,7 +84,7 @@ void RandomizeOperation::on_stroke_extended(const bContext &C, const InputSample
|
|||
point_mask.foreach_index(GrainSize(4096), [&](const int64_t point_i) {
|
||||
const float2 &co = view_positions[point_i];
|
||||
const float influence = brush_point_influence(
|
||||
scene, brush, co, extension_sample, params.multi_frame_falloff);
|
||||
paint, brush, co, extension_sample, params.multi_frame_falloff);
|
||||
if (influence <= 0.0f) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -102,7 +101,7 @@ void RandomizeOperation::on_stroke_extended(const bContext &C, const InputSample
|
|||
point_mask.foreach_index(GrainSize(4096), [&](const int64_t point_i) {
|
||||
const float2 &co = view_positions[point_i];
|
||||
const float influence = brush_point_influence(
|
||||
scene, brush, co, extension_sample, params.multi_frame_falloff);
|
||||
paint, brush, co, extension_sample, params.multi_frame_falloff);
|
||||
if (influence <= 0.0f) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -116,7 +115,7 @@ void RandomizeOperation::on_stroke_extended(const bContext &C, const InputSample
|
|||
point_mask.foreach_index(GrainSize(4096), [&](const int64_t point_i) {
|
||||
const float2 &co = view_positions[point_i];
|
||||
const float influence = brush_point_influence(
|
||||
scene, brush, co, extension_sample, params.multi_frame_falloff);
|
||||
paint, brush, co, extension_sample, params.multi_frame_falloff);
|
||||
if (influence <= 0.0f) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -134,7 +133,7 @@ void RandomizeOperation::on_stroke_extended(const bContext &C, const InputSample
|
|||
point_mask.foreach_index(GrainSize(4096), [&](const int64_t point_i) {
|
||||
const float2 &co = view_positions[point_i];
|
||||
const float influence = brush_point_influence(
|
||||
scene, brush, co, extension_sample, params.multi_frame_falloff);
|
||||
paint, brush, co, extension_sample, params.multi_frame_falloff);
|
||||
if (influence <= 0.0f) {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,7 +55,6 @@ void SmoothOperation::toggle_smooth_brush_on(const bContext &C)
|
|||
{
|
||||
Paint *paint = BKE_paint_get_active_from_context(&C);
|
||||
Main *bmain = CTX_data_main(&C);
|
||||
Scene *scene = CTX_data_scene(&C);
|
||||
Brush *current_brush = BKE_paint_brush(paint);
|
||||
|
||||
if (current_brush->sculpt_brush_type == SCULPT_BRUSH_TYPE_MASK) {
|
||||
|
|
@ -72,10 +71,10 @@ void SmoothOperation::toggle_smooth_brush_on(const bContext &C)
|
|||
init_brush(*smooth_brush);
|
||||
|
||||
saved_active_brush_ = current_brush;
|
||||
saved_smooth_size_ = BKE_brush_size_get(scene, smooth_brush);
|
||||
saved_smooth_size_ = BKE_brush_size_get(paint, smooth_brush);
|
||||
|
||||
const int current_brush_size = BKE_brush_size_get(scene, current_brush);
|
||||
BKE_brush_size_set(scene, smooth_brush, current_brush_size);
|
||||
const int current_brush_size = BKE_brush_size_get(paint, current_brush);
|
||||
BKE_brush_size_set(paint, smooth_brush, current_brush_size);
|
||||
BKE_curvemapping_init(smooth_brush->curve);
|
||||
}
|
||||
|
||||
|
|
@ -92,8 +91,7 @@ void SmoothOperation::toggle_smooth_brush_off(const bContext &C)
|
|||
/* If saved_active_brush is not set, brush was not switched/affected in
|
||||
* toggle_temp_on(). */
|
||||
if (saved_active_brush_) {
|
||||
Scene *scene = CTX_data_scene(&C);
|
||||
BKE_brush_size_set(scene, &brush, saved_smooth_size_);
|
||||
BKE_brush_size_set(paint, &brush, saved_smooth_size_);
|
||||
BKE_paint_brush_set(paint, saved_active_brush_);
|
||||
saved_active_brush_ = nullptr;
|
||||
}
|
||||
|
|
@ -114,7 +112,7 @@ void SmoothOperation::on_stroke_begin(const bContext &C, const InputSample &star
|
|||
|
||||
void SmoothOperation::on_stroke_extended(const bContext &C, const InputSample &extension_sample)
|
||||
{
|
||||
const Scene &scene = *CTX_data_scene(&C);
|
||||
Paint &paint = *BKE_paint_get_active_from_context(&C);
|
||||
const Brush &brush = [&]() -> const Brush & {
|
||||
if (temp_smooth_) {
|
||||
const Brush *brush = BKE_paint_brush_from_essentials(
|
||||
|
|
@ -122,7 +120,6 @@ void SmoothOperation::on_stroke_extended(const bContext &C, const InputSample &e
|
|||
BLI_assert(brush != nullptr);
|
||||
return *brush;
|
||||
}
|
||||
Paint &paint = *BKE_paint_get_active_from_context(&C);
|
||||
return *BKE_paint_brush(&paint);
|
||||
}();
|
||||
const int sculpt_mode_flag = brush.gpencil_settings->sculpt_mode_flag;
|
||||
|
|
@ -138,7 +135,7 @@ void SmoothOperation::on_stroke_extended(const bContext &C, const InputSample &e
|
|||
|
||||
const VArray<float> influences = VArray<float>::ForFunc(
|
||||
view_positions.size(), [&](const int64_t point_) {
|
||||
return brush_point_influence(scene,
|
||||
return brush_point_influence(paint,
|
||||
brush,
|
||||
view_positions[point_],
|
||||
extension_sample,
|
||||
|
|
|
|||
|
|
@ -37,7 +37,6 @@ void StrengthOperation::on_stroke_begin(const bContext &C, const InputSample &st
|
|||
|
||||
void StrengthOperation::on_stroke_extended(const bContext &C, const InputSample &extension_sample)
|
||||
{
|
||||
const Scene &scene = *CTX_data_scene(&C);
|
||||
Paint &paint = *BKE_paint_get_active_from_context(&C);
|
||||
const Brush &brush = *BKE_paint_brush(&paint);
|
||||
const bool invert = this->is_inverted(brush);
|
||||
|
|
@ -50,7 +49,7 @@ void StrengthOperation::on_stroke_extended(const bContext &C, const InputSample
|
|||
point_mask.foreach_index(GrainSize(4096), [&](const int64_t point_i) {
|
||||
float &opacity = opacities[point_i];
|
||||
const float influence = brush_point_influence(
|
||||
scene, brush, view_positions[point_i], extension_sample, params.multi_frame_falloff);
|
||||
paint, brush, view_positions[point_i], extension_sample, params.multi_frame_falloff);
|
||||
/* Brush influence mapped to opacity by a factor of 0.125. */
|
||||
const float delta_opacity = (invert ? -influence : influence) * 0.125f;
|
||||
opacity = std::clamp(opacity + delta_opacity, 0.0f, 1.0f);
|
||||
|
|
|
|||
|
|
@ -37,7 +37,6 @@ void ThicknessOperation::on_stroke_begin(const bContext &C, const InputSample &s
|
|||
|
||||
void ThicknessOperation::on_stroke_extended(const bContext &C, const InputSample &extension_sample)
|
||||
{
|
||||
const Scene &scene = *CTX_data_scene(&C);
|
||||
Paint &paint = *BKE_paint_get_active_from_context(&C);
|
||||
const Brush &brush = *BKE_paint_brush(&paint);
|
||||
const bool invert = this->is_inverted(brush);
|
||||
|
|
@ -52,7 +51,7 @@ void ThicknessOperation::on_stroke_extended(const bContext &C, const InputSample
|
|||
point_mask.foreach_index(GrainSize(4096), [&](const int64_t point_i) {
|
||||
float &radius = radii[point_i];
|
||||
const float influence = brush_point_influence(
|
||||
scene, brush, view_positions[point_i], extension_sample, params.multi_frame_falloff);
|
||||
paint, brush, view_positions[point_i], extension_sample, params.multi_frame_falloff);
|
||||
/* Factor 1/1000 is used to map arbitrary influence value to a sensible radius. */
|
||||
const float delta_radius = (invert ? -influence : influence) * 0.001f;
|
||||
radius = std::max(radius + delta_radius, 0.0f);
|
||||
|
|
|
|||
|
|
@ -45,7 +45,6 @@ void TwistOperation::on_stroke_begin(const bContext &C, const InputSample &start
|
|||
|
||||
void TwistOperation::on_stroke_extended(const bContext &C, const InputSample &extension_sample)
|
||||
{
|
||||
const Scene &scene = *CTX_data_scene(&C);
|
||||
Paint &paint = *BKE_paint_get_active_from_context(&C);
|
||||
const Brush &brush = *BKE_paint_brush(&paint);
|
||||
const bool invert = this->is_inverted(brush);
|
||||
|
|
@ -65,7 +64,7 @@ void TwistOperation::on_stroke_extended(const bContext &C, const InputSample &ex
|
|||
point_mask.foreach_index(GrainSize(4096), [&](const int64_t point_i) {
|
||||
const float2 &co = view_positions[point_i];
|
||||
const float influence = brush_point_influence(
|
||||
scene, brush, co, extension_sample, params.multi_frame_falloff);
|
||||
paint, brush, co, extension_sample, params.multi_frame_falloff);
|
||||
if (influence <= 0.0f) {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ void TintOperation::on_stroke_begin(const bContext &C, const InputSample & /*sta
|
|||
|
||||
float4 color_linear;
|
||||
color_linear[3] = 1.0f;
|
||||
srgb_to_linearrgb_v3_v3(color_linear, BKE_brush_color_get(scene, paint, brush));
|
||||
srgb_to_linearrgb_v3_v3(color_linear, BKE_brush_color_get(paint, brush));
|
||||
|
||||
color_ = ColorGeometry4f(color_linear);
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ void VertexAverageOperation::on_stroke_extended(const bContext &C,
|
|||
const Scene &scene = *CTX_data_scene(&C);
|
||||
Paint &paint = *BKE_paint_get_active_from_context(&C);
|
||||
const Brush &brush = *BKE_paint_brush(&paint);
|
||||
const float radius = brush_radius(scene, brush, extension_sample.pressure);
|
||||
const float radius = brush_radius(paint, brush, extension_sample.pressure);
|
||||
const float radius_squared = radius * radius;
|
||||
|
||||
const bool use_selection_masking = GPENCIL_ANY_VERTEX_MASK(
|
||||
|
|
@ -104,7 +104,7 @@ void VertexAverageOperation::on_stroke_extended(const bContext &C,
|
|||
|
||||
point_selection.foreach_index(GrainSize(4096), [&](const int64_t point_i) {
|
||||
const float influence = brush_point_influence(
|
||||
scene, brush, view_positions[point_i], extension_sample, params.multi_frame_falloff);
|
||||
paint, brush, view_positions[point_i], extension_sample, params.multi_frame_falloff);
|
||||
|
||||
ColorGeometry4f &color = vertex_colors[point_i];
|
||||
color = math::interpolate(color, mix_color, influence);
|
||||
|
|
@ -122,7 +122,7 @@ void VertexAverageOperation::on_stroke_extended(const bContext &C,
|
|||
const IndexRange points = points_by_curve[curve_i];
|
||||
const Span<float2> curve_view_positions = view_positions.as_span().slice(points);
|
||||
const float influence = brush_fill_influence(
|
||||
scene, brush, curve_view_positions, extension_sample, params.multi_frame_falloff);
|
||||
paint, brush, curve_view_positions, extension_sample, params.multi_frame_falloff);
|
||||
|
||||
ColorGeometry4f &color = fill_colors[curve_i];
|
||||
color = math::interpolate(color, mix_color, influence);
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ void VertexBlurOperation::on_stroke_extended(const bContext &C,
|
|||
const Scene &scene = *CTX_data_scene(&C);
|
||||
Paint &paint = *BKE_paint_get_active_from_context(&C);
|
||||
const Brush &brush = *BKE_paint_brush(&paint);
|
||||
const float radius = brush_radius(scene, brush, extension_sample.pressure);
|
||||
const float radius = brush_radius(paint, brush, extension_sample.pressure);
|
||||
const float radius_squared = radius * radius;
|
||||
|
||||
const bool use_selection_masking = GPENCIL_ANY_VERTEX_MASK(
|
||||
|
|
@ -76,7 +76,7 @@ void VertexBlurOperation::on_stroke_extended(const bContext &C,
|
|||
|
||||
for (const int point : points) {
|
||||
const float influence = brush_point_influence(
|
||||
scene, brush, view_positions[point], extension_sample, params.multi_frame_falloff);
|
||||
paint, brush, view_positions[point], extension_sample, params.multi_frame_falloff);
|
||||
ColorGeometry4f &color = vertex_colors[point];
|
||||
if (color.a > 0.0f && influence > 0.0f) {
|
||||
color = math::interpolate(color, mix_color, influence);
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ void VertexPaintOperation::on_stroke_extended(const bContext &C,
|
|||
const bool do_fill = do_vertex_color_fill(brush);
|
||||
|
||||
float color_linear[3];
|
||||
srgb_to_linearrgb_v3_v3(color_linear, BKE_brush_color_get(&scene, &paint, &brush));
|
||||
srgb_to_linearrgb_v3_v3(color_linear, BKE_brush_color_get(&paint, &brush));
|
||||
const ColorGeometry4f mix_color(color_linear[0], color_linear[1], color_linear[2], 1.0f);
|
||||
|
||||
this->foreach_editable_drawing(C, GrainSize(1), [&](const GreasePencilStrokeParams ¶ms) {
|
||||
|
|
@ -61,7 +61,7 @@ void VertexPaintOperation::on_stroke_extended(const bContext &C,
|
|||
/* Erase vertex colors. */
|
||||
point_selection.foreach_index(GrainSize(4096), [&](const int64_t point_i) {
|
||||
const float influence = brush_point_influence(
|
||||
scene, brush, view_positions[point_i], extension_sample, params.multi_frame_falloff);
|
||||
paint, brush, view_positions[point_i], extension_sample, params.multi_frame_falloff);
|
||||
|
||||
ColorGeometry4f &color = vertex_colors[point_i];
|
||||
color.a -= influence;
|
||||
|
|
@ -72,7 +72,7 @@ void VertexPaintOperation::on_stroke_extended(const bContext &C,
|
|||
/* Mix brush color into vertex colors by influence using alpha over. */
|
||||
point_selection.foreach_index(GrainSize(4096), [&](const int64_t point_i) {
|
||||
const float influence = brush_point_influence(
|
||||
scene, brush, view_positions[point_i], extension_sample, params.multi_frame_falloff);
|
||||
paint, brush, view_positions[point_i], extension_sample, params.multi_frame_falloff);
|
||||
|
||||
ColorGeometry4f &color = vertex_colors[point_i];
|
||||
color = math::interpolate(color, mix_color, influence);
|
||||
|
|
@ -92,7 +92,7 @@ void VertexPaintOperation::on_stroke_extended(const bContext &C,
|
|||
const IndexRange points = points_by_curve[curve_i];
|
||||
const Span<float2> curve_view_positions = view_positions.as_span().slice(points);
|
||||
const float influence = brush_fill_influence(
|
||||
scene, brush, curve_view_positions, extension_sample, params.multi_frame_falloff);
|
||||
paint, brush, curve_view_positions, extension_sample, params.multi_frame_falloff);
|
||||
|
||||
ColorGeometry4f &color = fill_colors[curve_i];
|
||||
color.a -= influence;
|
||||
|
|
@ -104,7 +104,7 @@ void VertexPaintOperation::on_stroke_extended(const bContext &C,
|
|||
const IndexRange points = points_by_curve[curve_i];
|
||||
const Span<float2> curve_view_positions = view_positions.as_span().slice(points);
|
||||
const float influence = brush_fill_influence(
|
||||
scene, brush, curve_view_positions, extension_sample, params.multi_frame_falloff);
|
||||
paint, brush, curve_view_positions, extension_sample, params.multi_frame_falloff);
|
||||
|
||||
ColorGeometry4f &color = fill_colors[curve_i];
|
||||
color = math::interpolate(color, mix_color, influence);
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ void VertexReplaceOperation::on_stroke_extended(const bContext &C,
|
|||
const bool do_fill = do_vertex_color_fill(brush);
|
||||
|
||||
float3 color_linear;
|
||||
srgb_to_linearrgb_v3_v3(color_linear, BKE_brush_color_get(&scene, &paint, &brush));
|
||||
srgb_to_linearrgb_v3_v3(color_linear, BKE_brush_color_get(&paint, &brush));
|
||||
const ColorGeometry4f replace_color(color_linear.x, color_linear.y, color_linear.z, 1.0f);
|
||||
|
||||
this->foreach_editable_drawing(C, GrainSize(1), [&](const GreasePencilStrokeParams ¶ms) {
|
||||
|
|
@ -55,7 +55,7 @@ void VertexReplaceOperation::on_stroke_extended(const bContext &C,
|
|||
MutableSpan<ColorGeometry4f> vertex_colors = params.drawing.vertex_colors_for_write();
|
||||
point_selection.foreach_index(GrainSize(4096), [&](const int64_t point_i) {
|
||||
const float influence = brush_point_influence(
|
||||
scene, brush, view_positions[point_i], extension_sample, params.multi_frame_falloff);
|
||||
paint, brush, view_positions[point_i], extension_sample, params.multi_frame_falloff);
|
||||
if (influence > 0.0f && vertex_colors[point_i].a > 0.0f) {
|
||||
vertex_colors[point_i] = replace_color;
|
||||
}
|
||||
|
|
@ -73,7 +73,7 @@ void VertexReplaceOperation::on_stroke_extended(const bContext &C,
|
|||
const IndexRange points = points_by_curve[curve_i];
|
||||
const Span<float2> curve_view_positions = view_positions.as_span().slice(points);
|
||||
const float influence = brush_fill_influence(
|
||||
scene, brush, curve_view_positions, extension_sample, params.multi_frame_falloff);
|
||||
paint, brush, curve_view_positions, extension_sample, params.multi_frame_falloff);
|
||||
if (influence > 0.0f && fill_colors[curve_i].a > 0.0f) {
|
||||
fill_colors[curve_i] = replace_color;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ void VertexSmearOperation::init_color_grid(const bContext &C, const float2 start
|
|||
const Brush &brush = *BKE_paint_brush(&paint);
|
||||
const bool use_selection_masking = GPENCIL_ANY_VERTEX_MASK(
|
||||
eGP_vertex_SelectMaskFlag(scene.toolsettings->gpencil_selectmode_vertex));
|
||||
const float radius = brush_radius(scene, brush, 1.0f);
|
||||
const float radius = brush_radius(paint, brush, 1.0f);
|
||||
|
||||
/* Setup grid values. */
|
||||
/* TODO: Make this a setting. */
|
||||
|
|
@ -153,7 +153,7 @@ void VertexSmearOperation::on_stroke_extended(const bContext &C,
|
|||
const Scene &scene = *CTX_data_scene(&C);
|
||||
Paint &paint = *BKE_paint_get_active_from_context(&C);
|
||||
const Brush &brush = *BKE_paint_brush(&paint);
|
||||
const float radius = brush_radius(scene, brush, extension_sample.pressure);
|
||||
const float radius = brush_radius(paint, brush, extension_sample.pressure);
|
||||
|
||||
const bool use_selection_masking = GPENCIL_ANY_VERTEX_MASK(
|
||||
eGP_vertex_SelectMaskFlag(scene.toolsettings->gpencil_selectmode_vertex));
|
||||
|
|
@ -178,7 +178,7 @@ void VertexSmearOperation::on_stroke_extended(const bContext &C,
|
|||
|
||||
const float distance_falloff = math::clamp(
|
||||
1.0f - (math::distance(color_grid_.center, view_pos) / radius * 2), 0.0f, 1.0f);
|
||||
const float influence = brush_point_influence(scene,
|
||||
const float influence = brush_point_influence(paint,
|
||||
brush,
|
||||
view_pos,
|
||||
extension_sample,
|
||||
|
|
|
|||
|
|
@ -125,16 +125,15 @@ class WeightPaintOperation : public GreasePencilStrokeOperation {
|
|||
{
|
||||
using namespace blender::ed::greasepencil;
|
||||
|
||||
const Scene *scene = CTX_data_scene(&C);
|
||||
this->object = CTX_data_active_object(&C);
|
||||
this->grease_pencil = static_cast<GreasePencil *>(this->object->data);
|
||||
Paint *paint = BKE_paint_get_active_from_context(&C);
|
||||
Brush *brush = BKE_paint_brush(paint);
|
||||
|
||||
this->brush = brush;
|
||||
this->initial_brush_radius = BKE_brush_size_get(scene, brush);
|
||||
this->initial_brush_strength = BKE_brush_alpha_get(scene, brush);
|
||||
this->brush_weight = BKE_brush_weight_get(scene, brush);
|
||||
this->initial_brush_radius = BKE_brush_size_get(paint, brush);
|
||||
this->initial_brush_strength = BKE_brush_alpha_get(paint, brush);
|
||||
this->brush_weight = BKE_brush_weight_get(paint, brush);
|
||||
this->mouse_position_previous = start_sample.mouse_position;
|
||||
this->invert_brush_weight = false;
|
||||
|
||||
|
|
|
|||
|
|
@ -284,14 +284,15 @@ static int load_tex(Brush *br, ViewContext *vc, float zoom, bool col, bool prima
|
|||
|
||||
if (refresh) {
|
||||
ImagePool *pool = nullptr;
|
||||
Paint *paint = BKE_paint_get_active_from_context(vc->C);
|
||||
/* Stencil is rotated later. */
|
||||
const float rotation = (mtex->brush_map_mode != MTEX_MAP_MODE_STENCIL) ? -mtex->rot : 0.0f;
|
||||
const float radius = BKE_brush_size_get(vc->scene, br) * zoom;
|
||||
const float radius = BKE_brush_size_get(paint, br) * zoom;
|
||||
|
||||
make_tex_snap(target, vc, zoom);
|
||||
|
||||
if (mtex->brush_map_mode == MTEX_MAP_MODE_VIEW) {
|
||||
int s = BKE_brush_size_get(vc->scene, br);
|
||||
int s = BKE_brush_size_get(paint, br);
|
||||
int r = 1;
|
||||
|
||||
for (s >>= 1; s > 0; s >>= 1) {
|
||||
|
|
@ -430,11 +431,12 @@ static int load_tex_cursor(Brush *br, ViewContext *vc, float zoom)
|
|||
init = (cursor_snap.overlay_texture != nullptr);
|
||||
|
||||
if (refresh) {
|
||||
Paint *paint = BKE_paint_get_active_from_context(vc->C);
|
||||
int s, r;
|
||||
|
||||
cursor_snap.zoom = zoom;
|
||||
|
||||
s = BKE_brush_size_get(vc->scene, br);
|
||||
s = BKE_brush_size_get(paint, br);
|
||||
r = 1;
|
||||
|
||||
for (s >>= 1; s > 0; s >>= 1) {
|
||||
|
|
@ -633,7 +635,8 @@ static bool paint_draw_tex_overlay(UnifiedPaintSettings *ups,
|
|||
quad.ymax = center[1] + ups->anchored_size;
|
||||
}
|
||||
else {
|
||||
const int radius = BKE_brush_size_get(vc->scene, brush) * zoom;
|
||||
const Paint &paint = *BKE_paint_get_active_from_paintmode(vc->scene, mode);
|
||||
const int radius = BKE_brush_size_get(&paint, brush) * zoom;
|
||||
quad.xmin = center[0] - radius;
|
||||
quad.ymin = center[1] - radius;
|
||||
quad.xmax = center[0] + radius;
|
||||
|
|
@ -747,7 +750,8 @@ static bool paint_draw_cursor_overlay(
|
|||
quad.ymax = ups->anchored_initial_mouse[1] + ups->anchored_size;
|
||||
}
|
||||
else {
|
||||
const int radius = BKE_brush_size_get(vc->scene, brush) * zoom;
|
||||
const Paint *paint = BKE_paint_get_active_from_context(vc->C);
|
||||
const int radius = BKE_brush_size_get(paint, brush) * zoom;
|
||||
center[0] = x;
|
||||
center[1] = y;
|
||||
|
||||
|
|
@ -1043,9 +1047,9 @@ static void paint_cursor_update_unprojected_radius(const UnifiedPaintSettings &u
|
|||
const ViewContext &vc,
|
||||
const float location[3])
|
||||
{
|
||||
|
||||
Paint &paint = *BKE_paint_get_active_from_context(vc.C);
|
||||
/* Update the brush's cached 3D radius. */
|
||||
if (!BKE_brush_use_locked_size(vc.scene, &brush)) {
|
||||
if (!BKE_brush_use_locked_size(&paint, &brush)) {
|
||||
float projected_radius;
|
||||
/* Get 2D brush radius. */
|
||||
if (ups.draw_anchored) {
|
||||
|
|
@ -1056,7 +1060,7 @@ static void paint_cursor_update_unprojected_radius(const UnifiedPaintSettings &u
|
|||
projected_radius = 8;
|
||||
}
|
||||
else {
|
||||
projected_radius = BKE_brush_size_get(vc.scene, &brush);
|
||||
projected_radius = BKE_brush_size_get(&paint, &brush);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1069,7 +1073,7 @@ static void paint_cursor_update_unprojected_radius(const UnifiedPaintSettings &u
|
|||
}
|
||||
|
||||
/* Set cached value in either Brush or UnifiedPaintSettings. */
|
||||
BKE_brush_unprojected_radius_set(vc.scene, &brush, unprojected_radius);
|
||||
BKE_brush_unprojected_radius_set(&paint, &brush, unprojected_radius);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1339,11 +1343,11 @@ static bool paint_cursor_context_init(bContext *C,
|
|||
pcontext.screen = CTX_wm_screen(C);
|
||||
pcontext.depsgraph = CTX_data_depsgraph_pointer(C);
|
||||
pcontext.scene = CTX_data_scene(C);
|
||||
pcontext.ups = &pcontext.scene->toolsettings->unified_paint_settings;
|
||||
pcontext.paint = BKE_paint_get_active_from_context(C);
|
||||
if (pcontext.paint == nullptr) {
|
||||
return false;
|
||||
}
|
||||
pcontext.ups = &pcontext.paint->unified_paint_settings;
|
||||
pcontext.brush = BKE_paint_brush(pcontext.paint);
|
||||
if (pcontext.brush == nullptr) {
|
||||
return false;
|
||||
|
|
@ -1369,7 +1373,7 @@ static bool paint_cursor_context_init(bContext *C,
|
|||
float zoomx, zoomy;
|
||||
get_imapaint_zoom(C, &zoomx, &zoomy);
|
||||
pcontext.zoomx = max_ff(zoomx, zoomy);
|
||||
pcontext.final_radius = (BKE_brush_size_get(pcontext.scene, pcontext.brush) * zoomx);
|
||||
pcontext.final_radius = (BKE_brush_size_get(pcontext.paint, pcontext.brush) * zoomx);
|
||||
|
||||
/* There is currently no way to check if the direction is inverted before starting the stroke,
|
||||
* so this does not reflect the state of the brush in the UI. */
|
||||
|
|
@ -1408,10 +1412,10 @@ static void paint_cursor_update_pixel_radius(PaintCursorContext &pcontext)
|
|||
if (pcontext.is_cursor_over_mesh) {
|
||||
Brush *brush = BKE_paint_brush(pcontext.paint);
|
||||
pcontext.pixel_radius = project_brush_radius(
|
||||
&pcontext.vc, BKE_brush_unprojected_radius_get(pcontext.scene, brush), pcontext.location);
|
||||
&pcontext.vc, BKE_brush_unprojected_radius_get(pcontext.paint, brush), pcontext.location);
|
||||
|
||||
if (pcontext.pixel_radius == 0) {
|
||||
pcontext.pixel_radius = BKE_brush_size_get(pcontext.scene, brush);
|
||||
pcontext.pixel_radius = BKE_brush_size_get(pcontext.paint, brush);
|
||||
}
|
||||
|
||||
pcontext.scene_space_location = math::transform_point(pcontext.vc.obact->object_to_world(),
|
||||
|
|
@ -1421,7 +1425,7 @@ static void paint_cursor_update_pixel_radius(PaintCursorContext &pcontext)
|
|||
Sculpt *sd = CTX_data_tool_settings(pcontext.C)->sculpt;
|
||||
Brush *brush = BKE_paint_brush(&sd->paint);
|
||||
|
||||
pcontext.pixel_radius = BKE_brush_size_get(pcontext.scene, brush);
|
||||
pcontext.pixel_radius = BKE_brush_size_get(pcontext.paint, brush);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1433,7 +1437,6 @@ static void paint_cursor_sculpt_session_update_and_init(PaintCursorContext &pcon
|
|||
bContext *C = pcontext.C;
|
||||
SculptSession &ss = *pcontext.ss;
|
||||
Brush &brush = *pcontext.brush;
|
||||
Scene &scene = *pcontext.scene;
|
||||
UnifiedPaintSettings &ups = *pcontext.ups;
|
||||
ViewContext &vc = pcontext.vc;
|
||||
CursorGeometryInfo gi;
|
||||
|
|
@ -1464,8 +1467,8 @@ static void paint_cursor_sculpt_session_update_and_init(PaintCursorContext &pcon
|
|||
|
||||
paint_cursor_update_pixel_radius(pcontext);
|
||||
|
||||
if (BKE_brush_use_locked_size(&scene, &brush)) {
|
||||
BKE_brush_size_set(&scene, &brush, pcontext.pixel_radius);
|
||||
if (BKE_brush_use_locked_size(pcontext.paint, &brush)) {
|
||||
BKE_brush_size_set(pcontext.paint, &brush, pcontext.pixel_radius);
|
||||
}
|
||||
|
||||
if (pcontext.is_cursor_over_mesh) {
|
||||
|
|
@ -1655,8 +1658,8 @@ static void grease_pencil_brush_cursor_draw(PaintCursorContext &pcontext)
|
|||
}
|
||||
}
|
||||
else if (pcontext.mode == PaintMode::VertexGPencil) {
|
||||
pcontext.pixel_radius = BKE_brush_size_get(pcontext.vc.scene, brush);
|
||||
color = BKE_brush_color_get(pcontext.vc.scene, paint, brush);
|
||||
pcontext.pixel_radius = BKE_brush_size_get(pcontext.paint, brush);
|
||||
color = BKE_brush_color_get(paint, brush);
|
||||
}
|
||||
|
||||
GPU_line_width(1.0f);
|
||||
|
|
@ -1703,14 +1706,14 @@ static void paint_draw_3D_view_inactive_brush_cursor(PaintCursorContext &pcontex
|
|||
pcontext.translation[0],
|
||||
pcontext.translation[1],
|
||||
pcontext.final_radius *
|
||||
clamp_f(BKE_brush_alpha_get(pcontext.scene, pcontext.brush), 0.0f, 1.0f),
|
||||
clamp_f(BKE_brush_alpha_get(pcontext.paint, pcontext.brush), 0.0f, 1.0f),
|
||||
80);
|
||||
}
|
||||
|
||||
static void paint_cursor_update_object_space_radius(PaintCursorContext &pcontext)
|
||||
{
|
||||
pcontext.radius = object_space_radius_get(
|
||||
pcontext.vc, *pcontext.scene, *pcontext.brush, pcontext.location);
|
||||
pcontext.vc, *pcontext.paint, *pcontext.brush, pcontext.location);
|
||||
}
|
||||
|
||||
static void paint_cursor_drawing_setup_cursor_space(const PaintCursorContext &pcontext)
|
||||
|
|
@ -1747,7 +1750,7 @@ static void paint_cursor_draw_main_inactive_cursor(PaintCursorContext &pcontext)
|
|||
pcontext.pos,
|
||||
0,
|
||||
0,
|
||||
pcontext.radius * clamp_f(BKE_brush_alpha_get(pcontext.scene, pcontext.brush), 0.0f, 1.0f),
|
||||
pcontext.radius * clamp_f(BKE_brush_alpha_get(pcontext.paint, pcontext.brush), 0.0f, 1.0f),
|
||||
80);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -348,7 +348,7 @@ static bool image_paint_2d_clone_poll(bContext *C)
|
|||
/** \name Paint Operator
|
||||
* \{ */
|
||||
|
||||
bool paint_use_opacity_masking(const Scene *scene, const Paint *paint, const Brush *brush)
|
||||
bool paint_use_opacity_masking(const Paint *paint, const Brush *brush)
|
||||
{
|
||||
return ((brush->flag & BRUSH_AIRBRUSH) || (brush->flag & BRUSH_DRAG_DOT) ||
|
||||
(brush->flag & BRUSH_ANCHORED) ||
|
||||
|
|
@ -357,7 +357,7 @@ bool paint_use_opacity_masking(const Scene *scene, const Paint *paint, const Bru
|
|||
IMAGE_PAINT_BRUSH_TYPE_SOFTEN) ||
|
||||
(brush->image_brush_type == IMAGE_PAINT_BRUSH_TYPE_FILL) ||
|
||||
(brush->flag & BRUSH_USE_GRADIENT) ||
|
||||
(BKE_brush_color_jitter_get_settings(scene, paint, brush)) ||
|
||||
(BKE_brush_color_jitter_get_settings(paint, brush)) ||
|
||||
(brush->mtex.tex && !ELEM(brush->mtex.brush_map_mode,
|
||||
MTEX_MAP_MODE_TILED,
|
||||
MTEX_MAP_MODE_STENCIL,
|
||||
|
|
@ -366,8 +366,7 @@ bool paint_use_opacity_masking(const Scene *scene, const Paint *paint, const Bru
|
|||
true);
|
||||
}
|
||||
|
||||
void paint_brush_color_get(Scene *scene,
|
||||
const Paint *paint,
|
||||
void paint_brush_color_get(const Paint *paint,
|
||||
Brush *br,
|
||||
std::optional<blender::float3> &initial_hsv_jitter,
|
||||
bool color_correction,
|
||||
|
|
@ -378,11 +377,11 @@ void paint_brush_color_get(Scene *scene,
|
|||
float r_color[3])
|
||||
{
|
||||
if (invert) {
|
||||
copy_v3_v3(r_color, BKE_brush_secondary_color_get(scene, paint, br));
|
||||
copy_v3_v3(r_color, BKE_brush_secondary_color_get(paint, br));
|
||||
}
|
||||
else {
|
||||
const std::optional<BrushColorJitterSettings> color_jitter_settings =
|
||||
BKE_brush_color_jitter_get_settings(scene, paint, br);
|
||||
BKE_brush_color_jitter_get_settings(paint, br);
|
||||
if (br->flag & BRUSH_USE_GRADIENT) {
|
||||
float color_gr[4];
|
||||
switch (br->gradient_stroke_mode) {
|
||||
|
|
@ -409,10 +408,10 @@ void paint_brush_color_get(Scene *scene,
|
|||
*initial_hsv_jitter,
|
||||
distance,
|
||||
pressure,
|
||||
BKE_brush_color_get(scene, paint, br)));
|
||||
BKE_brush_color_get(paint, br)));
|
||||
}
|
||||
else {
|
||||
copy_v3_v3(r_color, BKE_brush_color_get(scene, paint, br));
|
||||
copy_v3_v3(r_color, BKE_brush_color_get(paint, br));
|
||||
}
|
||||
}
|
||||
if (color_correction) {
|
||||
|
|
@ -699,7 +698,6 @@ static wmOperatorStatus sample_color_exec(bContext *C, wmOperator *op)
|
|||
|
||||
static wmOperatorStatus sample_color_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
{
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
Paint *paint = BKE_paint_get_active_from_context(C);
|
||||
Brush *brush = BKE_paint_brush(paint);
|
||||
SampleColorData *data = MEM_new<SampleColorData>("sample color custom data");
|
||||
|
|
@ -708,7 +706,7 @@ static wmOperatorStatus sample_color_invoke(bContext *C, wmOperator *op, const w
|
|||
|
||||
data->launch_event = WM_userdef_event_type_from_keymap_type(event->type);
|
||||
data->show_cursor = ((paint->flags & PAINT_SHOW_BRUSH) != 0);
|
||||
copy_v3_v3(data->initcolor, BKE_brush_color_get(scene, paint, brush));
|
||||
copy_v3_v3(data->initcolor, BKE_brush_color_get(paint, brush));
|
||||
data->sample_palette = false;
|
||||
op->customdata = data;
|
||||
paint->flags &= ~PAINT_SHOW_BRUSH;
|
||||
|
|
@ -737,7 +735,6 @@ static wmOperatorStatus sample_color_invoke(bContext *C, wmOperator *op, const w
|
|||
|
||||
static wmOperatorStatus sample_color_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
{
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
SampleColorData *data = static_cast<SampleColorData *>(op->customdata);
|
||||
Paint *paint = BKE_paint_get_active_from_context(C);
|
||||
Brush *brush = BKE_paint_brush(paint);
|
||||
|
|
@ -748,7 +745,7 @@ static wmOperatorStatus sample_color_modal(bContext *C, wmOperator *op, const wm
|
|||
}
|
||||
|
||||
if (data->sample_palette) {
|
||||
BKE_brush_color_set(scene, paint, brush, data->initcolor);
|
||||
BKE_brush_color_set(paint, brush, data->initcolor);
|
||||
RNA_boolean_set(op->ptr, "palette", true);
|
||||
WM_event_add_notifier(C, NC_BRUSH | NA_EDITED, brush);
|
||||
}
|
||||
|
|
@ -870,9 +867,9 @@ static blender::float3 paint_init_pivot_grease_pencil(Object *ob, const int fram
|
|||
return float3(0.0f);
|
||||
}
|
||||
|
||||
void paint_init_pivot(Object *ob, Scene *scene)
|
||||
void paint_init_pivot(Object *ob, Scene *scene, Paint *paint)
|
||||
{
|
||||
UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
|
||||
UnifiedPaintSettings *ups = &paint->unified_paint_settings;
|
||||
|
||||
blender::float3 location;
|
||||
switch (ob->type) {
|
||||
|
|
@ -951,7 +948,7 @@ void ED_object_texture_paint_mode_enter_ex(Main &bmain,
|
|||
|
||||
/* Set pivot to bounding box center. */
|
||||
Object *ob_eval = DEG_get_evaluated(&depsgraph, &ob);
|
||||
paint_init_pivot(ob_eval ? ob_eval : &ob, &scene);
|
||||
paint_init_pivot(ob_eval ? ob_eval : &ob, &scene, &imapaint.paint);
|
||||
|
||||
WM_main_add_notifier(NC_SCENE | ND_MODE, &scene);
|
||||
}
|
||||
|
|
@ -1057,13 +1054,11 @@ void PAINT_OT_texture_paint_toggle(wmOperatorType *ot)
|
|||
|
||||
static wmOperatorStatus brush_colors_flip_exec(bContext *C, wmOperator * /*op*/)
|
||||
{
|
||||
Scene &scene = *CTX_data_scene(C);
|
||||
|
||||
Paint *paint = BKE_paint_get_active_from_context(C);
|
||||
Brush *br = BKE_paint_brush(paint);
|
||||
|
||||
if (BKE_paint_use_unified_color(scene.toolsettings, paint)) {
|
||||
UnifiedPaintSettings &ups = scene.toolsettings->unified_paint_settings;
|
||||
if (BKE_paint_use_unified_color(paint)) {
|
||||
UnifiedPaintSettings &ups = paint->unified_paint_settings;
|
||||
swap_v3_v3(ups.rgb, ups.secondary_rgb);
|
||||
}
|
||||
else if (br) {
|
||||
|
|
|
|||
|
|
@ -124,6 +124,7 @@ struct ImagePaintState {
|
|||
SpaceImage *sima;
|
||||
View2D *v2d;
|
||||
Scene *scene;
|
||||
const Paint *paint;
|
||||
|
||||
Brush *brush;
|
||||
short brush_type, blend;
|
||||
|
|
@ -150,7 +151,7 @@ static BrushPainter *brush_painter_2d_new(Scene *scene,
|
|||
painter->brush = brush;
|
||||
painter->scene = scene;
|
||||
painter->paint = paint;
|
||||
if (BKE_brush_color_jitter_get_settings(scene, paint, brush)) {
|
||||
if (BKE_brush_color_jitter_get_settings(paint, brush)) {
|
||||
painter->initial_hsv_jitter = seed_hsv_jitter();
|
||||
}
|
||||
painter->firsttouch = true;
|
||||
|
|
@ -216,7 +217,6 @@ static void brush_imbuf_tex_co(const rctf *mapping, int x, int y, float texco[3]
|
|||
/* create a mask with the mask texture */
|
||||
static ushort *brush_painter_mask_ibuf_new(BrushPainter *painter, const int size)
|
||||
{
|
||||
Scene *scene = painter->scene;
|
||||
Brush *brush = painter->brush;
|
||||
rctf mask_mapping = painter->mask_mapping;
|
||||
ImagePool *pool = painter->pool;
|
||||
|
|
@ -232,7 +232,7 @@ static ushort *brush_painter_mask_ibuf_new(BrushPainter *painter, const int size
|
|||
for (x = 0; x < size; x++, m++) {
|
||||
float res;
|
||||
brush_imbuf_tex_co(&mask_mapping, x, y, texco);
|
||||
res = BKE_brush_sample_masktex(scene, brush, texco, thread, pool);
|
||||
res = BKE_brush_sample_masktex(painter->paint, brush, texco, thread, pool);
|
||||
*m = ushort(65535.0f * res);
|
||||
}
|
||||
}
|
||||
|
|
@ -252,7 +252,6 @@ static void brush_painter_mask_imbuf_update(BrushPainter *painter,
|
|||
int yt,
|
||||
const int diameter)
|
||||
{
|
||||
Scene *scene = painter->scene;
|
||||
Brush *brush = painter->brush;
|
||||
BrushPainterCache *cache = &tile->cache;
|
||||
rctf tex_mapping = painter->mask_mapping;
|
||||
|
|
@ -278,7 +277,8 @@ static void brush_painter_mask_imbuf_update(BrushPainter *painter,
|
|||
|
||||
if (!use_texture_old) {
|
||||
brush_imbuf_tex_co(&tex_mapping, x, y, texco);
|
||||
res = ushort(65535.0f * BKE_brush_sample_masktex(scene, brush, texco, thread, pool));
|
||||
res = ushort(65535.0f *
|
||||
BKE_brush_sample_masktex(painter->paint, brush, texco, thread, pool));
|
||||
}
|
||||
|
||||
/* read from old texture buffer */
|
||||
|
|
@ -402,8 +402,7 @@ static ImBuf *brush_painter_imbuf_new(
|
|||
|
||||
/* get brush color */
|
||||
if (brush->image_brush_type == IMAGE_PAINT_BRUSH_TYPE_DRAW) {
|
||||
paint_brush_color_get(scene,
|
||||
paint,
|
||||
paint_brush_color_get(paint,
|
||||
brush,
|
||||
painter->initial_hsv_jitter,
|
||||
use_color_correction,
|
||||
|
|
@ -428,7 +427,7 @@ static ImBuf *brush_painter_imbuf_new(
|
|||
if (is_texbrush) {
|
||||
brush_imbuf_tex_co(&tex_mapping, x, y, texco);
|
||||
const MTex *mtex = &brush->mtex;
|
||||
BKE_brush_sample_tex_3d(scene, brush, mtex, texco, rgba, thread, pool);
|
||||
BKE_brush_sample_tex_3d(painter->paint, brush, mtex, texco, rgba, thread, pool);
|
||||
/* TODO(sergey): Support texture paint color space. */
|
||||
if (!use_float) {
|
||||
IMB_colormanagement_scene_linear_to_display_v3(rgba, display);
|
||||
|
|
@ -495,8 +494,7 @@ static void brush_painter_imbuf_update(BrushPainter *painter,
|
|||
|
||||
/* get brush color */
|
||||
if (brush->image_brush_type == IMAGE_PAINT_BRUSH_TYPE_DRAW) {
|
||||
paint_brush_color_get(scene,
|
||||
paint,
|
||||
paint_brush_color_get(paint,
|
||||
brush,
|
||||
painter->initial_hsv_jitter,
|
||||
use_color_correction,
|
||||
|
|
@ -521,7 +519,7 @@ static void brush_painter_imbuf_update(BrushPainter *painter,
|
|||
if (!use_texture_old) {
|
||||
if (is_texbrush) {
|
||||
brush_imbuf_tex_co(&tex_mapping, x, y, texco);
|
||||
BKE_brush_sample_tex_3d(scene, brush, mtex, texco, rgba, thread, pool);
|
||||
BKE_brush_sample_tex_3d(painter->paint, brush, mtex, texco, rgba, thread, pool);
|
||||
/* TODO(sergey): Support texture paint color space. */
|
||||
if (!use_float) {
|
||||
IMB_colormanagement_scene_linear_to_display_v3(rgba, display);
|
||||
|
|
@ -718,8 +716,7 @@ static void brush_painter_2d_refresh_cache(ImagePaintState *s,
|
|||
float distance,
|
||||
float size)
|
||||
{
|
||||
const Scene *scene = painter->scene;
|
||||
UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
|
||||
const UnifiedPaintSettings *ups = &painter->paint->unified_paint_settings;
|
||||
Brush *brush = painter->brush;
|
||||
BrushPainterCache *cache = &tile->cache;
|
||||
/* Adding 4 pixels of padding for brush anti-aliasing. */
|
||||
|
|
@ -732,7 +729,7 @@ static void brush_painter_2d_refresh_cache(ImagePaintState *s,
|
|||
BRUSH_GRADIENT_SPACING_REPEAT,
|
||||
BRUSH_GRADIENT_SPACING_CLAMP) ||
|
||||
(cache->last_pressure != pressure))) ||
|
||||
BKE_brush_color_jitter_get_settings(scene, painter->paint, brush);
|
||||
BKE_brush_color_jitter_get_settings(painter->paint, brush);
|
||||
float tex_rotation = -brush->mtex.rot;
|
||||
float mask_rotation = -brush->mask_mtex.rot;
|
||||
|
||||
|
|
@ -1042,7 +1039,7 @@ static void paint_2d_lift_soften(ImagePaintState *s,
|
|||
* avoid colored speckles appearing in final image, and also to check for threshold. */
|
||||
outrgb[0] = outrgb[1] = outrgb[2] = IMB_colormanagement_get_luminance(outrgb);
|
||||
if (fabsf(outrgb[0]) > threshold) {
|
||||
float mask = BKE_brush_alpha_get(s->scene, s->brush);
|
||||
float mask = BKE_brush_alpha_get(s->paint, s->brush);
|
||||
float alpha = rgba[3];
|
||||
rgba[3] = outrgb[3] = mask;
|
||||
|
||||
|
|
@ -1325,7 +1322,7 @@ static int paint_2d_op(void *state,
|
|||
short blend = s->blend;
|
||||
const float *offset = image_paint_settings.clone_offset;
|
||||
float liftpos[2];
|
||||
float mask_max = BKE_brush_alpha_get(s->scene, s->brush);
|
||||
float mask_max = BKE_brush_alpha_get(s->paint, s->brush);
|
||||
int bpos[2], blastpos[2], bliftpos[2];
|
||||
int a, tot;
|
||||
|
||||
|
|
@ -1463,7 +1460,7 @@ static int paint_2d_canvas_set(ImagePaintState *s, const Paint *paint)
|
|||
}
|
||||
|
||||
/* set masking */
|
||||
s->do_masking = paint_use_opacity_masking(s->scene, paint, s->brush);
|
||||
s->do_masking = paint_use_opacity_masking(paint, s->brush);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -1607,6 +1604,7 @@ void *paint_2d_new_stroke(bContext *C, wmOperator *op, int mode)
|
|||
s->sima = CTX_wm_space_image(C);
|
||||
s->v2d = &CTX_wm_region(C)->v2d;
|
||||
s->scene = scene;
|
||||
s->paint = paint;
|
||||
|
||||
s->brush = brush;
|
||||
s->brush_type = brush->image_brush_type;
|
||||
|
|
@ -1816,6 +1814,7 @@ void paint_2d_bucket_fill(const bContext *C,
|
|||
void *ps)
|
||||
{
|
||||
SpaceImage *sima = CTX_wm_space_image(C);
|
||||
Paint *paint = BKE_paint_get_active_from_context(C);
|
||||
Image *ima = sima->image;
|
||||
|
||||
ImagePaintState *s = static_cast<ImagePaintState *>(ps);
|
||||
|
|
@ -1824,7 +1823,7 @@ void paint_2d_bucket_fill(const bContext *C,
|
|||
int x_px, y_px;
|
||||
uint color_b;
|
||||
float color_f[4];
|
||||
float strength = (s && br) ? BKE_brush_alpha_get(s->scene, br) : 1.0f;
|
||||
float strength = (s && br) ? BKE_brush_alpha_get(paint, br) : 1.0f;
|
||||
|
||||
bool do_float;
|
||||
|
||||
|
|
@ -2021,7 +2020,7 @@ void paint_2d_gradient_fill(
|
|||
float image_init[2], image_final[2];
|
||||
float tangent[2];
|
||||
float line_len_sq_inv, line_len;
|
||||
const float brush_alpha = BKE_brush_alpha_get(s->scene, br);
|
||||
const float brush_alpha = BKE_brush_alpha_get(s->paint, br);
|
||||
|
||||
bool do_float;
|
||||
|
||||
|
|
|
|||
|
|
@ -60,7 +60,6 @@ class AbstractPaintMode {
|
|||
virtual void paint_stroke_redraw(const bContext *C, void *stroke_handle, bool final) = 0;
|
||||
virtual void paint_stroke_done(void *stroke_handle) = 0;
|
||||
virtual void paint_gradient_fill(const bContext *C,
|
||||
const Scene *scene,
|
||||
const Paint *paint,
|
||||
Brush *brush,
|
||||
PaintStroke *stroke,
|
||||
|
|
@ -68,7 +67,6 @@ class AbstractPaintMode {
|
|||
float mouse_start[2],
|
||||
float mouse_end[2]) = 0;
|
||||
virtual void paint_bucket_fill(const bContext *C,
|
||||
const Scene *scene,
|
||||
const Paint *paint,
|
||||
Brush *brush,
|
||||
PaintStroke *stroke,
|
||||
|
|
@ -108,7 +106,6 @@ class ImagePaintMode : public AbstractPaintMode {
|
|||
}
|
||||
|
||||
void paint_gradient_fill(const bContext *C,
|
||||
const Scene * /*scene*/,
|
||||
const Paint * /*paint*/,
|
||||
Brush *brush,
|
||||
PaintStroke * /*stroke*/,
|
||||
|
|
@ -120,7 +117,6 @@ class ImagePaintMode : public AbstractPaintMode {
|
|||
}
|
||||
|
||||
void paint_bucket_fill(const bContext *C,
|
||||
const Scene *scene,
|
||||
const Paint *paint,
|
||||
Brush *brush,
|
||||
PaintStroke *stroke,
|
||||
|
|
@ -130,10 +126,10 @@ class ImagePaintMode : public AbstractPaintMode {
|
|||
{
|
||||
float color[3];
|
||||
if (paint_stroke_inverted(stroke)) {
|
||||
copy_v3_v3(color, BKE_brush_secondary_color_get(scene, paint, brush));
|
||||
copy_v3_v3(color, BKE_brush_secondary_color_get(paint, brush));
|
||||
}
|
||||
else {
|
||||
copy_v3_v3(color, BKE_brush_color_get(scene, paint, brush));
|
||||
copy_v3_v3(color, BKE_brush_color_get(paint, brush));
|
||||
}
|
||||
paint_2d_bucket_fill(C, color, brush, mouse_start, mouse_end, stroke_handle);
|
||||
}
|
||||
|
|
@ -170,7 +166,6 @@ class ProjectionPaintMode : public AbstractPaintMode {
|
|||
}
|
||||
|
||||
void paint_gradient_fill(const bContext *C,
|
||||
const Scene *scene,
|
||||
const Paint *paint,
|
||||
Brush *brush,
|
||||
PaintStroke *stroke,
|
||||
|
|
@ -178,11 +173,10 @@ class ProjectionPaintMode : public AbstractPaintMode {
|
|||
float mouse_start[2],
|
||||
float mouse_end[2]) override
|
||||
{
|
||||
paint_fill(C, scene, paint, brush, stroke, stroke_handle, mouse_start, mouse_end);
|
||||
paint_fill(C, paint, brush, stroke, stroke_handle, mouse_start, mouse_end);
|
||||
}
|
||||
|
||||
void paint_bucket_fill(const bContext *C,
|
||||
const Scene *scene,
|
||||
const Paint *paint,
|
||||
Brush *brush,
|
||||
PaintStroke *stroke,
|
||||
|
|
@ -190,13 +184,12 @@ class ProjectionPaintMode : public AbstractPaintMode {
|
|||
float mouse_start[2],
|
||||
float mouse_end[2]) override
|
||||
{
|
||||
paint_fill(C, scene, paint, brush, stroke, stroke_handle, mouse_start, mouse_end);
|
||||
paint_fill(C, paint, brush, stroke, stroke_handle, mouse_start, mouse_end);
|
||||
}
|
||||
|
||||
private:
|
||||
void paint_fill(const bContext *C,
|
||||
const Scene *scene,
|
||||
const Paint * /*paint*/,
|
||||
const Paint *paint,
|
||||
Brush *brush,
|
||||
PaintStroke *stroke,
|
||||
void *stroke_handle,
|
||||
|
|
@ -210,7 +203,7 @@ class ProjectionPaintMode : public AbstractPaintMode {
|
|||
paint_stroke_flipped(stroke),
|
||||
1.0,
|
||||
0.0,
|
||||
BKE_brush_size_get(scene, brush));
|
||||
BKE_brush_size_get(paint, brush));
|
||||
/* two redraws, one for GPU update, one for notification */
|
||||
paint_proj_redraw(C, stroke_handle, false);
|
||||
paint_proj_redraw(C, stroke_handle, true);
|
||||
|
|
@ -342,15 +335,14 @@ static void paint_stroke_update_step(bContext *C,
|
|||
PointerRNA *itemptr)
|
||||
{
|
||||
PaintOperation *pop = static_cast<PaintOperation *>(paint_stroke_mode_data(stroke));
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
ToolSettings *toolsettings = CTX_data_tool_settings(C);
|
||||
UnifiedPaintSettings *ups = &toolsettings->unified_paint_settings;
|
||||
Brush *brush = BKE_paint_brush(&toolsettings->imapaint.paint);
|
||||
Paint *paint = BKE_paint_get_active_from_context(C);
|
||||
UnifiedPaintSettings *ups = &paint->unified_paint_settings;
|
||||
Brush *brush = BKE_paint_brush(paint);
|
||||
|
||||
float alphafac = (brush->flag & BRUSH_ACCUMULATE) ? ups->overlap_factor : 1.0f;
|
||||
|
||||
/* initial brush values. Maybe it should be considered moving these to stroke system */
|
||||
float startalpha = BKE_brush_alpha_get(scene, brush);
|
||||
float startalpha = BKE_brush_alpha_get(paint, brush);
|
||||
|
||||
float mouse[2];
|
||||
float pressure;
|
||||
|
|
@ -370,10 +362,10 @@ static void paint_stroke_update_step(bContext *C,
|
|||
}
|
||||
|
||||
if (BKE_brush_use_alpha_pressure(brush)) {
|
||||
BKE_brush_alpha_set(scene, brush, max_ff(0.0f, startalpha * pressure * alphafac));
|
||||
BKE_brush_alpha_set(paint, brush, max_ff(0.0f, startalpha * pressure * alphafac));
|
||||
}
|
||||
else {
|
||||
BKE_brush_alpha_set(scene, brush, max_ff(0.0f, startalpha * alphafac));
|
||||
BKE_brush_alpha_set(paint, brush, max_ff(0.0f, startalpha * alphafac));
|
||||
}
|
||||
|
||||
if ((brush->flag & BRUSH_DRAG_DOT) || (brush->flag & BRUSH_ANCHORED)) {
|
||||
|
|
@ -387,7 +379,7 @@ static void paint_stroke_update_step(bContext *C,
|
|||
copy_v2_v2(pop->prevmouse, mouse);
|
||||
|
||||
/* restore brush values */
|
||||
BKE_brush_alpha_set(scene, brush, startalpha);
|
||||
BKE_brush_alpha_set(paint, brush, startalpha);
|
||||
}
|
||||
|
||||
static void paint_stroke_redraw(const bContext *C, PaintStroke *stroke, bool final)
|
||||
|
|
@ -409,11 +401,11 @@ static void paint_stroke_done(const bContext *C, PaintStroke *stroke)
|
|||
if (brush->image_brush_type == IMAGE_PAINT_BRUSH_TYPE_FILL) {
|
||||
if (brush->flag & BRUSH_USE_GRADIENT) {
|
||||
pop->mode->paint_gradient_fill(
|
||||
C, scene, paint, brush, stroke, pop->stroke_handle, pop->startmouse, pop->prevmouse);
|
||||
C, paint, brush, stroke, pop->stroke_handle, pop->startmouse, pop->prevmouse);
|
||||
}
|
||||
else {
|
||||
pop->mode->paint_bucket_fill(
|
||||
C, scene, paint, brush, stroke, pop->stroke_handle, pop->startmouse, pop->prevmouse);
|
||||
C, paint, brush, stroke, pop->stroke_handle, pop->startmouse, pop->prevmouse);
|
||||
}
|
||||
}
|
||||
pop->mode->paint_stroke_done(pop->stroke_handle);
|
||||
|
|
@ -506,7 +498,6 @@ static wmOperatorStatus paint_exec(bContext *C, wmOperator *op)
|
|||
|
||||
/* Make sure we have proper coordinates for sampling (mask) textures -- these get stored in
|
||||
* #UnifiedPaintSettings -- as well as support randomness and jitter. */
|
||||
Scene &scene = *CTX_data_scene(C);
|
||||
PaintMode mode = BKE_paintmode_get_active_from_context(C);
|
||||
Paint &paint = *BKE_paint_get_active_from_context(C);
|
||||
const Brush &brush = *BKE_paint_brush_for_read(&paint);
|
||||
|
|
@ -516,7 +507,7 @@ static wmOperatorStatus paint_exec(bContext *C, wmOperator *op)
|
|||
bool dummy;
|
||||
float dummy_location[3];
|
||||
|
||||
paint_stroke_jitter_pos(scene, *stroke, mode, brush, pressure, mouse, mouse_out);
|
||||
paint_stroke_jitter_pos(*stroke, mode, brush, pressure, mouse, mouse_out);
|
||||
paint_brush_update(C, brush, mode, stroke, mouse, mouse_out, pressure, dummy_location, &dummy);
|
||||
|
||||
/* frees op->customdata */
|
||||
|
|
|
|||
|
|
@ -249,6 +249,7 @@ struct ProjStrokeHandle {
|
|||
|
||||
/* In ProjPaintState, only here for convenience */
|
||||
Scene *scene;
|
||||
Paint *paint;
|
||||
Brush *brush;
|
||||
};
|
||||
|
||||
|
|
@ -273,7 +274,7 @@ struct ProjPaintState {
|
|||
float paint_color_linear[3];
|
||||
float dither;
|
||||
|
||||
const Paint *paint;
|
||||
Paint *paint;
|
||||
Brush *brush;
|
||||
|
||||
/**
|
||||
|
|
@ -4502,7 +4503,7 @@ static void project_paint_begin(const bContext *C,
|
|||
/* At the moment this is just ps->arena_mt[0], but use this to show were not multi-threading. */
|
||||
MemArena *arena;
|
||||
|
||||
const int diameter = 2 * BKE_brush_size_get(ps->scene, ps->brush);
|
||||
const int diameter = 2 * BKE_brush_size_get(ps->paint, ps->brush);
|
||||
|
||||
bool reset_threads = false;
|
||||
|
||||
|
|
@ -5216,7 +5217,7 @@ static void do_projectpaint_thread(TaskPool *__restrict /*pool*/, void *ph_v)
|
|||
float pos_ofs[2] = {0};
|
||||
float co[2];
|
||||
ushort mask_short;
|
||||
const float brush_alpha = BKE_brush_alpha_get(ps->scene, brush);
|
||||
const float brush_alpha = BKE_brush_alpha_get(ps->paint, brush);
|
||||
const float brush_radius = ps->brush_size;
|
||||
/* avoid a square root with every dist comparison */
|
||||
const float brush_radius_sq = brush_radius * brush_radius;
|
||||
|
|
@ -5424,7 +5425,7 @@ static void do_projectpaint_thread(TaskPool *__restrict /*pool*/, void *ph_v)
|
|||
/* Mask texture. */
|
||||
if (ps->is_maskbrush) {
|
||||
float texmask = BKE_brush_sample_masktex(
|
||||
ps->scene, ps->brush, projPixel->projCoSS, thread_index, pool);
|
||||
ps->paint, ps->brush, projPixel->projCoSS, thread_index, pool);
|
||||
CLAMP(texmask, 0.0f, 1.0f);
|
||||
custom_mask *= texmask;
|
||||
}
|
||||
|
|
@ -5448,7 +5449,7 @@ static void do_projectpaint_thread(TaskPool *__restrict /*pool*/, void *ph_v)
|
|||
/* NOTE: for clone and smear,
|
||||
* we only use the alpha, could be a special function */
|
||||
BKE_brush_sample_tex_3d(
|
||||
ps->scene, brush, mtex, samplecos, texrgba, thread_index, pool);
|
||||
ps->paint, brush, mtex, samplecos, texrgba, thread_index, pool);
|
||||
|
||||
copy_v3_v3(texrgb, texrgba);
|
||||
custom_mask *= texrgba[3];
|
||||
|
|
@ -5728,7 +5729,7 @@ static bool project_paint_op(void *state, const float lastpos[2], const float po
|
|||
const int3 &tri = ps->corner_tris_eval[tri_index];
|
||||
const int vert_tri[3] = {PS_CORNER_TRI_AS_VERT_INDEX_3(ps, tri)};
|
||||
float world[3];
|
||||
UnifiedPaintSettings *ups = &ps->scene->toolsettings->unified_paint_settings;
|
||||
UnifiedPaintSettings *ups = &ps->paint->unified_paint_settings;
|
||||
|
||||
interp_v3_v3v3v3(world,
|
||||
ps->vert_positions_eval[vert_tri[0]],
|
||||
|
|
@ -5770,8 +5771,7 @@ static void paint_proj_stroke_ps(const bContext * /*C*/,
|
|||
|
||||
/* handle gradient and inverted stroke color here */
|
||||
if (ELEM(ps->brush_type, IMAGE_PAINT_BRUSH_TYPE_DRAW, IMAGE_PAINT_BRUSH_TYPE_FILL)) {
|
||||
paint_brush_color_get(scene,
|
||||
paint,
|
||||
paint_brush_color_get(paint,
|
||||
brush,
|
||||
ps_handle->initial_hsv_jitter,
|
||||
false,
|
||||
|
|
@ -5869,7 +5869,7 @@ static void project_state_init(bContext *C, Object *ob, ProjPaintState *ps, int
|
|||
}
|
||||
|
||||
/* disable for 3d mapping also because painting on mirrored mesh can create "stripes" */
|
||||
ps->do_masking = paint_use_opacity_masking(scene, ps->paint, brush);
|
||||
ps->do_masking = paint_use_opacity_masking(ps->paint, brush);
|
||||
ps->is_texbrush = (brush->mtex.tex && ps->brush_type == IMAGE_PAINT_BRUSH_TYPE_DRAW) ? true :
|
||||
false;
|
||||
ps->is_maskbrush = (brush->mask_mtex.tex) ? true : false;
|
||||
|
|
@ -5962,9 +5962,10 @@ void *paint_proj_new_stroke(bContext *C, Object *ob, const float mouse[2], int m
|
|||
|
||||
ps_handle = MEM_new<ProjStrokeHandle>("ProjStrokeHandle");
|
||||
ps_handle->scene = scene;
|
||||
ps_handle->paint = BKE_paint_get_active_from_context(C);
|
||||
ps_handle->brush = BKE_paint_brush(&settings->imapaint.paint);
|
||||
|
||||
if (BKE_brush_color_jitter_get_settings(scene, &settings->imapaint.paint, ps_handle->brush)) {
|
||||
if (BKE_brush_color_jitter_get_settings(&settings->imapaint.paint, ps_handle->brush)) {
|
||||
ps_handle->initial_hsv_jitter = seed_hsv_jitter();
|
||||
}
|
||||
|
||||
|
|
@ -5977,7 +5978,7 @@ void *paint_proj_new_stroke(bContext *C, Object *ob, const float mouse[2], int m
|
|||
}
|
||||
}
|
||||
|
||||
ps_handle->orig_brush_size = BKE_brush_size_get(scene, ps_handle->brush);
|
||||
ps_handle->orig_brush_size = BKE_brush_size_get(ps_handle->paint, ps_handle->brush);
|
||||
|
||||
Mesh *mesh = BKE_mesh_from_object(ob);
|
||||
ps_handle->symmetry_flags = mesh->symmetry;
|
||||
|
|
@ -6019,8 +6020,8 @@ void *paint_proj_new_stroke(bContext *C, Object *ob, const float mouse[2], int m
|
|||
}
|
||||
|
||||
/* Don't allow brush size below 2 */
|
||||
if (BKE_brush_size_get(scene, ps_handle->brush) < 2) {
|
||||
BKE_brush_size_set(scene, ps_handle->brush, 2 * U.pixelsize);
|
||||
if (BKE_brush_size_get(&settings->imapaint.paint, ps_handle->brush) < 2) {
|
||||
BKE_brush_size_set(&settings->imapaint.paint, ps_handle->brush, 2 * U.pixelsize);
|
||||
}
|
||||
|
||||
/* allocate and initialize spatial data structures */
|
||||
|
|
@ -6081,7 +6082,6 @@ void paint_proj_redraw(const bContext *C, void *ps_handle_p, bool final)
|
|||
void paint_proj_stroke_done(void *ps_handle_p)
|
||||
{
|
||||
ProjStrokeHandle *ps_handle = static_cast<ProjStrokeHandle *>(ps_handle_p);
|
||||
Scene *scene = ps_handle->scene;
|
||||
|
||||
if (ps_handle->is_clone_cursor_pick) {
|
||||
MEM_delete(ps_handle);
|
||||
|
|
@ -6092,7 +6092,7 @@ void paint_proj_stroke_done(void *ps_handle_p)
|
|||
PROJ_PAINT_STATE_SHARED_CLEAR(ps_handle->ps_views[i]);
|
||||
}
|
||||
|
||||
BKE_brush_size_set(scene, ps_handle->brush, ps_handle->orig_brush_size);
|
||||
BKE_brush_size_set(ps_handle->paint, ps_handle->brush, ps_handle->orig_brush_size);
|
||||
|
||||
paint_brush_exit_tex(ps_handle->brush);
|
||||
|
||||
|
|
@ -6180,9 +6180,9 @@ static wmOperatorStatus texture_paint_camera_project_exec(bContext *C, wmOperato
|
|||
ps.is_texbrush = false;
|
||||
ps.is_maskbrush = false;
|
||||
ps.do_masking = false;
|
||||
orig_brush_size = BKE_brush_size_get(&scene, ps.brush);
|
||||
orig_brush_size = BKE_brush_size_get(ps.paint, ps.brush);
|
||||
/* cover the whole image */
|
||||
BKE_brush_size_set(&scene, ps.brush, 32 * U.pixelsize);
|
||||
BKE_brush_size_set(ps.paint, ps.brush, 32 * U.pixelsize);
|
||||
|
||||
/* so pixels are initialized with minimal info */
|
||||
ps.brush_type = IMAGE_PAINT_BRUSH_TYPE_DRAW;
|
||||
|
|
@ -6193,7 +6193,7 @@ static wmOperatorStatus texture_paint_camera_project_exec(bContext *C, wmOperato
|
|||
project_paint_begin(C, &ps, false, 0);
|
||||
|
||||
if (ps.mesh_eval == nullptr) {
|
||||
BKE_brush_size_set(&scene, ps.brush, orig_brush_size);
|
||||
BKE_brush_size_set(ps.paint, ps.brush, orig_brush_size);
|
||||
BKE_report(op->reports, RPT_ERROR, "Could not get valid evaluated mesh");
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
|
@ -6218,7 +6218,7 @@ static wmOperatorStatus texture_paint_camera_project_exec(bContext *C, wmOperato
|
|||
ED_image_undo_push_end();
|
||||
|
||||
scene.toolsettings->imapaint.flag &= ~IMAGEPAINT_DRAWING;
|
||||
BKE_brush_size_set(&scene, ps.brush, orig_brush_size);
|
||||
BKE_brush_size_set(ps.paint, ps.brush, orig_brush_size);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -170,8 +170,7 @@ class PaintModeData {
|
|||
void paint_stroke_set_mode_data(PaintStroke *stroke, std::unique_ptr<PaintModeData> mode_data);
|
||||
|
||||
bool paint_stroke_started(PaintStroke *stroke);
|
||||
void paint_stroke_jitter_pos(Scene &scene,
|
||||
const PaintStroke &stroke,
|
||||
void paint_stroke_jitter_pos(const PaintStroke &stroke,
|
||||
const PaintMode mode,
|
||||
const Brush &brush,
|
||||
const float pressure,
|
||||
|
|
@ -349,8 +348,7 @@ void paint_proj_stroke(const bContext *C,
|
|||
void paint_proj_redraw(const bContext *C, void *ps_handle_p, bool final);
|
||||
void paint_proj_stroke_done(void *ps_handle_p);
|
||||
|
||||
void paint_brush_color_get(Scene *scene,
|
||||
const Paint *paint,
|
||||
void paint_brush_color_get(const Paint *paint,
|
||||
Brush *br,
|
||||
std::optional<blender::float3> &initial_hsv_jitter,
|
||||
bool color_correction,
|
||||
|
|
@ -359,7 +357,7 @@ void paint_brush_color_get(Scene *scene,
|
|||
float pressure,
|
||||
const ColorManagedDisplay *display,
|
||||
float r_color[3]);
|
||||
bool paint_use_opacity_masking(const Scene *scene, const Paint *paint, const Brush *brush);
|
||||
bool paint_use_opacity_masking(const Paint *paint, const Brush *brush);
|
||||
void paint_brush_init_tex(Brush *brush);
|
||||
void paint_brush_exit_tex(Brush *brush);
|
||||
|
||||
|
|
@ -568,7 +566,7 @@ BlurKernel *paint_new_blur_kernel(Brush *br, bool proj);
|
|||
void paint_delete_blur_kernel(BlurKernel *);
|
||||
|
||||
/** Initialize viewport pivot from evaluated bounding box center of `ob`. */
|
||||
void paint_init_pivot(Object *ob, Scene *scene);
|
||||
void paint_init_pivot(Object *ob, Scene *scene, Paint *paint);
|
||||
|
||||
/* paint curve defines */
|
||||
#define PAINT_CURVE_NUM_SEGMENTS 40
|
||||
|
|
@ -597,8 +595,8 @@ bool use_normal(const VPaint &vp);
|
|||
bool brush_use_accumulate_ex(const Brush &brush, eObjectMode ob_mode);
|
||||
bool brush_use_accumulate(const VPaint &vp);
|
||||
|
||||
void get_brush_alpha_data(const Scene &scene,
|
||||
const SculptSession &ss,
|
||||
void get_brush_alpha_data(const SculptSession &ss,
|
||||
const Paint &paint,
|
||||
const Brush &brush,
|
||||
float *r_brush_size_pressure,
|
||||
float *r_brush_alpha_value,
|
||||
|
|
@ -607,8 +605,12 @@ void get_brush_alpha_data(const Scene &scene,
|
|||
void init_stroke(Depsgraph &depsgraph, Object &ob);
|
||||
void init_session_data(const ToolSettings &ts, Object &ob);
|
||||
/** Toggle operator for turning vertex paint mode on or off (copied from `sculpt.cc`) */
|
||||
void init_session(
|
||||
Main &bmain, Depsgraph &depsgraph, Scene &scene, Object &ob, eObjectMode object_mode);
|
||||
void init_session(Main &bmain,
|
||||
Depsgraph &depsgraph,
|
||||
Scene &scene,
|
||||
Paint &paint,
|
||||
Object &ob,
|
||||
eObjectMode object_mode);
|
||||
|
||||
IndexMask pbvh_gather_generic(const Depsgraph &depsgraph,
|
||||
const Object &ob,
|
||||
|
|
@ -621,7 +623,7 @@ void mode_enter_generic(
|
|||
void mode_exit_generic(Object &ob, eObjectMode mode_flag);
|
||||
bool mode_toggle_poll_test(bContext *C);
|
||||
|
||||
void smooth_brush_toggle_off(const bContext *C, Paint *paint, StrokeCache *cache);
|
||||
void smooth_brush_toggle_off(Paint *paint, StrokeCache *cache);
|
||||
void smooth_brush_toggle_on(const bContext *C, Paint *paint, StrokeCache *cache);
|
||||
|
||||
/** Initialize the stroke cache variants from operator properties. */
|
||||
|
|
@ -629,5 +631,5 @@ void update_cache_variants(bContext *C, VPaint &vp, Object &ob, PointerRNA *ptr)
|
|||
/** Initialize the stroke cache invariants from operator properties. */
|
||||
void update_cache_invariants(
|
||||
bContext *C, VPaint &vp, SculptSession &ss, wmOperator *op, const float mval[2]);
|
||||
void last_stroke_update(Scene &scene, const float location[3]);
|
||||
void last_stroke_update(const float location[3], Paint &paint);
|
||||
} // namespace blender::ed::sculpt_paint::vwpaint
|
||||
|
|
|
|||
|
|
@ -50,7 +50,6 @@
|
|||
|
||||
static wmOperatorStatus brush_scale_size_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
Paint *paint = BKE_paint_get_active_from_context(C);
|
||||
Brush *brush = BKE_paint_brush(paint);
|
||||
float scalar = RNA_float_get(op->ptr, "scalar");
|
||||
|
|
@ -62,7 +61,7 @@ static wmOperatorStatus brush_scale_size_exec(bContext *C, wmOperator *op)
|
|||
if (brush) {
|
||||
/* Pixel radius. */
|
||||
{
|
||||
const int old_size = (use_unified_size) ? BKE_brush_size_get(scene, brush) : brush->size;
|
||||
const int old_size = (use_unified_size) ? BKE_brush_size_get(paint, brush) : brush->size;
|
||||
int size = int(scalar * old_size);
|
||||
|
||||
if (abs(old_size - size) < U.pixelsize) {
|
||||
|
|
@ -75,7 +74,7 @@ static wmOperatorStatus brush_scale_size_exec(bContext *C, wmOperator *op)
|
|||
}
|
||||
|
||||
if (use_unified_size) {
|
||||
BKE_brush_size_set(scene, brush, size);
|
||||
BKE_brush_size_set(paint, brush, size);
|
||||
}
|
||||
else {
|
||||
brush->size = max_ii(size, 1);
|
||||
|
|
@ -86,13 +85,13 @@ static wmOperatorStatus brush_scale_size_exec(bContext *C, wmOperator *op)
|
|||
/* Unprojected radius. */
|
||||
{
|
||||
float unprojected_radius = scalar * (use_unified_size ?
|
||||
BKE_brush_unprojected_radius_get(scene, brush) :
|
||||
BKE_brush_unprojected_radius_get(paint, brush) :
|
||||
brush->unprojected_radius);
|
||||
|
||||
unprojected_radius = std::max(unprojected_radius, 0.001f);
|
||||
|
||||
if (use_unified_size) {
|
||||
BKE_brush_unprojected_radius_set(scene, brush, unprojected_radius);
|
||||
BKE_brush_unprojected_radius_set(paint, brush, unprojected_radius);
|
||||
}
|
||||
else {
|
||||
brush->unprojected_radius = unprojected_radius;
|
||||
|
|
@ -166,7 +165,6 @@ static bool palette_poll(bContext *C)
|
|||
|
||||
static wmOperatorStatus palette_color_add_exec(bContext *C, wmOperator * /*op*/)
|
||||
{
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
Paint *paint = BKE_paint_get_active_from_context(C);
|
||||
PaintMode mode = BKE_paintmode_get_active_from_context(C);
|
||||
Palette *palette = paint->palette;
|
||||
|
|
@ -185,7 +183,7 @@ static wmOperatorStatus palette_color_add_exec(bContext *C, wmOperator * /*op*/)
|
|||
PaintMode::GPencil,
|
||||
PaintMode::VertexGPencil))
|
||||
{
|
||||
copy_v3_v3(color->rgb, BKE_brush_color_get(scene, paint, brush));
|
||||
copy_v3_v3(color->rgb, BKE_brush_color_get(paint, brush));
|
||||
color->value = 0.0;
|
||||
}
|
||||
else if (mode == PaintMode::Weight) {
|
||||
|
|
|
|||
|
|
@ -76,6 +76,7 @@ struct PaintStroke {
|
|||
|
||||
/* Cached values */
|
||||
ViewContext vc;
|
||||
Paint *paint;
|
||||
Brush *brush;
|
||||
UnifiedPaintSettings *ups;
|
||||
|
||||
|
|
@ -315,6 +316,7 @@ bool paint_brush_update(bContext *C,
|
|||
bool *r_location_is_set)
|
||||
{
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
Paint *paint = BKE_paint_get_active_from_paintmode(scene, mode);
|
||||
UnifiedPaintSettings &ups = *stroke->ups;
|
||||
bool location_sampled = false;
|
||||
bool location_success = false;
|
||||
|
|
@ -350,8 +352,8 @@ bool paint_brush_update(bContext *C,
|
|||
ups.stroke_active = true;
|
||||
ups.size_pressure_value = stroke->cached_size_pressure;
|
||||
|
||||
ups.pixel_radius = BKE_brush_size_get(scene, &brush);
|
||||
ups.initial_pixel_radius = BKE_brush_size_get(scene, &brush);
|
||||
ups.pixel_radius = BKE_brush_size_get(paint, &brush);
|
||||
ups.initial_pixel_radius = BKE_brush_size_get(paint, &brush);
|
||||
|
||||
if (BKE_brush_use_size_pressure(&brush) && paint_supports_dynamic_size(brush, mode)) {
|
||||
ups.pixel_radius *= stroke->cached_size_pressure;
|
||||
|
|
@ -515,8 +517,7 @@ static bool paint_stroke_use_jitter(const PaintMode mode, const Brush &brush, co
|
|||
return use_jitter;
|
||||
}
|
||||
|
||||
void paint_stroke_jitter_pos(Scene &scene,
|
||||
const PaintStroke &stroke,
|
||||
void paint_stroke_jitter_pos(const PaintStroke &stroke,
|
||||
const PaintMode mode,
|
||||
const Brush &brush,
|
||||
const float pressure,
|
||||
|
|
@ -530,7 +531,7 @@ void paint_stroke_jitter_pos(Scene &scene,
|
|||
factor *= pressure;
|
||||
}
|
||||
|
||||
BKE_brush_jitter_pos(scene, brush, mval, r_mouse_out);
|
||||
BKE_brush_jitter_pos(*stroke.paint, brush, mval, r_mouse_out);
|
||||
|
||||
/* XXX: meh, this is round about because
|
||||
* BKE_brush_jitter_pos isn't written in the best way to
|
||||
|
|
@ -551,7 +552,6 @@ void paint_stroke_jitter_pos(Scene &scene,
|
|||
static void paint_brush_stroke_add_step(
|
||||
bContext *C, wmOperator *op, PaintStroke *stroke, const float2 mval, float pressure)
|
||||
{
|
||||
Scene &scene = *CTX_data_scene(C);
|
||||
const Paint &paint = *BKE_paint_get_active_from_context(C);
|
||||
const PaintMode mode = BKE_paintmode_get_active_from_context(C);
|
||||
const Brush &brush = *BKE_paint_brush_for_read(&paint);
|
||||
|
|
@ -605,7 +605,7 @@ static void paint_brush_stroke_add_step(
|
|||
|
||||
float2 mouse_out;
|
||||
/* Get jitter position (same as mval if no jitter is used). */
|
||||
paint_stroke_jitter_pos(scene, *stroke, mode, brush, pressure, mval, mouse_out);
|
||||
paint_stroke_jitter_pos(*stroke, mode, brush, pressure, mval, mouse_out);
|
||||
|
||||
float3 location;
|
||||
bool is_location_is_set;
|
||||
|
|
@ -681,7 +681,6 @@ static bool paint_smooth_stroke(PaintStroke *stroke,
|
|||
}
|
||||
|
||||
static float paint_space_stroke_spacing(const bContext *C,
|
||||
const Scene *scene,
|
||||
PaintStroke *stroke,
|
||||
const float size_pressure,
|
||||
const float spacing_pressure)
|
||||
|
|
@ -695,12 +694,12 @@ static float paint_space_stroke_spacing(const bContext *C,
|
|||
const float3 last_object_space_position = math::transform_point(
|
||||
stroke->vc.obact->world_to_object(), stroke->last_world_space_position);
|
||||
size_clamp = object_space_radius_get(
|
||||
stroke->vc, *scene, brush, last_object_space_position, size_pressure);
|
||||
stroke->vc, *paint, brush, last_object_space_position, size_pressure);
|
||||
}
|
||||
else {
|
||||
/* brushes can have a minimum size of 1.0 but with pressure it can be smaller than a pixel
|
||||
* causing very high step sizes, hanging blender #32381. */
|
||||
size_clamp = max_ff(1.0f, BKE_brush_size_get(scene, stroke->brush) * size_pressure);
|
||||
size_clamp = max_ff(1.0f, BKE_brush_size_get(stroke->paint, stroke->brush) * size_pressure);
|
||||
}
|
||||
|
||||
float spacing = stroke->brush->spacing;
|
||||
|
|
@ -778,7 +777,6 @@ static float paint_stroke_integrate_overlap(const Brush &br, const float factor)
|
|||
}
|
||||
|
||||
static float paint_space_stroke_spacing_variable(bContext *C,
|
||||
const Scene *scene,
|
||||
PaintStroke *stroke,
|
||||
const float pressure,
|
||||
const float pressure_delta,
|
||||
|
|
@ -788,7 +786,7 @@ static float paint_space_stroke_spacing_variable(bContext *C,
|
|||
/* use pressure to modify size. set spacing so that at 100%, the circles
|
||||
* are aligned nicely with no overlap. for this the spacing needs to be
|
||||
* the average of the previous and next size. */
|
||||
const float s = paint_space_stroke_spacing(C, scene, stroke, 1.0f, pressure);
|
||||
const float s = paint_space_stroke_spacing(C, stroke, 1.0f, pressure);
|
||||
const float q = s * pressure_delta / (2.0f * length);
|
||||
const float pressure_fac = (1.0f + q) / (1.0f - q);
|
||||
|
||||
|
|
@ -796,16 +794,14 @@ static float paint_space_stroke_spacing_variable(bContext *C,
|
|||
const float new_size_pressure = stroke->last_pressure * pressure_fac;
|
||||
|
||||
/* average spacing */
|
||||
const float last_spacing = paint_space_stroke_spacing(
|
||||
C, scene, stroke, last_size_pressure, pressure);
|
||||
const float new_spacing = paint_space_stroke_spacing(
|
||||
C, scene, stroke, new_size_pressure, pressure);
|
||||
const float last_spacing = paint_space_stroke_spacing(C, stroke, last_size_pressure, pressure);
|
||||
const float new_spacing = paint_space_stroke_spacing(C, stroke, new_size_pressure, pressure);
|
||||
|
||||
return 0.5f * (last_spacing + new_spacing);
|
||||
}
|
||||
|
||||
/* no size pressure */
|
||||
return paint_space_stroke_spacing(C, scene, stroke, 1.0f, pressure);
|
||||
return paint_space_stroke_spacing(C, stroke, 1.0f, pressure);
|
||||
}
|
||||
|
||||
/* For brushes with stroke spacing enabled, moves mouse in steps
|
||||
|
|
@ -816,7 +812,6 @@ static int paint_space_stroke(bContext *C,
|
|||
const float2 final_mouse,
|
||||
const float final_pressure)
|
||||
{
|
||||
const Scene *scene = CTX_data_scene(C);
|
||||
const ARegion *region = CTX_wm_region(C);
|
||||
UnifiedPaintSettings *ups = stroke->ups;
|
||||
const Paint &paint = *BKE_paint_get_active_from_context(C);
|
||||
|
|
@ -851,11 +846,11 @@ static int paint_space_stroke(bContext *C,
|
|||
|
||||
float pressure = stroke->last_pressure;
|
||||
float pressure_delta = final_pressure - stroke->last_pressure;
|
||||
const float no_pressure_spacing = paint_space_stroke_spacing(C, scene, stroke, 1.0f, 1.0f);
|
||||
const float no_pressure_spacing = paint_space_stroke_spacing(C, stroke, 1.0f, 1.0f);
|
||||
int count = 0;
|
||||
while (length > 0.0f) {
|
||||
const float spacing = paint_space_stroke_spacing_variable(
|
||||
C, scene, stroke, pressure, pressure_delta, length);
|
||||
C, stroke, pressure, pressure_delta, length);
|
||||
BLI_assert(spacing >= 0.0f);
|
||||
|
||||
if (length >= spacing) {
|
||||
|
|
@ -907,9 +902,9 @@ PaintStroke *paint_stroke_new(bContext *C,
|
|||
{
|
||||
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
|
||||
PaintStroke *stroke = MEM_new<PaintStroke>(__func__);
|
||||
ToolSettings *toolsettings = CTX_data_tool_settings(C);
|
||||
UnifiedPaintSettings *ups = &toolsettings->unified_paint_settings;
|
||||
Paint *paint = BKE_paint_get_active_from_context(C);
|
||||
stroke->paint = paint;
|
||||
UnifiedPaintSettings *ups = &paint->unified_paint_settings;
|
||||
Brush *br = stroke->brush = BKE_paint_brush(paint);
|
||||
RegionView3D *rv3d = CTX_wm_region_view3d(C);
|
||||
|
||||
|
|
@ -976,7 +971,7 @@ PaintStroke *paint_stroke_new(bContext *C,
|
|||
|
||||
BKE_paint_set_overlay_override(eOverlayFlags(br->overlay_flags));
|
||||
|
||||
ups->start_pixel_radius = BKE_brush_size_get(CTX_data_scene(C), br);
|
||||
ups->start_pixel_radius = BKE_brush_size_get(stroke->paint, br);
|
||||
|
||||
return stroke;
|
||||
}
|
||||
|
|
@ -1340,9 +1335,9 @@ static bool paint_stroke_curve_end(bContext *C, wmOperator *op, PaintStroke *str
|
|||
return false;
|
||||
}
|
||||
|
||||
UnifiedPaintSettings &ups = CTX_data_tool_settings(C)->unified_paint_settings;
|
||||
const Scene *scene = CTX_data_scene(C);
|
||||
const float spacing = paint_space_stroke_spacing(C, scene, stroke, 1.0f, 1.0f);
|
||||
Paint *paint = BKE_paint_get_active_from_context(C);
|
||||
UnifiedPaintSettings &ups = paint->unified_paint_settings;
|
||||
const float spacing = paint_space_stroke_spacing(C, stroke, 1.0f, 1.0f);
|
||||
const PaintCurve *pc = br.paint_curve;
|
||||
|
||||
if (!pc) {
|
||||
|
|
@ -1459,7 +1454,6 @@ wmOperatorStatus paint_stroke_modal(bContext *C,
|
|||
const wmEvent *event,
|
||||
PaintStroke **stroke_p)
|
||||
{
|
||||
const Scene *scene = CTX_data_scene(C);
|
||||
Paint *paint = BKE_paint_get_active_from_context(C);
|
||||
const PaintMode mode = BKE_paintmode_get_active_from_context(C);
|
||||
PaintStroke *stroke = *stroke_p;
|
||||
|
|
@ -1488,7 +1482,7 @@ wmOperatorStatus paint_stroke_modal(bContext *C,
|
|||
stroke->last_tablet_event_pressure = pressure;
|
||||
}
|
||||
|
||||
const int input_samples = BKE_brush_input_samples_get(scene, br);
|
||||
const int input_samples = BKE_brush_input_samples_get(stroke->paint, br);
|
||||
paint_stroke_add_sample(stroke, input_samples, event->mval[0], event->mval[1], pressure);
|
||||
|
||||
PaintSample sample_average;
|
||||
|
|
|
|||
|
|
@ -414,7 +414,7 @@ void paint_sample_color(
|
|||
}
|
||||
else {
|
||||
linearrgb_to_srgb_v3_v3(rgba_f, rgba_f);
|
||||
BKE_brush_color_set(scene, paint, br, rgba_f);
|
||||
BKE_brush_color_set(paint, br, rgba_f);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
@ -427,7 +427,7 @@ void paint_sample_color(
|
|||
else {
|
||||
float rgba_f[3];
|
||||
rgb_uchar_to_float(rgba_f, rgba);
|
||||
BKE_brush_color_set(scene, paint, br, rgba_f);
|
||||
BKE_brush_color_set(paint, br, rgba_f);
|
||||
}
|
||||
}
|
||||
BKE_image_release_ibuf(image, ibuf, nullptr);
|
||||
|
|
@ -454,7 +454,7 @@ void paint_sample_color(
|
|||
copy_v3_v3(color->rgb, rgba_f);
|
||||
}
|
||||
else {
|
||||
BKE_brush_color_set(scene, paint, br, rgba_f);
|
||||
BKE_brush_color_set(paint, br, rgba_f);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
@ -471,7 +471,7 @@ void paint_sample_color(
|
|||
copy_v3_v3(color->rgb, rgb_fl);
|
||||
}
|
||||
else {
|
||||
BKE_brush_color_set(scene, paint, br, rgb_fl);
|
||||
BKE_brush_color_set(paint, br, rgb_fl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -216,8 +216,12 @@ void init_stroke(Depsgraph &depsgraph, Object &ob)
|
|||
}
|
||||
}
|
||||
|
||||
void init_session(
|
||||
Main &bmain, Depsgraph &depsgraph, Scene &scene, Object &ob, eObjectMode object_mode)
|
||||
void init_session(Main &bmain,
|
||||
Depsgraph &depsgraph,
|
||||
Scene &scene,
|
||||
Paint &paint,
|
||||
Object &ob,
|
||||
eObjectMode object_mode)
|
||||
{
|
||||
/* Create persistent sculpt mode data */
|
||||
BKE_sculpt_toolsettings_data_ensure(&bmain, &scene);
|
||||
|
|
@ -227,7 +231,7 @@ void init_session(
|
|||
ob.sculpt->mode_type = object_mode;
|
||||
BKE_sculpt_update_object_for_edit(&depsgraph, &ob, true);
|
||||
|
||||
ensure_valid_pivot(ob, scene);
|
||||
ensure_valid_pivot(ob, paint);
|
||||
}
|
||||
|
||||
void init_session_data(const ToolSettings &ts, Object &ob)
|
||||
|
|
@ -315,12 +319,13 @@ void mode_enter_generic(
|
|||
*/
|
||||
BKE_object_free_derived_caches(&ob);
|
||||
|
||||
Paint *paint = nullptr;
|
||||
if (mode_flag == OB_MODE_VERTEX_PAINT) {
|
||||
const PaintMode paint_mode = PaintMode::Vertex;
|
||||
ED_mesh_color_ensure(mesh, nullptr);
|
||||
|
||||
BKE_paint_ensure(scene.toolsettings, (Paint **)&scene.toolsettings->vpaint);
|
||||
Paint *paint = BKE_paint_get_active_from_paintmode(&scene, paint_mode);
|
||||
paint = BKE_paint_get_active_from_paintmode(&scene, paint_mode);
|
||||
ED_paint_cursor_start(paint, vertex_paint_poll);
|
||||
BKE_paint_init(&bmain, &scene, paint_mode, PAINT_CURSOR_VERTEX_PAINT);
|
||||
}
|
||||
|
|
@ -328,7 +333,7 @@ void mode_enter_generic(
|
|||
const PaintMode paint_mode = PaintMode::Weight;
|
||||
|
||||
BKE_paint_ensure(scene.toolsettings, (Paint **)&scene.toolsettings->wpaint);
|
||||
Paint *paint = BKE_paint_get_active_from_paintmode(&scene, paint_mode);
|
||||
paint = BKE_paint_get_active_from_paintmode(&scene, paint_mode);
|
||||
ED_paint_cursor_start(paint, weight_paint_poll);
|
||||
BKE_paint_init(&bmain, &scene, paint_mode, PAINT_CURSOR_WEIGHT_PAINT);
|
||||
|
||||
|
|
@ -347,7 +352,8 @@ void mode_enter_generic(
|
|||
BKE_sculptsession_free(&ob);
|
||||
}
|
||||
|
||||
vwpaint::init_session(bmain, depsgraph, scene, ob, mode_flag);
|
||||
BLI_assert(paint != nullptr);
|
||||
vwpaint::init_session(bmain, depsgraph, scene, *paint, ob, mode_flag);
|
||||
|
||||
/* Flush object mode. */
|
||||
DEG_id_tag_update(&ob.id, ID_RECALC_SYNC_TO_EVAL);
|
||||
|
|
@ -413,7 +419,7 @@ bool mode_toggle_poll_test(bContext *C)
|
|||
return true;
|
||||
}
|
||||
|
||||
void smooth_brush_toggle_off(const bContext *C, Paint *paint, StrokeCache *cache)
|
||||
void smooth_brush_toggle_off(Paint *paint, StrokeCache *cache)
|
||||
{
|
||||
Brush *brush = BKE_paint_brush(paint);
|
||||
/* The current brush should match with what we have stored in the cache. */
|
||||
|
|
@ -422,8 +428,7 @@ void smooth_brush_toggle_off(const bContext *C, Paint *paint, StrokeCache *cache
|
|||
/* If saved_active_brush is not set, brush was not switched/affected in
|
||||
* smooth_brush_toggle_on(). */
|
||||
if (cache->saved_active_brush) {
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
BKE_brush_size_set(scene, brush, cache->saved_smooth_size);
|
||||
BKE_brush_size_set(paint, brush, cache->saved_smooth_size);
|
||||
BKE_paint_brush_set(paint, cache->saved_active_brush);
|
||||
cache->saved_active_brush = nullptr;
|
||||
}
|
||||
|
|
@ -432,8 +437,7 @@ void update_cache_invariants(
|
|||
bContext *C, VPaint &vp, SculptSession &ss, wmOperator *op, const float mval[2])
|
||||
{
|
||||
StrokeCache *cache;
|
||||
const Scene *scene = CTX_data_scene(C);
|
||||
UnifiedPaintSettings *ups = &CTX_data_tool_settings(C)->unified_paint_settings;
|
||||
UnifiedPaintSettings &ups = vp.paint.unified_paint_settings;
|
||||
ViewContext *vc = paint_stroke_view_context((PaintStroke *)op->customdata);
|
||||
Object &ob = *CTX_data_active_object(C);
|
||||
float mat[3][3];
|
||||
|
|
@ -463,10 +467,10 @@ void update_cache_invariants(
|
|||
/* not very nice, but with current events system implementation
|
||||
* we can't handle brush appearance inversion hotkey separately (sergey) */
|
||||
if (cache->invert) {
|
||||
ups->draw_inverted = true;
|
||||
ups.draw_inverted = true;
|
||||
}
|
||||
else {
|
||||
ups->draw_inverted = false;
|
||||
ups.draw_inverted = false;
|
||||
}
|
||||
|
||||
if (cache->alt_smooth) {
|
||||
|
|
@ -478,6 +482,7 @@ void update_cache_invariants(
|
|||
/* Truly temporary data that isn't stored in properties */
|
||||
cache->vc = vc;
|
||||
cache->brush = brush;
|
||||
cache->paint = &vp.paint;
|
||||
cache->first_time = true;
|
||||
|
||||
/* cache projection matrix */
|
||||
|
|
@ -491,12 +496,12 @@ void update_cache_invariants(
|
|||
normalize_v3_v3(cache->view_normal, view_dir);
|
||||
|
||||
cache->view_normal_symm = cache->view_normal;
|
||||
cache->bstrength = BKE_brush_alpha_get(scene, brush);
|
||||
cache->bstrength = BKE_brush_alpha_get(&vp.paint, brush);
|
||||
cache->is_last_valid = false;
|
||||
|
||||
cache->accum = true;
|
||||
|
||||
if (BKE_brush_color_jitter_get_settings(scene, &vp.paint, brush)) {
|
||||
if (BKE_brush_color_jitter_get_settings(&vp.paint, brush)) {
|
||||
cache->initial_hsv_jitter = seed_hsv_jitter();
|
||||
}
|
||||
}
|
||||
|
|
@ -504,7 +509,6 @@ void update_cache_invariants(
|
|||
void update_cache_variants(bContext *C, VPaint &vp, Object &ob, PointerRNA *ptr)
|
||||
{
|
||||
using namespace blender;
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
const Depsgraph &depsgraph = *CTX_data_depsgraph_pointer(C);
|
||||
SculptSession &ss = *ob.sculpt;
|
||||
StrokeCache *cache = ss.cache;
|
||||
|
|
@ -530,8 +534,8 @@ void update_cache_variants(bContext *C, VPaint &vp, Object &ob, PointerRNA *ptr)
|
|||
/* Truly temporary data that isn't stored in properties */
|
||||
if (cache->first_time) {
|
||||
cache->initial_radius = paint_calc_object_space_radius(
|
||||
*cache->vc, cache->location, BKE_brush_size_get(scene, &brush));
|
||||
BKE_brush_unprojected_radius_set(scene, &brush, cache->initial_radius);
|
||||
*cache->vc, cache->location, BKE_brush_size_get(&vp.paint, &brush));
|
||||
BKE_brush_unprojected_radius_set(&vp.paint, &brush, cache->initial_radius);
|
||||
}
|
||||
|
||||
if (BKE_brush_use_size_pressure(&brush) && paint_supports_dynamic_size(brush, PaintMode::Sculpt))
|
||||
|
|
@ -549,22 +553,22 @@ void update_cache_variants(bContext *C, VPaint &vp, Object &ob, PointerRNA *ptr)
|
|||
}
|
||||
}
|
||||
|
||||
void get_brush_alpha_data(const Scene &scene,
|
||||
const SculptSession &ss,
|
||||
void get_brush_alpha_data(const SculptSession &ss,
|
||||
const Paint &paint,
|
||||
const Brush &brush,
|
||||
float *r_brush_size_pressure,
|
||||
float *r_brush_alpha_value,
|
||||
float *r_brush_alpha_pressure)
|
||||
{
|
||||
*r_brush_size_pressure = BKE_brush_size_get(&scene, &brush) *
|
||||
*r_brush_size_pressure = BKE_brush_size_get(&paint, &brush) *
|
||||
(BKE_brush_use_size_pressure(&brush) ? ss.cache->pressure : 1.0f);
|
||||
*r_brush_alpha_value = BKE_brush_alpha_get(&scene, &brush);
|
||||
*r_brush_alpha_value = BKE_brush_alpha_get(&paint, &brush);
|
||||
*r_brush_alpha_pressure = (BKE_brush_use_alpha_pressure(&brush) ? ss.cache->pressure : 1.0f);
|
||||
}
|
||||
|
||||
void last_stroke_update(Scene &scene, const float location[3])
|
||||
void last_stroke_update(const float location[3], Paint &paint)
|
||||
{
|
||||
UnifiedPaintSettings &ups = scene.toolsettings->unified_paint_settings;
|
||||
UnifiedPaintSettings &ups = paint.unified_paint_settings;
|
||||
ups.average_stroke_counter++;
|
||||
add_v3_v3(ups.average_stroke_accum, location);
|
||||
ups.last_stroke_valid = true;
|
||||
|
|
@ -575,7 +579,6 @@ void last_stroke_update(Scene &scene, const float location[3])
|
|||
void smooth_brush_toggle_on(const bContext *C, Paint *paint, StrokeCache *cache)
|
||||
{
|
||||
Main *bmain = CTX_data_main(C);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
Brush *cur_brush = BKE_paint_brush(paint);
|
||||
|
||||
/* Switch to the blur (smooth) brush if possible. */
|
||||
|
|
@ -589,11 +592,11 @@ void smooth_brush_toggle_on(const bContext *C, Paint *paint, StrokeCache *cache)
|
|||
return;
|
||||
}
|
||||
|
||||
int cur_brush_size = BKE_brush_size_get(scene, cur_brush);
|
||||
int cur_brush_size = BKE_brush_size_get(paint, cur_brush);
|
||||
|
||||
cache->saved_active_brush = cur_brush;
|
||||
cache->saved_smooth_size = BKE_brush_size_get(scene, smooth_brush);
|
||||
BKE_brush_size_set(scene, smooth_brush, cur_brush_size);
|
||||
cache->saved_smooth_size = BKE_brush_size_get(paint, smooth_brush);
|
||||
BKE_brush_size_set(paint, smooth_brush, cur_brush_size);
|
||||
BKE_curvemapping_init(smooth_brush->curve);
|
||||
}
|
||||
/** \} */
|
||||
|
|
@ -644,12 +647,12 @@ bool vertex_paint_poll_ignore_tool(bContext *C)
|
|||
return vertex_paint_poll_ex(C, false);
|
||||
}
|
||||
|
||||
static ColorPaint4f vpaint_get_current_col(Scene &scene, VPaint &vp, bool secondary)
|
||||
static ColorPaint4f vpaint_get_current_col(VPaint &vp, bool secondary)
|
||||
{
|
||||
const Brush *brush = BKE_paint_brush_for_read(&vp.paint);
|
||||
float color[4];
|
||||
const float *brush_color = secondary ? BKE_brush_secondary_color_get(&scene, &vp.paint, brush) :
|
||||
BKE_brush_color_get(&scene, &vp.paint, brush);
|
||||
const float *brush_color = secondary ? BKE_brush_secondary_color_get(&vp.paint, brush) :
|
||||
BKE_brush_color_get(&vp.paint, brush);
|
||||
IMB_colormanagement_srgb_to_scene_linear_v3(color, brush_color);
|
||||
|
||||
color[3] = 1.0f; /* alpha isn't used, could even be removed to speedup paint a little */
|
||||
|
|
@ -774,7 +777,7 @@ static void paint_and_tex_color_alpha_intern(const VPaint &vp,
|
|||
const MTex *mtex = BKE_brush_mask_texture_get(brush, OB_MODE_SCULPT);
|
||||
BLI_assert(mtex->tex != nullptr);
|
||||
if (mtex->brush_map_mode == MTEX_MAP_MODE_3D) {
|
||||
BKE_brush_sample_tex_3d(vc->scene, brush, mtex, co, r_rgba, 0, nullptr);
|
||||
BKE_brush_sample_tex_3d(&vp.paint, brush, mtex, co, r_rgba, 0, nullptr);
|
||||
}
|
||||
else {
|
||||
float co_ss[2]; /* screenspace */
|
||||
|
|
@ -783,7 +786,7 @@ static void paint_and_tex_color_alpha_intern(const VPaint &vp,
|
|||
V3D_PROJ_RET_OK)
|
||||
{
|
||||
const float co_ss_3d[3] = {co_ss[0], co_ss[1], 0.0f}; /* we need a 3rd empty value */
|
||||
BKE_brush_sample_tex_3d(vc->scene, brush, mtex, co_ss_3d, r_rgba, 0, nullptr);
|
||||
BKE_brush_sample_tex_3d(&vp.paint, brush, mtex, co_ss_3d, r_rgba, 0, nullptr);
|
||||
}
|
||||
else {
|
||||
zero_v4(r_rgba);
|
||||
|
|
@ -993,8 +996,8 @@ static std::unique_ptr<VPaintData> vpaint_init_vpaint(bContext *C,
|
|||
brush.falloff_angle,
|
||||
(brush.flag & BRUSH_FRONTFACE_FALLOFF) != 0);
|
||||
|
||||
vpd->paintcol = vpaint_get_current_col(
|
||||
scene, vp, (RNA_enum_get(op->ptr, "mode") == BRUSH_STROKE_INVERT));
|
||||
vpd->paintcol = vpaint_get_current_col(vp,
|
||||
(RNA_enum_get(op->ptr, "mode") == BRUSH_STROKE_INVERT));
|
||||
|
||||
vpd->is_texbrush = !(brush.vertex_brush_type == VPAINT_BRUSH_TYPE_BLUR) && brush.mtex.tex;
|
||||
|
||||
|
|
@ -1099,12 +1102,11 @@ static void do_vpaint_brush_blur_loops(const bContext *C,
|
|||
const StrokeCache &cache = *ss.cache;
|
||||
|
||||
const Brush &brush = *ob.sculpt->cache->brush;
|
||||
const Scene &scene = *CTX_data_scene(C);
|
||||
const Depsgraph &depsgraph = *CTX_data_depsgraph_pointer(C);
|
||||
|
||||
float brush_size_pressure, brush_alpha_value, brush_alpha_pressure;
|
||||
vwpaint::get_brush_alpha_data(
|
||||
scene, ss, brush, &brush_size_pressure, &brush_alpha_value, &brush_alpha_pressure);
|
||||
ss, vp.paint, brush, &brush_size_pressure, &brush_alpha_value, &brush_alpha_pressure);
|
||||
const bool use_normal = vwpaint::use_normal(vp);
|
||||
const bool use_vert_sel = (mesh.editflag & (ME_EDIT_PAINT_FACE_SEL | ME_EDIT_PAINT_VERT_SEL)) !=
|
||||
0;
|
||||
|
|
@ -1255,12 +1257,11 @@ static void do_vpaint_brush_blur_verts(const bContext *C,
|
|||
const StrokeCache &cache = *ss.cache;
|
||||
|
||||
const Brush &brush = *ss.cache->brush;
|
||||
const Scene &scene = *CTX_data_scene(C);
|
||||
const Depsgraph &depsgraph = *CTX_data_depsgraph_pointer(C);
|
||||
|
||||
float brush_size_pressure, brush_alpha_value, brush_alpha_pressure;
|
||||
vwpaint::get_brush_alpha_data(
|
||||
scene, ss, brush, &brush_size_pressure, &brush_alpha_value, &brush_alpha_pressure);
|
||||
ss, vp.paint, brush, &brush_size_pressure, &brush_alpha_value, &brush_alpha_pressure);
|
||||
const bool use_normal = vwpaint::use_normal(vp);
|
||||
const bool use_vert_sel = (mesh.editflag & (ME_EDIT_PAINT_FACE_SEL | ME_EDIT_PAINT_VERT_SEL)) !=
|
||||
0;
|
||||
|
|
@ -1405,7 +1406,6 @@ static void do_vpaint_brush_smear(const bContext *C,
|
|||
}
|
||||
|
||||
const Brush &brush = *cache.brush;
|
||||
const Scene &scene = *CTX_data_scene(C);
|
||||
const Depsgraph &depsgraph = *CTX_data_depsgraph_pointer(C);
|
||||
GMutableSpan g_color_curr = vpd.smear.color_curr;
|
||||
GMutableSpan g_color_prev_smear = vpd.smear.color_prev;
|
||||
|
|
@ -1414,7 +1414,7 @@ static void do_vpaint_brush_smear(const bContext *C,
|
|||
float brush_size_pressure, brush_alpha_value, brush_alpha_pressure;
|
||||
|
||||
vwpaint::get_brush_alpha_data(
|
||||
scene, ss, brush, &brush_size_pressure, &brush_alpha_value, &brush_alpha_pressure);
|
||||
ss, vp.paint, brush, &brush_size_pressure, &brush_alpha_value, &brush_alpha_pressure);
|
||||
const bool use_normal = vwpaint::use_normal(vp);
|
||||
const bool use_vert_sel = (mesh.editflag & (ME_EDIT_PAINT_FACE_SEL | ME_EDIT_PAINT_VERT_SEL)) !=
|
||||
0;
|
||||
|
|
@ -1714,15 +1714,14 @@ static float paint_and_tex_color_alpha(const VPaint &vp,
|
|||
}
|
||||
|
||||
/* Compute brush color, using jitter if it's enabled */
|
||||
static blender::float3 get_brush_color(const Scene *scene,
|
||||
static blender::float3 get_brush_color(const Paint *paint,
|
||||
const Brush *brush,
|
||||
const Paint *paint,
|
||||
const StrokeCache &cache,
|
||||
const ColorPaint4f &paint_color)
|
||||
{
|
||||
blender::float3 brush_color = blender::float3(paint_color.r, paint_color.g, paint_color.b);
|
||||
const std::optional<BrushColorJitterSettings> color_jitter_settings =
|
||||
BKE_brush_color_jitter_get_settings(scene, paint, brush);
|
||||
BKE_brush_color_jitter_get_settings(paint, brush);
|
||||
if (color_jitter_settings) {
|
||||
brush_color = BKE_paint_randomize_color(*color_jitter_settings,
|
||||
*cache.initial_hsv_jitter,
|
||||
|
|
@ -1745,12 +1744,11 @@ static void vpaint_do_draw(const bContext *C,
|
|||
SculptSession &ss = *ob.sculpt;
|
||||
const StrokeCache &cache = *ss.cache;
|
||||
const Brush &brush = *ob.sculpt->cache->brush;
|
||||
const Scene &scene = *CTX_data_scene(C);
|
||||
const Depsgraph &depsgraph = *CTX_data_depsgraph_pointer(C);
|
||||
|
||||
float brush_size_pressure, brush_alpha_value, brush_alpha_pressure;
|
||||
vwpaint::get_brush_alpha_data(
|
||||
scene, ss, brush, &brush_size_pressure, &brush_alpha_value, &brush_alpha_pressure);
|
||||
ss, vp.paint, brush, &brush_size_pressure, &brush_alpha_value, &brush_alpha_pressure);
|
||||
const bool use_normal = vwpaint::use_normal(vp);
|
||||
const bool use_vert_sel = (mesh.editflag & (ME_EDIT_PAINT_FACE_SEL | ME_EDIT_PAINT_VERT_SEL)) !=
|
||||
0;
|
||||
|
|
@ -1778,8 +1776,7 @@ static void vpaint_do_draw(const bContext *C,
|
|||
select_poly = *attributes.lookup<bool>(".select_poly", bke::AttrDomain::Face);
|
||||
}
|
||||
|
||||
const blender::float3 brush_color = get_brush_color(
|
||||
&scene, &brush, &vp.paint, cache, vpd.paintcol);
|
||||
const blender::float3 brush_color = get_brush_color(&vp.paint, &brush, cache, vpd.paintcol);
|
||||
|
||||
struct LocalData {
|
||||
Vector<float> factors;
|
||||
|
|
@ -2041,7 +2038,6 @@ static void vpaint_stroke_update_step(bContext *C,
|
|||
PaintStroke *stroke,
|
||||
PointerRNA *itemptr)
|
||||
{
|
||||
Scene &scene = *CTX_data_scene(C);
|
||||
ToolSettings *ts = CTX_data_tool_settings(C);
|
||||
VPaintData &vpd = *static_cast<VPaintData *>(paint_stroke_mode_data(stroke));
|
||||
VPaint &vp = *ts->vpaint;
|
||||
|
|
@ -2076,7 +2072,7 @@ static void vpaint_stroke_update_step(bContext *C,
|
|||
* also needed for "Frame Selected" on last stroke. */
|
||||
float loc_world[3];
|
||||
mul_v3_m4v3(loc_world, ob.object_to_world().ptr(), ss.cache->location);
|
||||
vwpaint::last_stroke_update(scene, loc_world);
|
||||
vwpaint::last_stroke_update(loc_world, vp.paint);
|
||||
|
||||
ED_region_tag_redraw(vc.region);
|
||||
|
||||
|
|
@ -2093,7 +2089,7 @@ static void vpaint_stroke_done(const bContext *C, PaintStroke *stroke)
|
|||
if (ss.cache && ss.cache->alt_smooth) {
|
||||
ToolSettings *ts = CTX_data_tool_settings(C);
|
||||
VPaint &vp = *ts->vpaint;
|
||||
vwpaint::smooth_brush_toggle_off(C, &vp.paint, ss.cache);
|
||||
vwpaint::smooth_brush_toggle_off(&vp.paint, ss.cache);
|
||||
}
|
||||
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, &ob);
|
||||
|
|
@ -2346,7 +2342,7 @@ static wmOperatorStatus vertex_color_set_exec(bContext *C, wmOperator *op)
|
|||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
ColorPaint4f paintcol = vpaint_get_current_col(scene, *scene.toolsettings->vpaint, false);
|
||||
ColorPaint4f paintcol = vpaint_get_current_col(*scene.toolsettings->vpaint, false);
|
||||
const bool affect_alpha = RNA_boolean_get(op->ptr, "use_alpha");
|
||||
|
||||
/* Ensure valid sculpt state. */
|
||||
|
|
|
|||
|
|
@ -258,7 +258,7 @@ static wmOperatorStatus weight_sample_invoke(bContext *C, wmOperator *op, const
|
|||
MEM_SAFE_FREE(defbase_unlocked);
|
||||
|
||||
CLAMP(vgroup_weight, 0.0f, 1.0f);
|
||||
BKE_brush_weight_set(vc.scene, brush, vgroup_weight);
|
||||
BKE_brush_weight_set(&ts->wpaint->paint, brush, vgroup_weight);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
|
@ -494,11 +494,10 @@ static bool weight_paint_set(Object *ob, float paintweight)
|
|||
|
||||
static wmOperatorStatus weight_paint_set_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
Object *obact = CTX_data_active_object(C);
|
||||
ToolSettings *ts = CTX_data_tool_settings(C);
|
||||
Brush *brush = BKE_paint_brush(&ts->wpaint->paint);
|
||||
float vgroup_weight = BKE_brush_weight_get(scene, brush);
|
||||
float vgroup_weight = BKE_brush_weight_get(&ts->wpaint->paint, brush);
|
||||
|
||||
if (ED_wpaint_ensure_data(C, op->reports, WPAINT_ENSURE_MIRROR, nullptr) == false) {
|
||||
return OPERATOR_CANCELLED;
|
||||
|
|
@ -822,7 +821,7 @@ static wmOperatorStatus paint_weight_gradient_exec(bContext *C, wmOperator *op)
|
|||
BKE_curvemapping_init(brush->curve);
|
||||
|
||||
data.brush = brush;
|
||||
data.weightpaint = BKE_brush_weight_get(scene, brush);
|
||||
data.weightpaint = BKE_brush_weight_get(&wp->paint, brush);
|
||||
data.use_vgroup_restrict = (ts->wpaint->flag & VP_FLAG_VGROUP_RESTRICT) != 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1089,7 +1089,6 @@ static void filter_factors_with_selection(const Span<bool> select_vert,
|
|||
}
|
||||
|
||||
static void do_wpaint_brush_blur(const Depsgraph &depsgraph,
|
||||
const Scene &scene,
|
||||
Object &ob,
|
||||
const Brush &brush,
|
||||
VPaint &vp,
|
||||
|
|
@ -1106,7 +1105,7 @@ static void do_wpaint_brush_blur(const Depsgraph &depsgraph,
|
|||
|
||||
float brush_size_pressure, brush_alpha_value, brush_alpha_pressure;
|
||||
vwpaint::get_brush_alpha_data(
|
||||
scene, ss, brush, &brush_size_pressure, &brush_alpha_value, &brush_alpha_pressure);
|
||||
ss, vp.paint, brush, &brush_size_pressure, &brush_alpha_value, &brush_alpha_pressure);
|
||||
const bool use_normal = vwpaint::use_normal(vp);
|
||||
const bool use_face_sel = (mesh.editflag & ME_EDIT_PAINT_FACE_SEL) != 0;
|
||||
const bool use_vert_sel = (mesh.editflag & ME_EDIT_PAINT_VERT_SEL) != 0;
|
||||
|
|
@ -1198,7 +1197,6 @@ static void do_wpaint_brush_blur(const Depsgraph &depsgraph,
|
|||
}
|
||||
|
||||
static void do_wpaint_brush_smear(const Depsgraph &depsgraph,
|
||||
const Scene &scene,
|
||||
Object &ob,
|
||||
const Brush &brush,
|
||||
VPaint &vp,
|
||||
|
|
@ -1218,7 +1216,7 @@ static void do_wpaint_brush_smear(const Depsgraph &depsgraph,
|
|||
|
||||
float brush_size_pressure, brush_alpha_value, brush_alpha_pressure;
|
||||
vwpaint::get_brush_alpha_data(
|
||||
scene, ss, brush, &brush_size_pressure, &brush_alpha_value, &brush_alpha_pressure);
|
||||
ss, vp.paint, brush, &brush_size_pressure, &brush_alpha_value, &brush_alpha_pressure);
|
||||
const bool use_normal = vwpaint::use_normal(vp);
|
||||
const bool use_face_sel = (mesh.editflag & ME_EDIT_PAINT_FACE_SEL) != 0;
|
||||
const bool use_vert_sel = (mesh.editflag & ME_EDIT_PAINT_VERT_SEL) != 0;
|
||||
|
|
@ -1325,7 +1323,6 @@ static void do_wpaint_brush_smear(const Depsgraph &depsgraph,
|
|||
}
|
||||
|
||||
static void do_wpaint_brush_draw(const Depsgraph &depsgraph,
|
||||
const Scene &scene,
|
||||
Object &ob,
|
||||
const Brush &brush,
|
||||
VPaint &vp,
|
||||
|
|
@ -1345,7 +1342,7 @@ static void do_wpaint_brush_draw(const Depsgraph &depsgraph,
|
|||
const float paintweight = strength;
|
||||
float brush_size_pressure, brush_alpha_value, brush_alpha_pressure;
|
||||
vwpaint::get_brush_alpha_data(
|
||||
scene, ss, brush, &brush_size_pressure, &brush_alpha_value, &brush_alpha_pressure);
|
||||
ss, vp.paint, brush, &brush_size_pressure, &brush_alpha_value, &brush_alpha_pressure);
|
||||
const bool use_normal = vwpaint::use_normal(vp);
|
||||
const bool use_face_sel = (mesh.editflag & ME_EDIT_PAINT_FACE_SEL) != 0;
|
||||
const bool use_vert_sel = (mesh.editflag & ME_EDIT_PAINT_VERT_SEL) != 0;
|
||||
|
|
@ -1506,7 +1503,6 @@ static void wpaint_paint_leaves(bContext *C,
|
|||
Mesh &mesh,
|
||||
const IndexMask &node_mask)
|
||||
{
|
||||
const Scene &scene = *CTX_data_scene(C);
|
||||
const Brush &brush = *ob.sculpt->cache->brush;
|
||||
const Depsgraph &depsgraph = *CTX_data_depsgraph_pointer(C);
|
||||
|
||||
|
|
@ -1514,7 +1510,6 @@ static void wpaint_paint_leaves(bContext *C,
|
|||
case WPAINT_BRUSH_TYPE_AVERAGE: {
|
||||
do_wpaint_brush_draw(
|
||||
depsgraph,
|
||||
scene,
|
||||
ob,
|
||||
brush,
|
||||
vp,
|
||||
|
|
@ -1526,21 +1521,20 @@ static void wpaint_paint_leaves(bContext *C,
|
|||
break;
|
||||
}
|
||||
case WPAINT_BRUSH_TYPE_SMEAR:
|
||||
do_wpaint_brush_smear(depsgraph, scene, ob, brush, vp, wpd, wpi, mesh, node_mask);
|
||||
do_wpaint_brush_smear(depsgraph, ob, brush, vp, wpd, wpi, mesh, node_mask);
|
||||
break;
|
||||
case WPAINT_BRUSH_TYPE_BLUR:
|
||||
do_wpaint_brush_blur(depsgraph, scene, ob, brush, vp, wpd, wpi, mesh, node_mask);
|
||||
do_wpaint_brush_blur(depsgraph, ob, brush, vp, wpd, wpi, mesh, node_mask);
|
||||
break;
|
||||
case WPAINT_BRUSH_TYPE_DRAW:
|
||||
do_wpaint_brush_draw(depsgraph,
|
||||
scene,
|
||||
ob,
|
||||
brush,
|
||||
vp,
|
||||
wpd,
|
||||
wpi,
|
||||
mesh,
|
||||
BKE_brush_weight_get(&scene, &brush),
|
||||
BKE_brush_weight_get(&vp.paint, &brush),
|
||||
node_mask);
|
||||
break;
|
||||
}
|
||||
|
|
@ -1789,7 +1783,6 @@ static void wpaint_stroke_update_step(bContext *C,
|
|||
PaintStroke *stroke,
|
||||
PointerRNA *itemptr)
|
||||
{
|
||||
Scene &scene = *CTX_data_scene(C);
|
||||
ToolSettings &ts = *CTX_data_tool_settings(C);
|
||||
VPaint &wp = *ts.wpaint;
|
||||
const Brush &brush = *BKE_paint_brush(&wp.paint);
|
||||
|
|
@ -1803,7 +1796,7 @@ static void wpaint_stroke_update_step(bContext *C,
|
|||
|
||||
float mat[4][4];
|
||||
|
||||
const float brush_alpha_value = BKE_brush_alpha_get(&scene, &brush);
|
||||
const float brush_alpha_value = BKE_brush_alpha_get(&wp.paint, &brush);
|
||||
|
||||
/* intentionally don't initialize as nullptr, make sure we initialize all members below */
|
||||
WeightPaintInfo wpi;
|
||||
|
|
@ -1859,7 +1852,7 @@ static void wpaint_stroke_update_step(bContext *C,
|
|||
* also needed for "Frame Selected" on last stroke. */
|
||||
float loc_world[3];
|
||||
mul_v3_m4v3(loc_world, ob->object_to_world().ptr(), ss.cache->location);
|
||||
vwpaint::last_stroke_update(scene, loc_world);
|
||||
vwpaint::last_stroke_update(loc_world, wp.paint);
|
||||
|
||||
BKE_mesh_batch_cache_dirty_tag(&mesh, BKE_MESH_BATCH_DIRTY_ALL);
|
||||
|
||||
|
|
@ -1879,7 +1872,7 @@ static void wpaint_stroke_done(const bContext *C, PaintStroke * /*stroke*/)
|
|||
if (ss.cache->alt_smooth) {
|
||||
ToolSettings &ts = *CTX_data_tool_settings(C);
|
||||
VPaint &vp = *ts.wpaint;
|
||||
vwpaint::smooth_brush_toggle_off(C, &vp.paint, ss.cache);
|
||||
vwpaint::smooth_brush_toggle_off(&vp.paint, ss.cache);
|
||||
}
|
||||
|
||||
if (ob.particlesystem.first) {
|
||||
|
|
|
|||
|
|
@ -113,16 +113,16 @@ namespace blender::ed::sculpt_paint {
|
|||
|
||||
/* TODO: This should be moved to either BKE_paint.hh or BKE_brush.hh */
|
||||
float object_space_radius_get(const ViewContext &vc,
|
||||
const Scene &scene,
|
||||
const Paint &paint,
|
||||
const Brush &brush,
|
||||
const float3 &location,
|
||||
const float scale_factor)
|
||||
{
|
||||
if (!BKE_brush_use_locked_size(&scene, &brush)) {
|
||||
if (!BKE_brush_use_locked_size(&paint, &brush)) {
|
||||
return paint_calc_object_space_radius(
|
||||
vc, location, BKE_brush_size_get(&scene, &brush) * scale_factor);
|
||||
vc, location, BKE_brush_size_get(&paint, &brush) * scale_factor);
|
||||
}
|
||||
return BKE_brush_unprojected_radius_get(&scene, &brush) * scale_factor;
|
||||
return BKE_brush_unprojected_radius_get(&paint, &brush) * scale_factor;
|
||||
}
|
||||
|
||||
bool report_if_shape_key_is_locked(const Object &ob, ReportList *reports)
|
||||
|
|
@ -2160,11 +2160,10 @@ static float brush_strength(const Sculpt &sd,
|
|||
const UnifiedPaintSettings &ups,
|
||||
const PaintModeSettings & /*paint_mode_settings*/)
|
||||
{
|
||||
const Scene *scene = cache.vc->scene;
|
||||
const Brush &brush = *BKE_paint_brush_for_read(&sd.paint);
|
||||
|
||||
/* Primary strength input; square it to make lower values more sensitive. */
|
||||
const float root_alpha = BKE_brush_alpha_get(scene, &brush);
|
||||
const float root_alpha = BKE_brush_alpha_get(&sd.paint, &brush);
|
||||
const float alpha = root_alpha * root_alpha;
|
||||
const float pressure = BKE_brush_use_alpha_pressure(&brush) ? cache.pressure : 1.0f;
|
||||
float overlap = ups.overlap_factor;
|
||||
|
|
@ -2308,7 +2307,6 @@ void sculpt_apply_texture(const SculptSession &ss,
|
|||
float r_rgba[4])
|
||||
{
|
||||
const blender::ed::sculpt_paint::StrokeCache &cache = *ss.cache;
|
||||
const Scene *scene = cache.vc->scene;
|
||||
const MTex *mtex = BKE_brush_mask_texture_get(&brush, OB_MODE_SCULPT);
|
||||
|
||||
if (!mtex->tex) {
|
||||
|
|
@ -2322,7 +2320,7 @@ void sculpt_apply_texture(const SculptSession &ss,
|
|||
|
||||
if (mtex->brush_map_mode == MTEX_MAP_MODE_3D) {
|
||||
/* Get strength by feeding the vertex location directly into a texture. */
|
||||
*r_value = BKE_brush_sample_tex_3d(scene, &brush, mtex, point, r_rgba, 0, ss.tex_pool);
|
||||
*r_value = BKE_brush_sample_tex_3d(cache.paint, &brush, mtex, point, r_rgba, 0, ss.tex_pool);
|
||||
}
|
||||
else {
|
||||
/* If the active area is being applied for symmetry, flip it
|
||||
|
|
@ -2361,7 +2359,8 @@ void sculpt_apply_texture(const SculptSession &ss,
|
|||
const blender::float2 point_2d = ED_view3d_project_float_v2_m4(
|
||||
cache.vc->region, symm_point, cache.projection_mat);
|
||||
const float point_3d[3] = {point_2d[0], point_2d[1], 0.0f};
|
||||
*r_value = BKE_brush_sample_tex_3d(scene, &brush, mtex, point_3d, r_rgba, 0, ss.tex_pool);
|
||||
*r_value = BKE_brush_sample_tex_3d(
|
||||
cache.paint, &brush, mtex, point_3d, r_rgba, 0, ss.tex_pool);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3177,7 +3176,7 @@ static void push_undo_nodes(const Depsgraph &depsgraph,
|
|||
}
|
||||
|
||||
static void do_brush_action(const Depsgraph &depsgraph,
|
||||
const Scene &scene,
|
||||
const Scene & /*scene*/,
|
||||
const Sculpt &sd,
|
||||
Object &ob,
|
||||
const Brush &brush,
|
||||
|
|
@ -3278,10 +3277,10 @@ static void do_brush_action(const Depsgraph &depsgraph,
|
|||
}
|
||||
break;
|
||||
case SCULPT_BRUSH_TYPE_CREASE:
|
||||
brushes::do_crease_brush(depsgraph, scene, sd, ob, node_mask);
|
||||
brushes::do_crease_brush(depsgraph, sd, ob, node_mask);
|
||||
break;
|
||||
case SCULPT_BRUSH_TYPE_BLOB:
|
||||
brushes::do_blob_brush(depsgraph, scene, sd, ob, node_mask);
|
||||
brushes::do_blob_brush(depsgraph, sd, ob, node_mask);
|
||||
break;
|
||||
case SCULPT_BRUSH_TYPE_PINCH:
|
||||
brushes::do_pinch_brush(depsgraph, sd, ob, node_mask);
|
||||
|
|
@ -3373,8 +3372,7 @@ static void do_brush_action(const Depsgraph &depsgraph,
|
|||
brushes::do_displacement_smear_brush(depsgraph, sd, ob, node_mask);
|
||||
break;
|
||||
case SCULPT_BRUSH_TYPE_PAINT:
|
||||
color::do_paint_brush(
|
||||
scene, depsgraph, paint_mode_settings, sd, ob, node_mask, texnode_mask);
|
||||
color::do_paint_brush(depsgraph, paint_mode_settings, sd, ob, node_mask, texnode_mask);
|
||||
break;
|
||||
case SCULPT_BRUSH_TYPE_SMEAR:
|
||||
color::do_smear_brush(depsgraph, sd, ob, node_mask);
|
||||
|
|
@ -3839,7 +3837,6 @@ static void sculpt_init_mirror_clipping(const Object &ob, const SculptSession &s
|
|||
static void smooth_brush_toggle_on(const bContext *C, Paint *paint, StrokeCache *cache)
|
||||
{
|
||||
Main *bmain = CTX_data_main(C);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
Brush *cur_brush = BKE_paint_brush(paint);
|
||||
|
||||
if (cur_brush->sculpt_brush_type == SCULPT_BRUSH_TYPE_MASK) {
|
||||
|
|
@ -3869,16 +3866,16 @@ static void smooth_brush_toggle_on(const bContext *C, Paint *paint, StrokeCache
|
|||
return;
|
||||
}
|
||||
|
||||
int cur_brush_size = BKE_brush_size_get(scene, cur_brush);
|
||||
int cur_brush_size = BKE_brush_size_get(paint, cur_brush);
|
||||
|
||||
cache->saved_active_brush = cur_brush;
|
||||
|
||||
cache->saved_smooth_size = BKE_brush_size_get(scene, smooth_brush);
|
||||
BKE_brush_size_set(scene, smooth_brush, cur_brush_size);
|
||||
cache->saved_smooth_size = BKE_brush_size_get(paint, smooth_brush);
|
||||
BKE_brush_size_set(paint, smooth_brush, cur_brush_size);
|
||||
BKE_curvemapping_init(smooth_brush->curve);
|
||||
}
|
||||
|
||||
static void smooth_brush_toggle_off(const bContext *C, Paint *paint, StrokeCache *cache)
|
||||
static void smooth_brush_toggle_off(Paint *paint, StrokeCache *cache)
|
||||
{
|
||||
Brush &brush = *BKE_paint_brush(paint);
|
||||
|
||||
|
|
@ -3900,8 +3897,7 @@ static void smooth_brush_toggle_off(const bContext *C, Paint *paint, StrokeCache
|
|||
/* If saved_active_brush is not set, brush was not switched/affected in
|
||||
* smooth_brush_toggle_on(). */
|
||||
if (cache->saved_active_brush) {
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
BKE_brush_size_set(scene, &brush, cache->saved_smooth_size);
|
||||
BKE_brush_size_set(paint, &brush, cache->saved_smooth_size);
|
||||
BKE_paint_brush_set(paint, cache->saved_active_brush);
|
||||
cache->saved_active_brush = nullptr;
|
||||
}
|
||||
|
|
@ -3912,8 +3908,8 @@ static void sculpt_update_cache_invariants(
|
|||
bContext *C, Sculpt &sd, SculptSession &ss, const wmOperator &op, const float mval[2])
|
||||
{
|
||||
StrokeCache *cache = MEM_new<StrokeCache>(__func__);
|
||||
UnifiedPaintSettings *ups = &sd.paint.unified_paint_settings;
|
||||
ToolSettings *tool_settings = CTX_data_tool_settings(C);
|
||||
UnifiedPaintSettings *ups = &tool_settings->unified_paint_settings;
|
||||
const Brush *brush = BKE_paint_brush_for_read(&sd.paint);
|
||||
ViewContext *vc = paint_stroke_view_context(static_cast<PaintStroke *>(op.customdata));
|
||||
Object &ob = *CTX_data_active_object(C);
|
||||
|
|
@ -3984,6 +3980,7 @@ static void sculpt_update_cache_invariants(
|
|||
/* Truly temporary data that isn't stored in properties. */
|
||||
cache->vc = vc;
|
||||
cache->brush = brush;
|
||||
cache->paint = &sd.paint;
|
||||
|
||||
/* Cache projection matrix. */
|
||||
cache->projection_mat = ED_view3d_ob_project_mat_get(cache->vc->rv3d, &ob);
|
||||
|
|
@ -4039,7 +4036,7 @@ static void sculpt_update_cache_invariants(
|
|||
cache->accum = true;
|
||||
}
|
||||
|
||||
if (BKE_brush_color_jitter_get_settings(CTX_data_scene(C), &sd.paint, brush)) {
|
||||
if (BKE_brush_color_jitter_get_settings(&sd.paint, brush)) {
|
||||
cache->initial_hsv_jitter = seed_hsv_jitter();
|
||||
}
|
||||
cache->first_time = true;
|
||||
|
|
@ -4304,9 +4301,9 @@ static void cache_paint_invariants_update(StrokeCache &cache, const Brush &brush
|
|||
/* Initialize the stroke cache variants from operator properties. */
|
||||
static void sculpt_update_cache_variants(bContext *C, Sculpt &sd, Object &ob, PointerRNA *ptr)
|
||||
{
|
||||
Scene &scene = *CTX_data_scene(C);
|
||||
const Depsgraph &depsgraph = *CTX_data_depsgraph_pointer(C);
|
||||
UnifiedPaintSettings &ups = scene.toolsettings->unified_paint_settings;
|
||||
Paint &paint = *BKE_paint_get_active_from_context(C);
|
||||
UnifiedPaintSettings &ups = paint.unified_paint_settings;
|
||||
SculptSession &ss = *ob.sculpt;
|
||||
StrokeCache &cache = *ss.cache;
|
||||
Brush &brush = *BKE_paint_brush(&sd.paint);
|
||||
|
|
@ -4335,10 +4332,10 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt &sd, Object &ob, Po
|
|||
|
||||
/* Truly temporary data that isn't stored in properties. */
|
||||
if (SCULPT_stroke_is_first_brush_step_of_symmetry_pass(*ss.cache)) {
|
||||
cache.initial_radius = object_space_radius_get(*cache.vc, scene, brush, cache.location);
|
||||
cache.initial_radius = object_space_radius_get(*cache.vc, paint, brush, cache.location);
|
||||
|
||||
if (!BKE_brush_use_locked_size(&scene, &brush)) {
|
||||
BKE_brush_unprojected_radius_set(&scene, &brush, cache.initial_radius);
|
||||
if (!BKE_brush_use_locked_size(&paint, &brush)) {
|
||||
BKE_brush_unprojected_radius_set(&paint, &brush, cache.initial_radius);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -4652,8 +4649,8 @@ bool cursor_geometry_info_update(bContext *C,
|
|||
const bool use_sampled_normal)
|
||||
{
|
||||
Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
const Brush &brush = *BKE_paint_brush_for_read(BKE_paint_get_active_from_context(C));
|
||||
Paint *paint = BKE_paint_get_active_from_context(C);
|
||||
const Brush &brush = *BKE_paint_brush_for_read(paint);
|
||||
bool original = false;
|
||||
|
||||
ViewContext vc = ED_view3d_viewcontext_init(C, depsgraph);
|
||||
|
|
@ -4759,7 +4756,7 @@ bool cursor_geometry_info_update(bContext *C,
|
|||
ss.rv3d = vc.rv3d;
|
||||
ss.v3d = vc.v3d;
|
||||
|
||||
ss.cursor_radius = object_space_radius_get(vc, *scene, brush, out->location);
|
||||
ss.cursor_radius = object_space_radius_get(vc, *paint, brush, out->location);
|
||||
|
||||
IndexMaskMemory memory;
|
||||
const IndexMask node_mask = pbvh_gather_cursor_update(ob, original, memory);
|
||||
|
|
@ -4806,8 +4803,8 @@ static bool stroke_get_location_bvh_ex(bContext *C,
|
|||
SculptSession &ss = *ob.sculpt;
|
||||
StrokeCache *cache = ss.cache;
|
||||
const bool original = force_original || ((cache) ? !cache->accum : false);
|
||||
|
||||
const Brush &brush = *BKE_paint_brush(BKE_paint_get_active_from_context(C));
|
||||
Paint *paint = BKE_paint_get_active_from_context(C);
|
||||
const Brush &brush = *BKE_paint_brush(paint);
|
||||
|
||||
SCULPT_stroke_modifiers_check(C, ob, brush);
|
||||
|
||||
|
|
@ -4896,7 +4893,7 @@ static bool stroke_get_location_bvh_ex(bContext *C,
|
|||
|
||||
float closest_radius_sq = std::numeric_limits<float>::max();
|
||||
if (limit_closest_radius) {
|
||||
closest_radius_sq = object_space_radius_get(vc, *CTX_data_scene(C), brush, out);
|
||||
closest_radius_sq = object_space_radius_get(vc, *paint, brush, out);
|
||||
closest_radius_sq *= closest_radius_sq;
|
||||
}
|
||||
|
||||
|
|
@ -5498,10 +5495,10 @@ static void stroke_update_step(bContext *C,
|
|||
PaintStroke *stroke,
|
||||
PointerRNA *itemptr)
|
||||
{
|
||||
UnifiedPaintSettings &ups = CTX_data_tool_settings(C)->unified_paint_settings;
|
||||
const Scene &scene = *CTX_data_scene(C);
|
||||
const Depsgraph &depsgraph = *CTX_data_depsgraph_pointer(C);
|
||||
Sculpt &sd = *CTX_data_tool_settings(C)->sculpt;
|
||||
UnifiedPaintSettings &ups = sd.paint.unified_paint_settings;
|
||||
Object &ob = *CTX_data_active_object(C);
|
||||
SculptSession &ss = *ob.sculpt;
|
||||
const Brush &brush = *BKE_paint_brush_for_read(&sd.paint);
|
||||
|
|
@ -5566,7 +5563,7 @@ static void stroke_done(const bContext *C, PaintStroke * /*stroke*/)
|
|||
brush_exit_tex(sd);
|
||||
return;
|
||||
}
|
||||
UnifiedPaintSettings *ups = &CTX_data_tool_settings(C)->unified_paint_settings;
|
||||
UnifiedPaintSettings *ups = &sd.paint.unified_paint_settings;
|
||||
Brush *brush = BKE_paint_brush(&sd.paint);
|
||||
BLI_assert(brush == ss.cache->brush); /* const, so we shouldn't change. */
|
||||
ups->draw_inverted = false;
|
||||
|
|
@ -5575,7 +5572,7 @@ static void stroke_done(const bContext *C, PaintStroke * /*stroke*/)
|
|||
|
||||
/* Alt-Smooth. */
|
||||
if (ss.cache->alt_smooth) {
|
||||
smooth_brush_toggle_off(C, &sd.paint, ss.cache);
|
||||
smooth_brush_toggle_off(&sd.paint, ss.cache);
|
||||
/* Refresh the brush pointer in case we switched brush in the toggle function. */
|
||||
brush = BKE_paint_brush(&sd.paint);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2397,7 +2397,7 @@ static wmOperatorStatus sculpt_cloth_filter_invoke(bContext *C,
|
|||
const Scene &scene = *CTX_data_scene(C);
|
||||
Object &ob = *CTX_data_active_object(C);
|
||||
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
|
||||
const Sculpt &sd = *CTX_data_tool_settings(C)->sculpt;
|
||||
Sculpt &sd = *CTX_data_tool_settings(C)->sculpt;
|
||||
SculptSession &ss = *ob.sculpt;
|
||||
|
||||
const View3D *v3d = CTX_wm_view3d(C);
|
||||
|
|
|
|||
|
|
@ -62,8 +62,7 @@ float4 color_vert_get(OffsetIndices<int> faces,
|
|||
bke::GAttributeReader active_color_attribute(const Mesh &mesh);
|
||||
bke::GSpanAttributeWriter active_color_attribute_for_write(Mesh &mesh);
|
||||
|
||||
void do_paint_brush(const Scene &scene,
|
||||
const Depsgraph &depsgraph,
|
||||
void do_paint_brush(const Depsgraph &depsgraph,
|
||||
PaintModeSettings &paint_mode_settings,
|
||||
const Sculpt &sd,
|
||||
Object &ob,
|
||||
|
|
|
|||
|
|
@ -857,9 +857,8 @@ static wmOperatorStatus dyntopo_detail_size_edit_invoke(bContext *C,
|
|||
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
|
||||
ViewContext vc = ED_view3d_viewcontext_init(C, depsgraph);
|
||||
|
||||
const Scene *scene = CTX_data_scene(C);
|
||||
cd->brush_radius = object_space_radius_get(vc, *scene, *brush, ss.cursor_location);
|
||||
cd->pixel_radius = BKE_brush_size_get(scene, brush);
|
||||
cd->brush_radius = object_space_radius_get(vc, sd->paint, *brush, ss.cursor_location);
|
||||
cd->pixel_radius = BKE_brush_size_get(&sd->paint, brush);
|
||||
|
||||
/* Generates the matrix to position the gizmo in the surface of the mesh using the same
|
||||
* location and orientation as the brush cursor. */
|
||||
|
|
|
|||
|
|
@ -198,7 +198,7 @@ static float falloff_value_vertex_get(const SculptSession &ss,
|
|||
|
||||
float rgba[4];
|
||||
const float avg = BKE_brush_sample_tex_3d(
|
||||
expand_cache.scene, brush, mtex, position, rgba, 0, ss.tex_pool);
|
||||
expand_cache.paint, brush, mtex, position, rgba, 0, ss.tex_pool);
|
||||
|
||||
const float distortion = (avg - 0.5f) * expand_cache.texture_distortion_strength *
|
||||
expand_cache.max_vert_falloff;
|
||||
|
|
@ -2573,13 +2573,13 @@ static void cache_initial_config_set(bContext *C, wmOperator *op, Cache &expand_
|
|||
expand_cache.brush_gradient = false;
|
||||
|
||||
/* Texture and color data from the active Brush. */
|
||||
Scene &scene = *CTX_data_scene(C);
|
||||
const Paint *paint = BKE_paint_get_active_from_context(C);
|
||||
const Sculpt &sd = *CTX_data_tool_settings(C)->sculpt;
|
||||
expand_cache.paint = paint;
|
||||
expand_cache.brush = BKE_paint_brush_for_read(&sd.paint);
|
||||
BKE_curvemapping_init(expand_cache.brush->curve);
|
||||
copy_v4_fl(expand_cache.fill_color, 1.0f);
|
||||
copy_v3_v3(expand_cache.fill_color, BKE_brush_color_get(&scene, paint, expand_cache.brush));
|
||||
copy_v3_v3(expand_cache.fill_color, BKE_brush_color_get(paint, expand_cache.brush));
|
||||
IMB_colormanagement_srgb_to_scene_linear_v3(expand_cache.fill_color, expand_cache.fill_color);
|
||||
|
||||
expand_cache.scene = CTX_data_scene(C);
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
#include "BLI_index_mask.hh"
|
||||
#include "BLI_math_vector_types.hh"
|
||||
#include "BLI_set.hh"
|
||||
#include "DNA_scene_types.h"
|
||||
|
||||
struct Brush;
|
||||
struct Scene;
|
||||
|
|
@ -107,6 +108,7 @@ struct Cache {
|
|||
|
||||
/* Texture distortion data. */
|
||||
const Brush *brush;
|
||||
const Paint *paint;
|
||||
Scene *scene;
|
||||
// struct MTex *mtex;
|
||||
|
||||
|
|
|
|||
|
|
@ -1065,7 +1065,8 @@ static wmOperatorStatus change_visibility_exec(bContext *C, wmOperator *op)
|
|||
/* For modes that use the cursor active vertex, update the rotation origin for viewport
|
||||
* navigation. */
|
||||
if (ELEM(mode, VisibilityMode::Toggle, VisibilityMode::ShowActive)) {
|
||||
UnifiedPaintSettings *ups = &CTX_data_tool_settings(C)->unified_paint_settings;
|
||||
Paint *paint = BKE_paint_get_active_from_context(C);
|
||||
UnifiedPaintSettings *ups = &paint->unified_paint_settings;
|
||||
if (std::holds_alternative<std::monostate>(ss.active_vert())) {
|
||||
ups->last_stroke_valid = false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ struct Cache {
|
|||
|
||||
void cache_init(bContext *C,
|
||||
Object &ob,
|
||||
const Sculpt &sd,
|
||||
Sculpt &sd,
|
||||
undo::Type undo_type,
|
||||
const float mval_fl[2],
|
||||
float area_normal_radius,
|
||||
|
|
|
|||
|
|
@ -461,7 +461,7 @@ static int sculpt_color_filter_init(bContext *C, wmOperator *op)
|
|||
{
|
||||
const Scene &scene = *CTX_data_scene(C);
|
||||
Object &ob = *CTX_data_active_object(C);
|
||||
const Sculpt &sd = *CTX_data_tool_settings(C)->sculpt;
|
||||
Sculpt &sd = *CTX_data_tool_settings(C)->sculpt;
|
||||
View3D *v3d = CTX_wm_view3d(C);
|
||||
|
||||
const Base *base = CTX_data_active_base(C);
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ Cache::~Cache() = default;
|
|||
|
||||
void cache_init(bContext *C,
|
||||
Object &ob,
|
||||
const Sculpt &sd,
|
||||
Sculpt &sd,
|
||||
const undo::Type undo_type,
|
||||
const float mval_fl[2],
|
||||
float area_normal_radius,
|
||||
|
|
@ -161,8 +161,7 @@ void cache_init(bContext *C,
|
|||
copy_m4_m4(ss.filter_cache->viewmat_inv.ptr(), vc.rv3d->viewinv);
|
||||
}
|
||||
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
|
||||
UnifiedPaintSettings *ups = &sd.paint.unified_paint_settings;
|
||||
|
||||
float3 co;
|
||||
|
||||
|
|
@ -172,7 +171,7 @@ void cache_init(bContext *C,
|
|||
|
||||
float radius;
|
||||
if (brush) {
|
||||
radius = object_space_radius_get(vc, *scene, *brush, co, area_normal_radius);
|
||||
radius = object_space_radius_get(vc, sd.paint, *brush, co, area_normal_radius);
|
||||
}
|
||||
else {
|
||||
radius = paint_calc_object_space_radius(vc, co, float(ups->size) * area_normal_radius);
|
||||
|
|
@ -2378,7 +2377,7 @@ static wmOperatorStatus sculpt_mesh_filter_start(bContext *C, wmOperator *op)
|
|||
const Scene &scene = *CTX_data_scene(C);
|
||||
Object &ob = *CTX_data_active_object(C);
|
||||
Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
|
||||
const Sculpt &sd = *CTX_data_tool_settings(C)->sculpt;
|
||||
Sculpt &sd = *CTX_data_tool_settings(C)->sculpt;
|
||||
|
||||
const View3D *v3d = CTX_wm_view3d(C);
|
||||
const Base *base = CTX_data_active_base(C);
|
||||
|
|
|
|||
|
|
@ -242,6 +242,7 @@ struct StrokeCache {
|
|||
/* TODO: Clean this up! */
|
||||
ViewContext *vc = nullptr;
|
||||
const Brush *brush = nullptr;
|
||||
const Paint *paint = nullptr;
|
||||
|
||||
float special_rotation = 0.0f;
|
||||
float3 grab_delta = float3(0);
|
||||
|
|
@ -852,11 +853,11 @@ inline bool brush_uses_vector_displacement(const Brush &brush)
|
|||
brush.mtex.brush_map_mode == MTEX_MAP_MODE_AREA;
|
||||
}
|
||||
|
||||
void ensure_valid_pivot(const Object &ob, Scene &scene);
|
||||
void ensure_valid_pivot(const Object &ob, Paint &paint);
|
||||
|
||||
/** Retrieve or calculate the object space radius depending on brush settings. */
|
||||
float object_space_radius_get(const ViewContext &vc,
|
||||
const Scene &scene,
|
||||
const Paint &paint,
|
||||
const Brush &brush,
|
||||
const float3 &location,
|
||||
float scale_factor = 1.0);
|
||||
|
|
@ -879,8 +880,7 @@ bool SCULPT_paint_image_canvas_get(PaintModeSettings &paint_mode_settings,
|
|||
Object &ob,
|
||||
Image **r_image,
|
||||
ImageUser **r_image_user) ATTR_NONNULL();
|
||||
void SCULPT_do_paint_brush_image(const Scene &scene,
|
||||
const Depsgraph &depsgraph,
|
||||
void SCULPT_do_paint_brush_image(const Depsgraph &depsgraph,
|
||||
PaintModeSettings &paint_mode_settings,
|
||||
const Sculpt &sd,
|
||||
Object &ob,
|
||||
|
|
|
|||
|
|
@ -359,9 +359,9 @@ static void init_sculpt_mode_session(Main &bmain, Depsgraph &depsgraph, Scene &s
|
|||
}
|
||||
}
|
||||
|
||||
void ensure_valid_pivot(const Object &ob, Scene &scene)
|
||||
void ensure_valid_pivot(const Object &ob, Paint &paint)
|
||||
{
|
||||
UnifiedPaintSettings &ups = scene.toolsettings->unified_paint_settings;
|
||||
UnifiedPaintSettings &ups = paint.unified_paint_settings;
|
||||
const bke::pbvh::Tree *pbvh = bke::object::pbvh_get(ob);
|
||||
|
||||
/* Account for the case where no objects are evaluated. */
|
||||
|
|
@ -470,7 +470,7 @@ void object_sculpt_mode_enter(Main &bmain,
|
|||
}
|
||||
}
|
||||
|
||||
ensure_valid_pivot(ob, scene);
|
||||
ensure_valid_pivot(ob, *paint);
|
||||
|
||||
/* Flush object mode. */
|
||||
DEG_id_tag_update(&ob.id, ID_RECALC_SYNC_TO_EVAL);
|
||||
|
|
@ -664,7 +664,7 @@ static wmOperatorStatus sample_color_invoke(bContext *C, wmOperator *op, const w
|
|||
|
||||
float color_srgb[3];
|
||||
IMB_colormanagement_scene_linear_to_srgb_v3(color_srgb, active_vertex_color);
|
||||
BKE_brush_color_set(&scene, &sd.paint, &brush, color_srgb);
|
||||
BKE_brush_color_set(&sd.paint, &brush, color_srgb);
|
||||
|
||||
WM_event_add_notifier(C, NC_BRUSH | NA_EDITED, &brush);
|
||||
|
||||
|
|
|
|||
|
|
@ -350,8 +350,7 @@ static void do_color_smooth_task(const Depsgraph &depsgraph,
|
|||
}
|
||||
}
|
||||
|
||||
static void do_paint_brush_task(const Scene &scene,
|
||||
const Depsgraph &depsgraph,
|
||||
static void do_paint_brush_task(const Depsgraph &depsgraph,
|
||||
Object &object,
|
||||
const Span<float3> vert_positions,
|
||||
const Span<float3> vert_normals,
|
||||
|
|
@ -372,7 +371,7 @@ static void do_paint_brush_task(const Scene &scene,
|
|||
const StrokeCache &cache = *ss.cache;
|
||||
|
||||
const float bstrength = fabsf(ss.cache->bstrength);
|
||||
const float alpha = BKE_brush_alpha_get(&scene, &brush);
|
||||
const float alpha = BKE_brush_alpha_get(&paint, &brush);
|
||||
|
||||
const Span<int> verts = node.verts();
|
||||
|
||||
|
|
@ -429,14 +428,13 @@ static void do_paint_brush_task(const Scene &scene,
|
|||
}
|
||||
}
|
||||
|
||||
float3 brush_color_rgb = ss.cache->invert ?
|
||||
BKE_brush_secondary_color_get(&scene, &paint, &brush) :
|
||||
BKE_brush_color_get(&scene, &paint, &brush);
|
||||
float3 brush_color_rgb = ss.cache->invert ? BKE_brush_secondary_color_get(&paint, &brush) :
|
||||
BKE_brush_color_get(&paint, &brush);
|
||||
|
||||
IMB_colormanagement_srgb_to_scene_linear_v3(brush_color_rgb, brush_color_rgb);
|
||||
|
||||
const std::optional<BrushColorJitterSettings> color_jitter_settings =
|
||||
BKE_brush_color_jitter_get_settings(&scene, &paint, &brush);
|
||||
BKE_brush_color_jitter_get_settings(&paint, &brush);
|
||||
if (color_jitter_settings) {
|
||||
brush_color_rgb = BKE_paint_randomize_color(*color_jitter_settings,
|
||||
*ss.cache->initial_hsv_jitter,
|
||||
|
|
@ -554,8 +552,7 @@ static void do_sample_wet_paint_task(const Object &object,
|
|||
}
|
||||
}
|
||||
|
||||
void do_paint_brush(const Scene &scene,
|
||||
const Depsgraph &depsgraph,
|
||||
void do_paint_brush(const Depsgraph &depsgraph,
|
||||
PaintModeSettings &paint_mode_settings,
|
||||
const Sculpt &sd,
|
||||
Object &ob,
|
||||
|
|
@ -563,7 +560,7 @@ void do_paint_brush(const Scene &scene,
|
|||
const IndexMask &texnode_mask)
|
||||
{
|
||||
if (SCULPT_use_image_paint_brush(paint_mode_settings, ob)) {
|
||||
SCULPT_do_paint_brush_image(scene, depsgraph, paint_mode_settings, sd, ob, texnode_mask);
|
||||
SCULPT_do_paint_brush_image(depsgraph, paint_mode_settings, sd, ob, texnode_mask);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -684,8 +681,7 @@ void do_paint_brush(const Scene &scene,
|
|||
threading::EnumerableThreadSpecific<ColorPaintLocalData> all_tls;
|
||||
node_mask.foreach_index(GrainSize(1), [&](const int i) {
|
||||
ColorPaintLocalData &tls = all_tls.local();
|
||||
do_paint_brush_task(scene,
|
||||
depsgraph,
|
||||
do_paint_brush_task(depsgraph,
|
||||
ob,
|
||||
vert_positions,
|
||||
vert_normals,
|
||||
|
|
|
|||
|
|
@ -251,8 +251,7 @@ static BitVector<> init_uv_primitives_brush_test(SculptSession &ss,
|
|||
return brush_test;
|
||||
}
|
||||
|
||||
static void do_paint_pixels(const Scene &scene,
|
||||
const Depsgraph &depsgraph,
|
||||
static void do_paint_pixels(const Depsgraph &depsgraph,
|
||||
Object &object,
|
||||
const Paint &paint,
|
||||
const Brush &brush,
|
||||
|
|
@ -282,8 +281,8 @@ static void do_paint_pixels(const Scene &scene,
|
|||
brush_color[2] = float((hash >> 16) & 255) / 255.0f;
|
||||
#else
|
||||
copy_v3_v3(brush_color,
|
||||
ss.cache->invert ? BKE_brush_secondary_color_get(&scene, &paint, &brush) :
|
||||
BKE_brush_color_get(&scene, &paint, &brush));
|
||||
ss.cache->invert ? BKE_brush_secondary_color_get(&paint, &brush) :
|
||||
BKE_brush_color_get(&paint, &brush));
|
||||
#endif
|
||||
|
||||
brush_color[3] = 1.0f;
|
||||
|
|
@ -499,8 +498,7 @@ bool SCULPT_use_image_paint_brush(PaintModeSettings &settings, Object &ob)
|
|||
return BKE_paint_canvas_image_get(&settings, &ob, &image, &image_user);
|
||||
}
|
||||
|
||||
void SCULPT_do_paint_brush_image(const Scene &scene,
|
||||
const Depsgraph &depsgraph,
|
||||
void SCULPT_do_paint_brush_image(const Depsgraph &depsgraph,
|
||||
PaintModeSettings &paint_mode_settings,
|
||||
const Sculpt &sd,
|
||||
Object &ob,
|
||||
|
|
@ -521,7 +519,7 @@ void SCULPT_do_paint_brush_image(const Scene &scene,
|
|||
do_push_undo_tile(*image_data.image, *image_data.image_user, nodes[i]);
|
||||
});
|
||||
node_mask.foreach_index(GrainSize(1), [&](const int i) {
|
||||
do_paint_pixels(scene, depsgraph, ob, sd.paint, *brush, image_data, nodes[i]);
|
||||
do_paint_pixels(depsgraph, ob, sd.paint, *brush, image_data, nodes[i]);
|
||||
});
|
||||
|
||||
fix_non_manifold_seam_bleeding(ob, *image_data.image, *image_data.image_user, nodes, node_mask);
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ namespace blender::ed::sculpt_paint {
|
|||
void init_transform(bContext *C, Object &ob, const float mval_fl[2], const char *undo_name)
|
||||
{
|
||||
const Scene &scene = *CTX_data_scene(C);
|
||||
const Sculpt &sd = *CTX_data_tool_settings(C)->sculpt;
|
||||
Sculpt &sd = *CTX_data_tool_settings(C)->sculpt;
|
||||
SculptSession &ss = *ob.sculpt;
|
||||
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
|
||||
|
||||
|
|
@ -551,17 +551,16 @@ void update_modal_transform(bContext *C, Object &ob)
|
|||
}
|
||||
case SCULPT_TRANSFORM_MODE_RADIUS_ELASTIC: {
|
||||
const Brush &brush = *BKE_paint_brush_for_read(&sd.paint);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
float transform_radius;
|
||||
|
||||
if (BKE_brush_use_locked_size(scene, &brush)) {
|
||||
transform_radius = BKE_brush_unprojected_radius_get(scene, &brush);
|
||||
if (BKE_brush_use_locked_size(&sd.paint, &brush)) {
|
||||
transform_radius = BKE_brush_unprojected_radius_get(&sd.paint, &brush);
|
||||
}
|
||||
else {
|
||||
ViewContext vc = ED_view3d_viewcontext_init(C, depsgraph);
|
||||
|
||||
transform_radius = paint_calc_object_space_radius(
|
||||
vc, ss.init_pivot_pos, BKE_brush_size_get(scene, &brush));
|
||||
vc, ss.init_pivot_pos, BKE_brush_size_get(&sd.paint, &brush));
|
||||
}
|
||||
|
||||
transform_radius_elastic(*depsgraph, sd, ob, transform_radius);
|
||||
|
|
@ -955,7 +954,8 @@ static wmOperatorStatus set_pivot_position_exec(bContext *C, wmOperator *op)
|
|||
}
|
||||
|
||||
/* Update the viewport navigation rotation origin. */
|
||||
UnifiedPaintSettings *ups = &CTX_data_tool_settings(C)->unified_paint_settings;
|
||||
Paint *paint = BKE_paint_get_active_from_context(C);
|
||||
UnifiedPaintSettings *ups = &paint->unified_paint_settings;
|
||||
copy_v3_v3(ups->average_stroke_accum, ss.pivot_pos);
|
||||
ups->average_stroke_counter = 1;
|
||||
ups->last_stroke_valid = true;
|
||||
|
|
|
|||
|
|
@ -274,9 +274,9 @@ static void calculate_depth(gesture::GestureData &gesture_data,
|
|||
|
||||
Sculpt *sd = CTX_data_tool_settings(vc.C)->sculpt;
|
||||
Brush *brush = BKE_paint_brush(&sd->paint);
|
||||
Scene *scene = CTX_data_scene(vc.C);
|
||||
|
||||
depth_radius = object_space_radius_get(vc, *scene, *brush, trim_operation->initial_location);
|
||||
depth_radius = object_space_radius_get(
|
||||
vc, sd->paint, *brush, trim_operation->initial_location);
|
||||
}
|
||||
|
||||
depth_front = mid_point_depth - depth_radius;
|
||||
|
|
|
|||
|
|
@ -807,8 +807,8 @@ bool view3d_orbit_calc_center(bContext *C, float r_dyn_ofs[3])
|
|||
bool is_set = false;
|
||||
|
||||
const Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
|
||||
Paint *paint = BKE_paint_get_active_from_context(C);
|
||||
ViewLayer *view_layer_eval = DEG_get_evaluated_view_layer(depsgraph);
|
||||
View3D *v3d = CTX_wm_view3d(C);
|
||||
BKE_view_layer_synced_ensure(scene_eval, view_layer_eval);
|
||||
|
|
@ -819,7 +819,7 @@ bool view3d_orbit_calc_center(bContext *C, float r_dyn_ofs[3])
|
|||
/* with weight-paint + pose-mode, fall through to using calculateTransformCenter */
|
||||
((ob_act->mode & OB_MODE_WEIGHT_PAINT) && BKE_object_pose_armature_get(ob_act)) == 0)
|
||||
{
|
||||
BKE_paint_stroke_get_average(scene, ob_act_eval, lastofs);
|
||||
BKE_paint_stroke_get_average(paint, ob_act_eval, lastofs);
|
||||
is_set = true;
|
||||
}
|
||||
else if (ob_act && ELEM(ob_act->mode,
|
||||
|
|
@ -829,7 +829,7 @@ bool view3d_orbit_calc_center(bContext *C, float r_dyn_ofs[3])
|
|||
OB_MODE_VERTEX_GREASE_PENCIL,
|
||||
OB_MODE_WEIGHT_GREASE_PENCIL))
|
||||
{
|
||||
BKE_paint_stroke_get_average(scene, ob_act_eval, lastofs);
|
||||
BKE_paint_stroke_get_average(paint, ob_act_eval, lastofs);
|
||||
is_set = true;
|
||||
}
|
||||
else if (ob_act && (ob_act->mode & OB_MODE_EDIT) && (ob_act->type == OB_FONT)) {
|
||||
|
|
|
|||
|
|
@ -344,7 +344,21 @@ std::optional<blender::Bounds<float3>> view3d_calc_minmax_selected(Depsgraph *de
|
|||
else if (ob_eval && (ob_eval->mode & (OB_MODE_SCULPT | OB_MODE_VERTEX_PAINT |
|
||||
OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)))
|
||||
{
|
||||
BKE_paint_stroke_get_average(scene, ob_eval, min);
|
||||
PaintMode mode = PaintMode::Invalid;
|
||||
if (ob_eval->mode & OB_MODE_SCULPT) {
|
||||
mode = PaintMode::Sculpt;
|
||||
}
|
||||
else if (ob_eval->mode & OB_MODE_VERTEX_PAINT) {
|
||||
mode = PaintMode::Vertex;
|
||||
}
|
||||
else if (ob_eval->mode & OB_MODE_WEIGHT_PAINT) {
|
||||
mode = PaintMode::Weight;
|
||||
}
|
||||
else if (ob_eval->mode & OB_MODE_TEXTURE_PAINT) {
|
||||
mode = PaintMode::Texture3D;
|
||||
}
|
||||
Paint *paint = BKE_paint_get_active_from_paintmode(scene, mode);
|
||||
BKE_paint_stroke_get_average(paint, ob_eval, min);
|
||||
copy_v3_v3(max, min);
|
||||
changed = true;
|
||||
*r_do_zoom = false;
|
||||
|
|
|
|||
|
|
@ -286,7 +286,10 @@
|
|||
|
||||
#define _DNA_DEFAULTS_ImagePaintSettings \
|
||||
{ \
|
||||
.paint.flags = PAINT_SHOW_BRUSH, \
|
||||
.paint = { \
|
||||
.flags = PAINT_SHOW_BRUSH, \
|
||||
.unified_paint_settings = _DNA_DEFAULTS_UnifiedPaintSettings, \
|
||||
}, \
|
||||
.normal_angle = 80, \
|
||||
.seam_bleed = 2, \
|
||||
.clone_alpha = 0.5f, \
|
||||
|
|
@ -433,6 +436,7 @@
|
|||
.automasking_boundary_edges_propagation_steps = 1, \
|
||||
.flags = SCULPT_DYNTOPO_SUBDIVIDE | SCULPT_DYNTOPO_COLLAPSE,\
|
||||
.paint = {\
|
||||
.unified_paint_settings = _DNA_DEFAULTS_UnifiedPaintSettings, \
|
||||
.symmetry_flags = PAINT_SYMMETRY_FEATHER,\
|
||||
.tile_offset = {1.0f, 1.0f, 1.0f},\
|
||||
}\
|
||||
|
|
|
|||
|
|
@ -964,6 +964,118 @@ typedef struct TimeMarker {
|
|||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Unified Paint Settings
|
||||
* \{ */
|
||||
|
||||
/**
|
||||
* These settings can override the equivalent fields in the active
|
||||
* Brush for any paint mode; the flag field controls whether these
|
||||
* values are used
|
||||
*/
|
||||
typedef struct UnifiedPaintSettings {
|
||||
/** Unified radius of brush in pixels. */
|
||||
int size;
|
||||
|
||||
/** Unified radius of brush in Blender units. */
|
||||
float unprojected_radius;
|
||||
|
||||
/** Unified strength of brush. */
|
||||
float alpha;
|
||||
|
||||
/** Unified brush weight, [0, 1]. */
|
||||
float weight;
|
||||
|
||||
/** Unified brush color. */
|
||||
float rgb[3];
|
||||
/** Unified brush secondary color. */
|
||||
float secondary_rgb[3];
|
||||
|
||||
/** Unified color jitter settings */
|
||||
int color_jitter_flag;
|
||||
float hsv_jitter[3];
|
||||
|
||||
/** Color jitter pressure curves. */
|
||||
struct CurveMapping *curve_rand_hue;
|
||||
struct CurveMapping *curve_rand_saturation;
|
||||
struct CurveMapping *curve_rand_value;
|
||||
|
||||
/** Unified brush stroke input samples. */
|
||||
int input_samples;
|
||||
|
||||
/** User preferences for sculpt and paint. */
|
||||
int flag;
|
||||
char _pad[4];
|
||||
|
||||
/* TODO: Many of the following values should not be on this struct, as it causes them to be
|
||||
* persisted. PaintRuntime may be a better choice for some of these. */
|
||||
|
||||
/* Rake rotation. */
|
||||
|
||||
/** Record movement of mouse so that rake can start at an intuitive angle. */
|
||||
float last_rake[2];
|
||||
float last_rake_angle;
|
||||
|
||||
int last_stroke_valid;
|
||||
float average_stroke_accum[3];
|
||||
int average_stroke_counter;
|
||||
|
||||
/* How much brush should be rotated in the view plane, 0 means x points right, y points up.
|
||||
* The convention is that the brush's _negative_ Y axis points in the tangent direction (of the
|
||||
* mouse curve, Bezier curve, etc.) */
|
||||
float brush_rotation;
|
||||
float brush_rotation_sec;
|
||||
|
||||
/*******************************************************************************
|
||||
* all data below are used to communicate with cursor drawing and tex sampling *
|
||||
*******************************************************************************/
|
||||
int anchored_size;
|
||||
|
||||
/**
|
||||
* Normalization factor due to accumulated value of curve along spacing.
|
||||
* Calculated when brush spacing changes to dampen strength of stroke
|
||||
* if space attenuation is used.
|
||||
*/
|
||||
float overlap_factor;
|
||||
char draw_inverted;
|
||||
/** Check is there an ongoing stroke right now. */
|
||||
char stroke_active;
|
||||
|
||||
char draw_anchored;
|
||||
char do_linear_conversion;
|
||||
|
||||
/**
|
||||
* Store last location of stroke or whether the mesh was hit.
|
||||
* Valid only while stroke is active.
|
||||
*/
|
||||
float last_location[3];
|
||||
int last_hit;
|
||||
|
||||
float anchored_initial_mouse[2];
|
||||
|
||||
/**
|
||||
* Radius of brush, pre-multiplied with pressure.
|
||||
* In case of anchored brushes contains the anchored radius.
|
||||
*/
|
||||
float pixel_radius;
|
||||
float initial_pixel_radius;
|
||||
float start_pixel_radius;
|
||||
|
||||
/** Drawing pressure. */
|
||||
float size_pressure_value;
|
||||
|
||||
/** Position of mouse, used to sample the texture. */
|
||||
float tex_mouse[2];
|
||||
|
||||
/** Position of mouse, used to sample the mask texture. */
|
||||
float mask_tex_mouse[2];
|
||||
|
||||
/** ColorSpace cache to avoid locking up during sampling. */
|
||||
const ColorSpaceHandle *colorspace;
|
||||
} UnifiedPaintSettings;
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Paint Mode/Tool Data
|
||||
* \{ */
|
||||
|
|
@ -986,6 +1098,8 @@ typedef struct NamedBrushAssetReference {
|
|||
struct AssetWeakReference *brush_asset_reference;
|
||||
} NamedBrushAssetReference;
|
||||
|
||||
/** \} */
|
||||
|
||||
/**
|
||||
* For the tool system: Storage to remember the last active brush for specific tools.
|
||||
*
|
||||
|
|
@ -1054,6 +1168,7 @@ typedef struct Paint {
|
|||
|
||||
float tile_offset[3];
|
||||
char _pad2[4];
|
||||
struct UnifiedPaintSettings unified_paint_settings;
|
||||
|
||||
struct Paint_Runtime runtime;
|
||||
} Paint;
|
||||
|
|
@ -1397,115 +1512,6 @@ typedef enum eGP_Interpolate_Type {
|
|||
GP_IPO_SINE = 12,
|
||||
} eGP_Interpolate_Type;
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Unified Paint Settings
|
||||
* \{ */
|
||||
|
||||
/**
|
||||
* These settings can override the equivalent fields in the active
|
||||
* Brush for any paint mode; the flag field controls whether these
|
||||
* values are used
|
||||
*/
|
||||
typedef struct UnifiedPaintSettings {
|
||||
/** Unified radius of brush in pixels. */
|
||||
int size;
|
||||
|
||||
/** Unified radius of brush in Blender units. */
|
||||
float unprojected_radius;
|
||||
|
||||
/** Unified strength of brush. */
|
||||
float alpha;
|
||||
|
||||
/** Unified brush weight, [0, 1]. */
|
||||
float weight;
|
||||
|
||||
/** Unified brush color. */
|
||||
float rgb[3];
|
||||
/** Unified brush secondary color. */
|
||||
float secondary_rgb[3];
|
||||
|
||||
/** Unified color jitter settings */
|
||||
int color_jitter_flag;
|
||||
float hsv_jitter[3];
|
||||
|
||||
/** Color jitter pressure curves. */
|
||||
struct CurveMapping *curve_rand_hue;
|
||||
struct CurveMapping *curve_rand_saturation;
|
||||
struct CurveMapping *curve_rand_value;
|
||||
|
||||
/** Unified brush stroke input samples. */
|
||||
int input_samples;
|
||||
|
||||
/** User preferences for sculpt and paint. */
|
||||
int flag;
|
||||
char _pad[4];
|
||||
|
||||
/* Rake rotation. */
|
||||
|
||||
/** Record movement of mouse so that rake can start at an intuitive angle. */
|
||||
float last_rake[2];
|
||||
float last_rake_angle;
|
||||
|
||||
int last_stroke_valid;
|
||||
float average_stroke_accum[3];
|
||||
int average_stroke_counter;
|
||||
|
||||
/* How much brush should be rotated in the view plane, 0 means x points right, y points up.
|
||||
* The convention is that the brush's _negative_ Y axis points in the tangent direction (of the
|
||||
* mouse curve, Bezier curve, etc.) */
|
||||
float brush_rotation;
|
||||
float brush_rotation_sec;
|
||||
|
||||
/*******************************************************************************
|
||||
* all data below are used to communicate with cursor drawing and tex sampling *
|
||||
*******************************************************************************/
|
||||
int anchored_size;
|
||||
|
||||
/**
|
||||
* Normalization factor due to accumulated value of curve along spacing.
|
||||
* Calculated when brush spacing changes to dampen strength of stroke
|
||||
* if space attenuation is used.
|
||||
*/
|
||||
float overlap_factor;
|
||||
char draw_inverted;
|
||||
/** Check is there an ongoing stroke right now. */
|
||||
char stroke_active;
|
||||
|
||||
char draw_anchored;
|
||||
char do_linear_conversion;
|
||||
|
||||
/**
|
||||
* Store last location of stroke or whether the mesh was hit.
|
||||
* Valid only while stroke is active.
|
||||
*/
|
||||
float last_location[3];
|
||||
int last_hit;
|
||||
|
||||
float anchored_initial_mouse[2];
|
||||
|
||||
/**
|
||||
* Radius of brush, pre-multiplied with pressure.
|
||||
* In case of anchored brushes contains the anchored radius.
|
||||
*/
|
||||
float pixel_radius;
|
||||
float initial_pixel_radius;
|
||||
float start_pixel_radius;
|
||||
|
||||
/** Drawing pressure. */
|
||||
float size_pressure_value;
|
||||
|
||||
/** Position of mouse, used to sample the texture. */
|
||||
float tex_mouse[2];
|
||||
|
||||
/** Position of mouse, used to sample the mask texture. */
|
||||
float mask_tex_mouse[2];
|
||||
|
||||
/** ColorSpace cache to avoid locking up during sampling. */
|
||||
const ColorSpaceHandle *colorspace;
|
||||
} UnifiedPaintSettings;
|
||||
|
||||
typedef struct CurvePaintSettings {
|
||||
char curve_type;
|
||||
char flag;
|
||||
|
|
@ -1805,8 +1811,11 @@ typedef struct ToolSettings {
|
|||
float sculpt_paint_unified_unprojected_radius DNA_DEPRECATED;
|
||||
float sculpt_paint_unified_alpha DNA_DEPRECATED;
|
||||
|
||||
/** Unified Paint Settings. */
|
||||
struct UnifiedPaintSettings unified_paint_settings;
|
||||
/**
|
||||
* Unified Paint Settings.
|
||||
* \warning Deprecated, see the per-paint mode values on the `Paint` struct.
|
||||
*/
|
||||
struct UnifiedPaintSettings unified_paint_settings DNA_DEPRECATED;
|
||||
|
||||
struct CurvePaintSettings curve_paint_settings;
|
||||
|
||||
|
|
|
|||
|
|
@ -2426,44 +2426,6 @@ static KeyingSet *rna_Scene_keying_set_new(Scene *sce,
|
|||
}
|
||||
}
|
||||
|
||||
static void rna_UnifiedPaintSettings_update(bContext *C, PointerRNA * /*ptr*/)
|
||||
{
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
ViewLayer *view_layer = CTX_data_view_layer(C);
|
||||
Brush *br = BKE_paint_brush(BKE_paint_get_active(scene, view_layer));
|
||||
WM_main_add_notifier(NC_BRUSH | NA_EDITED, br);
|
||||
}
|
||||
|
||||
static void rna_UnifiedPaintSettings_size_set(PointerRNA *ptr, int value)
|
||||
{
|
||||
UnifiedPaintSettings *ups = static_cast<UnifiedPaintSettings *>(ptr->data);
|
||||
|
||||
/* scale unprojected radius so it stays consistent with brush size */
|
||||
BKE_brush_scale_unprojected_radius(&ups->unprojected_radius, value, ups->size);
|
||||
ups->size = value;
|
||||
}
|
||||
|
||||
static void rna_UnifiedPaintSettings_unprojected_radius_set(PointerRNA *ptr, float value)
|
||||
{
|
||||
UnifiedPaintSettings *ups = static_cast<UnifiedPaintSettings *>(ptr->data);
|
||||
|
||||
/* scale brush size so it stays consistent with unprojected_radius */
|
||||
BKE_brush_scale_size(&ups->size, value, ups->unprojected_radius);
|
||||
ups->unprojected_radius = value;
|
||||
}
|
||||
|
||||
static void rna_UnifiedPaintSettings_radius_update(bContext *C, PointerRNA *ptr)
|
||||
{
|
||||
/* changing the unified size should invalidate the overlay but also update the brush */
|
||||
BKE_paint_invalidate_overlay_all();
|
||||
rna_UnifiedPaintSettings_update(C, ptr);
|
||||
}
|
||||
|
||||
static std::optional<std::string> rna_UnifiedPaintSettings_path(const PointerRNA * /*ptr*/)
|
||||
{
|
||||
return "tool_settings.unified_paint_settings";
|
||||
}
|
||||
|
||||
static std::optional<std::string> rna_CurvePaintSettings_path(const PointerRNA * /*ptr*/)
|
||||
{
|
||||
return "tool_settings.curve_paint_settings";
|
||||
|
|
@ -4235,12 +4197,6 @@ static void rna_def_tool_settings(BlenderRNA *brna)
|
|||
RNA_def_property_ui_text(prop, "Normal Vector", "Normal vector used to copy, add or multiply");
|
||||
RNA_def_property_ui_range(prop, -10000.0, 10000.0, 1, 3);
|
||||
|
||||
/* Unified Paint Settings */
|
||||
prop = RNA_def_property(srna, "unified_paint_settings", PROP_POINTER, PROP_NONE);
|
||||
RNA_def_property_flag(prop, PROP_NEVER_NULL);
|
||||
RNA_def_property_struct_type(prop, "UnifiedPaintSettings");
|
||||
RNA_def_property_ui_text(prop, "Unified Paint Settings", nullptr);
|
||||
|
||||
/* Curve Paint Settings */
|
||||
prop = RNA_def_property(srna, "curve_paint_settings", PROP_POINTER, PROP_NONE);
|
||||
RNA_def_property_flag(prop, PROP_NEVER_NULL);
|
||||
|
|
@ -4392,192 +4348,6 @@ static void rna_def_sequencer_tool_settings(BlenderRNA *brna)
|
|||
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, nullptr);
|
||||
}
|
||||
|
||||
static void rna_def_unified_paint_settings(BlenderRNA *brna)
|
||||
{
|
||||
StructRNA *srna;
|
||||
PropertyRNA *prop;
|
||||
|
||||
static const EnumPropertyItem brush_size_unit_items[] = {
|
||||
{0, "VIEW", 0, "View", "Measure brush size relative to the view"},
|
||||
{UNIFIED_PAINT_BRUSH_LOCK_SIZE,
|
||||
"SCENE",
|
||||
0,
|
||||
"Scene",
|
||||
"Measure brush size relative to the scene"},
|
||||
{0, nullptr, 0, nullptr, nullptr},
|
||||
};
|
||||
|
||||
srna = RNA_def_struct(brna, "UnifiedPaintSettings", nullptr);
|
||||
RNA_def_struct_path_func(srna, "rna_UnifiedPaintSettings_path");
|
||||
RNA_def_struct_ui_text(
|
||||
srna, "Unified Paint Settings", "Overrides for some of the active brush's settings");
|
||||
RNA_def_struct_clear_flag(srna, STRUCT_UNDO);
|
||||
|
||||
/* high-level flags to enable or disable unified paint settings */
|
||||
prop = RNA_def_property(srna, "use_unified_size", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, nullptr, "flag", UNIFIED_PAINT_SIZE);
|
||||
RNA_def_property_ui_text(prop,
|
||||
"Use Unified Radius",
|
||||
"Instead of per-brush radius, the radius is shared across brushes");
|
||||
|
||||
prop = RNA_def_property(srna, "use_unified_strength", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, nullptr, "flag", UNIFIED_PAINT_ALPHA);
|
||||
RNA_def_property_ui_text(prop,
|
||||
"Use Unified Strength",
|
||||
"Instead of per-brush strength, the strength is shared across brushes");
|
||||
|
||||
prop = RNA_def_property(srna, "use_unified_weight", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, nullptr, "flag", UNIFIED_PAINT_WEIGHT);
|
||||
RNA_def_property_ui_text(prop,
|
||||
"Use Unified Weight",
|
||||
"Instead of per-brush weight, the weight is shared across brushes");
|
||||
|
||||
prop = RNA_def_property(srna, "use_unified_color", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, nullptr, "flag", UNIFIED_PAINT_COLOR);
|
||||
RNA_def_property_ui_text(
|
||||
prop, "Use Unified Color", "Instead of per-brush color, the color is shared across brushes");
|
||||
|
||||
prop = RNA_def_property(srna, "use_unified_input_samples", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, nullptr, "flag", UNIFIED_PAINT_INPUT_SAMPLES);
|
||||
RNA_def_property_ui_text(
|
||||
prop,
|
||||
"Use Unified Input Samples",
|
||||
"Instead of per-brush input samples, the value is shared across brushes");
|
||||
|
||||
/* unified paint settings that override the equivalent settings
|
||||
* from the active brush */
|
||||
prop = RNA_def_property(srna, "size", PROP_INT, PROP_PIXEL);
|
||||
RNA_def_property_int_funcs(prop, nullptr, "rna_UnifiedPaintSettings_size_set", nullptr);
|
||||
RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
|
||||
RNA_def_property_range(prop, 1, MAX_BRUSH_PIXEL_RADIUS * 10);
|
||||
RNA_def_property_ui_range(prop, 1, MAX_BRUSH_PIXEL_RADIUS, 1, -1);
|
||||
RNA_def_property_ui_text(prop, "Radius", "Radius of the brush");
|
||||
RNA_def_property_update(prop, 0, "rna_UnifiedPaintSettings_radius_update");
|
||||
|
||||
prop = RNA_def_property(srna, "unprojected_radius", PROP_FLOAT, PROP_DISTANCE);
|
||||
RNA_def_property_float_funcs(
|
||||
prop, nullptr, "rna_UnifiedPaintSettings_unprojected_radius_set", nullptr);
|
||||
RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
|
||||
RNA_def_property_range(prop, 0.001, FLT_MAX);
|
||||
RNA_def_property_ui_range(prop, 0.001, 1, 1, -1);
|
||||
RNA_def_property_ui_text(prop, "Unprojected Radius", "Radius of brush in Blender units");
|
||||
RNA_def_property_update(prop, 0, "rna_UnifiedPaintSettings_radius_update");
|
||||
|
||||
prop = RNA_def_property(srna, "strength", PROP_FLOAT, PROP_FACTOR);
|
||||
RNA_def_property_float_sdna(prop, nullptr, "alpha");
|
||||
RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
|
||||
RNA_def_property_range(prop, 0.0f, 10.0f);
|
||||
RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.001, 3);
|
||||
RNA_def_property_ui_text(
|
||||
prop, "Strength", "How powerful the effect of the brush is when applied");
|
||||
RNA_def_property_update(prop, 0, "rna_UnifiedPaintSettings_update");
|
||||
|
||||
prop = RNA_def_property(srna, "weight", PROP_FLOAT, PROP_FACTOR);
|
||||
RNA_def_property_float_sdna(prop, nullptr, "weight");
|
||||
RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
|
||||
RNA_def_property_range(prop, 0.0f, 1.0f);
|
||||
RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.001, 3);
|
||||
RNA_def_property_ui_text(prop, "Weight", "Weight to assign in vertex groups");
|
||||
RNA_def_property_update(prop, 0, "rna_UnifiedPaintSettings_update");
|
||||
|
||||
prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR_GAMMA);
|
||||
RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
|
||||
RNA_def_property_range(prop, 0.0, 1.0);
|
||||
RNA_def_property_float_sdna(prop, nullptr, "rgb");
|
||||
RNA_def_property_ui_text(prop, "Color", "");
|
||||
RNA_def_property_update(prop, 0, "rna_UnifiedPaintSettings_update");
|
||||
|
||||
prop = RNA_def_property(srna, "secondary_color", PROP_FLOAT, PROP_COLOR_GAMMA);
|
||||
RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
|
||||
RNA_def_property_range(prop, 0.0, 1.0);
|
||||
RNA_def_property_float_sdna(prop, nullptr, "secondary_rgb");
|
||||
RNA_def_property_ui_text(prop, "Secondary Color", "");
|
||||
RNA_def_property_update(prop, 0, "rna_UnifiedPaintSettings_update");
|
||||
|
||||
prop = RNA_def_property(srna, "use_color_jitter", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
|
||||
RNA_def_property_boolean_sdna(prop, nullptr, "flag", UNIFIED_PAINT_COLOR_JITTER);
|
||||
RNA_def_property_ui_text(prop, "Use Color Jitter", "Jitter brush color");
|
||||
RNA_def_property_update(prop, 0, "rna_UnifiedPaintSettings_update");
|
||||
|
||||
prop = RNA_def_property(srna, "hue_jitter", PROP_FLOAT, PROP_NONE);
|
||||
RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
|
||||
RNA_def_property_float_sdna(prop, nullptr, "hsv_jitter[0]");
|
||||
RNA_def_property_range(prop, 0, 1.0f);
|
||||
RNA_def_property_ui_range(prop, 0, 1, 0.05, 2);
|
||||
RNA_def_property_ui_text(prop, "Hue Jitter", "Color jitter effect on hue");
|
||||
RNA_def_property_update(prop, 0, "rna_UnifiedPaintSettings_update");
|
||||
|
||||
prop = RNA_def_property(srna, "saturation_jitter", PROP_FLOAT, PROP_NONE);
|
||||
RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
|
||||
RNA_def_property_float_sdna(prop, nullptr, "hsv_jitter[1]");
|
||||
RNA_def_property_range(prop, 0, 1.0f);
|
||||
RNA_def_property_ui_range(prop, 0, 1, 0.05, 2);
|
||||
RNA_def_property_ui_text(prop, "Saturation Jitter", "Color jitter effect on saturation");
|
||||
RNA_def_property_update(prop, 0, "rna_UnifiedPaintSettings_update");
|
||||
|
||||
prop = RNA_def_property(srna, "value_jitter", PROP_FLOAT, PROP_NONE);
|
||||
RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
|
||||
RNA_def_property_float_sdna(prop, nullptr, "hsv_jitter[2]");
|
||||
RNA_def_property_range(prop, 0, 1.0f);
|
||||
RNA_def_property_ui_range(prop, 0, 1, 0.05, 2);
|
||||
RNA_def_property_ui_text(prop, "Value Jitter", "Color jitter effect on value");
|
||||
RNA_def_property_update(prop, 0, "rna_UnifiedPaintSettings_update");
|
||||
|
||||
prop = RNA_def_property(srna, "use_stroke_random_hue", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(
|
||||
prop, nullptr, "color_jitter_flag", BRUSH_COLOR_JITTER_USE_HUE_AT_STROKE);
|
||||
RNA_def_property_ui_icon(prop, ICON_GP_SELECT_STROKES, 0);
|
||||
RNA_def_property_ui_text(prop, "Stroke Random", "Use randomness at stroke level");
|
||||
|
||||
prop = RNA_def_property(srna, "use_stroke_random_sat", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(
|
||||
prop, nullptr, "color_jitter_flag", BRUSH_COLOR_JITTER_USE_SAT_AT_STROKE);
|
||||
RNA_def_property_ui_icon(prop, ICON_GP_SELECT_STROKES, 0);
|
||||
RNA_def_property_ui_text(prop, "Stroke Random", "Use randomness at stroke level");
|
||||
|
||||
prop = RNA_def_property(srna, "use_stroke_random_val", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(
|
||||
prop, nullptr, "color_jitter_flag", BRUSH_COLOR_JITTER_USE_VAL_AT_STROKE);
|
||||
RNA_def_property_ui_icon(prop, ICON_GP_SELECT_STROKES, 0);
|
||||
RNA_def_property_ui_text(prop, "Stroke Random", "Use randomness at stroke level");
|
||||
|
||||
prop = RNA_def_property(srna, "use_random_press_hue", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(
|
||||
prop, nullptr, "color_jitter_flag", BRUSH_COLOR_JITTER_USE_HUE_RAND_PRESS);
|
||||
RNA_def_property_ui_icon(prop, ICON_STYLUS_PRESSURE, 0);
|
||||
RNA_def_property_ui_text(prop, "Use Pressure", "Use pressure to modulate randomness");
|
||||
|
||||
prop = RNA_def_property(srna, "use_random_press_sat", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(
|
||||
prop, nullptr, "color_jitter_flag", BRUSH_COLOR_JITTER_USE_SAT_RAND_PRESS);
|
||||
RNA_def_property_ui_icon(prop, ICON_STYLUS_PRESSURE, 0);
|
||||
RNA_def_property_ui_text(prop, "Use Pressure", "Use pressure to modulate randomness");
|
||||
|
||||
prop = RNA_def_property(srna, "use_random_press_val", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(
|
||||
prop, nullptr, "color_jitter_flag", BRUSH_COLOR_JITTER_USE_VAL_RAND_PRESS);
|
||||
RNA_def_property_ui_icon(prop, ICON_STYLUS_PRESSURE, 0);
|
||||
RNA_def_property_ui_text(prop, "Use Pressure", "Use pressure to modulate randomness");
|
||||
|
||||
prop = RNA_def_property(srna, "input_samples", PROP_INT, PROP_UNSIGNED);
|
||||
RNA_def_property_int_sdna(prop, nullptr, "input_samples");
|
||||
RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
|
||||
RNA_def_property_range(prop, 1, PAINT_MAX_INPUT_SAMPLES);
|
||||
RNA_def_property_ui_range(prop, 1, PAINT_MAX_INPUT_SAMPLES, 1, -1);
|
||||
RNA_def_property_ui_text(
|
||||
prop,
|
||||
"Input Samples",
|
||||
"Number of input samples to average together to smooth the brush stroke");
|
||||
RNA_def_property_update(prop, 0, "rna_UnifiedPaintSettings_update");
|
||||
|
||||
prop = RNA_def_property(srna, "use_locked_size", PROP_ENUM, PROP_NONE); /* as an enum */
|
||||
RNA_def_property_enum_bitflag_sdna(prop, nullptr, "flag");
|
||||
RNA_def_property_enum_items(prop, brush_size_unit_items);
|
||||
RNA_def_property_ui_text(
|
||||
prop, "Radius Unit", "Measure brush size relative to the view or the scene");
|
||||
}
|
||||
|
||||
static void rna_def_curve_paint_settings(BlenderRNA *brna)
|
||||
{
|
||||
StructRNA *srna;
|
||||
|
|
@ -9332,7 +9102,6 @@ void RNA_def_scene(BlenderRNA *brna)
|
|||
RNA_define_animate_sdna(false);
|
||||
rna_def_tool_settings(brna);
|
||||
rna_def_gpencil_interpolate(brna);
|
||||
rna_def_unified_paint_settings(brna);
|
||||
rna_def_curve_paint_settings(brna);
|
||||
rna_def_sequencer_tool_settings(brna);
|
||||
rna_def_statvis(brna);
|
||||
|
|
|
|||
|
|
@ -101,6 +101,7 @@ const EnumPropertyItem rna_enum_symmetrize_direction_items[] = {
|
|||
#ifdef RNA_RUNTIME
|
||||
# include "MEM_guardedalloc.h"
|
||||
|
||||
# include "BKE_brush.hh"
|
||||
# include "BKE_collection.hh"
|
||||
# include "BKE_colortools.hh"
|
||||
# include "BKE_context.hh"
|
||||
|
|
@ -514,6 +515,98 @@ static void rna_Sculpt_automasking_cavity_set(PointerRNA *ptr, bool val)
|
|||
sd->automasking_flags &= ~BRUSH_AUTOMASKING_CAVITY_NORMAL;
|
||||
}
|
||||
}
|
||||
|
||||
static void rna_UnifiedPaintSettings_update(bContext *C, PointerRNA * /*ptr*/)
|
||||
{
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
ViewLayer *view_layer = CTX_data_view_layer(C);
|
||||
Brush *br = BKE_paint_brush(BKE_paint_get_active(scene, view_layer));
|
||||
WM_main_add_notifier(NC_BRUSH | NA_EDITED, br);
|
||||
}
|
||||
|
||||
static void rna_UnifiedPaintSettings_size_set(PointerRNA *ptr, int value)
|
||||
{
|
||||
UnifiedPaintSettings *ups = static_cast<UnifiedPaintSettings *>(ptr->data);
|
||||
|
||||
/* scale unprojected radius so it stays consistent with brush size */
|
||||
BKE_brush_scale_unprojected_radius(&ups->unprojected_radius, value, ups->size);
|
||||
ups->size = value;
|
||||
}
|
||||
|
||||
static void rna_UnifiedPaintSettings_unprojected_radius_set(PointerRNA *ptr, float value)
|
||||
{
|
||||
UnifiedPaintSettings *ups = static_cast<UnifiedPaintSettings *>(ptr->data);
|
||||
|
||||
/* scale brush size so it stays consistent with unprojected_radius */
|
||||
BKE_brush_scale_size(&ups->size, value, ups->unprojected_radius);
|
||||
ups->unprojected_radius = value;
|
||||
}
|
||||
|
||||
static void rna_UnifiedPaintSettings_radius_update(bContext *C, PointerRNA *ptr)
|
||||
{
|
||||
/* changing the unified size should invalidate the overlay but also update the brush */
|
||||
BKE_paint_invalidate_overlay_all();
|
||||
rna_UnifiedPaintSettings_update(C, ptr);
|
||||
}
|
||||
|
||||
static const UnifiedPaintSettings *rna_UnifiedPaintSettings_address_get(const Paint *paint)
|
||||
{
|
||||
if (!paint) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return &paint->unified_paint_settings;
|
||||
}
|
||||
|
||||
static std::optional<std::string> rna_UnifiedPaintSettings_path(const PointerRNA *ptr)
|
||||
{
|
||||
const Scene *scene = reinterpret_cast<Scene *>(ptr->owner_id);
|
||||
const ToolSettings *tool_settings = scene ? scene->toolsettings : nullptr;
|
||||
if (tool_settings == nullptr) {
|
||||
return std::nullopt;
|
||||
}
|
||||
if (rna_UnifiedPaintSettings_address_get(reinterpret_cast<Paint *>(tool_settings->vpaint)) ==
|
||||
ptr->data)
|
||||
{
|
||||
return "tool_settings.vertex_paint.unified_paint_settings";
|
||||
}
|
||||
if (rna_UnifiedPaintSettings_address_get(reinterpret_cast<Paint *>(tool_settings->wpaint)) ==
|
||||
ptr->data)
|
||||
{
|
||||
return "tool_settings.weight_paint.unified_paint_settings";
|
||||
}
|
||||
if (rna_UnifiedPaintSettings_address_get(reinterpret_cast<Paint *>(tool_settings->sculpt)) ==
|
||||
ptr->data)
|
||||
{
|
||||
return "tool_settings.sculpt.unified_paint_settings";
|
||||
}
|
||||
if (rna_UnifiedPaintSettings_address_get(reinterpret_cast<Paint *>(tool_settings->gp_paint)) ==
|
||||
ptr->data)
|
||||
{
|
||||
return "tool_settings.gpencil_paint.unified_paint_settings";
|
||||
}
|
||||
if (rna_UnifiedPaintSettings_address_get(
|
||||
reinterpret_cast<Paint *>(tool_settings->gp_vertexpaint)) == ptr->data)
|
||||
{
|
||||
return "tool_settings.gpencil_vertex_paint.unified_paint_settings";
|
||||
}
|
||||
if (rna_UnifiedPaintSettings_address_get(
|
||||
reinterpret_cast<Paint *>(tool_settings->gp_sculptpaint)) == ptr->data)
|
||||
{
|
||||
return "tool_settings.gpencil_sculpt_paint.unified_paint_settings";
|
||||
}
|
||||
if (rna_UnifiedPaintSettings_address_get(
|
||||
reinterpret_cast<Paint *>(tool_settings->gp_weightpaint)) == ptr->data)
|
||||
{
|
||||
return "tool_settings.gpencil_weight_paint.unified_paint_settings";
|
||||
}
|
||||
if (rna_UnifiedPaintSettings_address_get(
|
||||
reinterpret_cast<Paint *>(tool_settings->curves_sculpt)) == ptr->data)
|
||||
{
|
||||
return "tool_settings.curves_sculpt.unified_paint_settings";
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
#else
|
||||
|
||||
static void rna_def_paint_curve(BlenderRNA *brna)
|
||||
|
|
@ -652,6 +745,198 @@ static void rna_def_paint(BlenderRNA *brna)
|
|||
RNA_def_property_boolean_sdna(prop, nullptr, "symmetry_flags", PAINT_TILE_Z);
|
||||
RNA_def_property_ui_text(prop, "Tile Z", "Tile along Z axis");
|
||||
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, nullptr);
|
||||
|
||||
/* Unified Paint Settings */
|
||||
prop = RNA_def_property(srna, "unified_paint_settings", PROP_POINTER, PROP_NONE);
|
||||
RNA_def_property_flag(prop, PROP_NEVER_NULL);
|
||||
RNA_def_property_struct_type(prop, "UnifiedPaintSettings");
|
||||
RNA_def_property_ui_text(prop, "Unified Paint Settings", nullptr);
|
||||
}
|
||||
|
||||
static void rna_def_unified_paint_settings(BlenderRNA *brna)
|
||||
{
|
||||
StructRNA *srna;
|
||||
PropertyRNA *prop;
|
||||
|
||||
static const EnumPropertyItem brush_size_unit_items[] = {
|
||||
{0, "VIEW", 0, "View", "Measure brush size relative to the view"},
|
||||
{UNIFIED_PAINT_BRUSH_LOCK_SIZE,
|
||||
"SCENE",
|
||||
0,
|
||||
"Scene",
|
||||
"Measure brush size relative to the scene"},
|
||||
{0, nullptr, 0, nullptr, nullptr},
|
||||
};
|
||||
|
||||
srna = RNA_def_struct(brna, "UnifiedPaintSettings", nullptr);
|
||||
RNA_def_struct_path_func(srna, "rna_UnifiedPaintSettings_path");
|
||||
RNA_def_struct_ui_text(
|
||||
srna, "Unified Paint Settings", "Overrides for some of the active brush's settings");
|
||||
RNA_def_struct_clear_flag(srna, STRUCT_UNDO);
|
||||
|
||||
/* high-level flags to enable or disable unified paint settings */
|
||||
prop = RNA_def_property(srna, "use_unified_size", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, nullptr, "flag", UNIFIED_PAINT_SIZE);
|
||||
RNA_def_property_ui_text(prop,
|
||||
"Use Unified Radius",
|
||||
"Instead of per-brush radius, the radius is shared across brushes");
|
||||
|
||||
prop = RNA_def_property(srna, "use_unified_strength", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, nullptr, "flag", UNIFIED_PAINT_ALPHA);
|
||||
RNA_def_property_ui_text(prop,
|
||||
"Use Unified Strength",
|
||||
"Instead of per-brush strength, the strength is shared across brushes");
|
||||
|
||||
prop = RNA_def_property(srna, "use_unified_weight", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, nullptr, "flag", UNIFIED_PAINT_WEIGHT);
|
||||
RNA_def_property_ui_text(prop,
|
||||
"Use Unified Weight",
|
||||
"Instead of per-brush weight, the weight is shared across brushes");
|
||||
|
||||
prop = RNA_def_property(srna, "use_unified_color", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, nullptr, "flag", UNIFIED_PAINT_COLOR);
|
||||
RNA_def_property_ui_text(
|
||||
prop, "Use Unified Color", "Instead of per-brush color, the color is shared across brushes");
|
||||
|
||||
prop = RNA_def_property(srna, "use_unified_input_samples", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, nullptr, "flag", UNIFIED_PAINT_INPUT_SAMPLES);
|
||||
RNA_def_property_ui_text(
|
||||
prop,
|
||||
"Use Unified Input Samples",
|
||||
"Instead of per-brush input samples, the value is shared across brushes");
|
||||
|
||||
/* unified paint settings that override the equivalent settings
|
||||
* from the active brush */
|
||||
prop = RNA_def_property(srna, "size", PROP_INT, PROP_PIXEL);
|
||||
RNA_def_property_int_funcs(prop, nullptr, "rna_UnifiedPaintSettings_size_set", nullptr);
|
||||
RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
|
||||
RNA_def_property_range(prop, 1, MAX_BRUSH_PIXEL_RADIUS * 10);
|
||||
RNA_def_property_ui_range(prop, 1, MAX_BRUSH_PIXEL_RADIUS, 1, -1);
|
||||
RNA_def_property_ui_text(prop, "Radius", "Radius of the brush");
|
||||
RNA_def_property_update(prop, 0, "rna_UnifiedPaintSettings_radius_update");
|
||||
|
||||
prop = RNA_def_property(srna, "unprojected_radius", PROP_FLOAT, PROP_DISTANCE);
|
||||
RNA_def_property_float_funcs(
|
||||
prop, nullptr, "rna_UnifiedPaintSettings_unprojected_radius_set", nullptr);
|
||||
RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
|
||||
RNA_def_property_range(prop, 0.001, FLT_MAX);
|
||||
RNA_def_property_ui_range(prop, 0.001, 1, 1, -1);
|
||||
RNA_def_property_ui_text(prop, "Unprojected Radius", "Radius of brush in Blender units");
|
||||
RNA_def_property_update(prop, 0, "rna_UnifiedPaintSettings_radius_update");
|
||||
|
||||
prop = RNA_def_property(srna, "strength", PROP_FLOAT, PROP_FACTOR);
|
||||
RNA_def_property_float_sdna(prop, nullptr, "alpha");
|
||||
RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
|
||||
RNA_def_property_range(prop, 0.0f, 10.0f);
|
||||
RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.001, 3);
|
||||
RNA_def_property_ui_text(
|
||||
prop, "Strength", "How powerful the effect of the brush is when applied");
|
||||
RNA_def_property_update(prop, 0, "rna_UnifiedPaintSettings_update");
|
||||
|
||||
prop = RNA_def_property(srna, "weight", PROP_FLOAT, PROP_FACTOR);
|
||||
RNA_def_property_float_sdna(prop, nullptr, "weight");
|
||||
RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
|
||||
RNA_def_property_range(prop, 0.0f, 1.0f);
|
||||
RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.001, 3);
|
||||
RNA_def_property_ui_text(prop, "Weight", "Weight to assign in vertex groups");
|
||||
RNA_def_property_update(prop, 0, "rna_UnifiedPaintSettings_update");
|
||||
|
||||
prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR_GAMMA);
|
||||
RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
|
||||
RNA_def_property_range(prop, 0.0, 1.0);
|
||||
RNA_def_property_float_sdna(prop, nullptr, "rgb");
|
||||
RNA_def_property_ui_text(prop, "Color", "");
|
||||
RNA_def_property_update(prop, 0, "rna_UnifiedPaintSettings_update");
|
||||
|
||||
prop = RNA_def_property(srna, "secondary_color", PROP_FLOAT, PROP_COLOR_GAMMA);
|
||||
RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
|
||||
RNA_def_property_range(prop, 0.0, 1.0);
|
||||
RNA_def_property_float_sdna(prop, nullptr, "secondary_rgb");
|
||||
RNA_def_property_ui_text(prop, "Secondary Color", "");
|
||||
RNA_def_property_update(prop, 0, "rna_UnifiedPaintSettings_update");
|
||||
|
||||
prop = RNA_def_property(srna, "use_color_jitter", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
|
||||
RNA_def_property_boolean_sdna(prop, nullptr, "flag", UNIFIED_PAINT_COLOR_JITTER);
|
||||
RNA_def_property_ui_text(prop, "Use Color Jitter", "Jitter brush color");
|
||||
RNA_def_property_update(prop, 0, "rna_UnifiedPaintSettings_update");
|
||||
|
||||
prop = RNA_def_property(srna, "hue_jitter", PROP_FLOAT, PROP_NONE);
|
||||
RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
|
||||
RNA_def_property_float_sdna(prop, nullptr, "hsv_jitter[0]");
|
||||
RNA_def_property_range(prop, 0, 1.0f);
|
||||
RNA_def_property_ui_range(prop, 0, 1, 0.05, 2);
|
||||
RNA_def_property_ui_text(prop, "Hue Jitter", "Color jitter effect on hue");
|
||||
RNA_def_property_update(prop, 0, "rna_UnifiedPaintSettings_update");
|
||||
|
||||
prop = RNA_def_property(srna, "saturation_jitter", PROP_FLOAT, PROP_NONE);
|
||||
RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
|
||||
RNA_def_property_float_sdna(prop, nullptr, "hsv_jitter[1]");
|
||||
RNA_def_property_range(prop, 0, 1.0f);
|
||||
RNA_def_property_ui_range(prop, 0, 1, 0.05, 2);
|
||||
RNA_def_property_ui_text(prop, "Saturation Jitter", "Color jitter effect on saturation");
|
||||
RNA_def_property_update(prop, 0, "rna_UnifiedPaintSettings_update");
|
||||
|
||||
prop = RNA_def_property(srna, "value_jitter", PROP_FLOAT, PROP_NONE);
|
||||
RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
|
||||
RNA_def_property_float_sdna(prop, nullptr, "hsv_jitter[2]");
|
||||
RNA_def_property_range(prop, 0, 1.0f);
|
||||
RNA_def_property_ui_range(prop, 0, 1, 0.05, 2);
|
||||
RNA_def_property_ui_text(prop, "Value Jitter", "Color jitter effect on value");
|
||||
RNA_def_property_update(prop, 0, "rna_UnifiedPaintSettings_update");
|
||||
|
||||
prop = RNA_def_property(srna, "use_stroke_random_hue", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(
|
||||
prop, nullptr, "color_jitter_flag", BRUSH_COLOR_JITTER_USE_HUE_AT_STROKE);
|
||||
RNA_def_property_ui_icon(prop, ICON_GP_SELECT_STROKES, 0);
|
||||
RNA_def_property_ui_text(prop, "Stroke Random", "Use randomness at stroke level");
|
||||
|
||||
prop = RNA_def_property(srna, "use_stroke_random_sat", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(
|
||||
prop, nullptr, "color_jitter_flag", BRUSH_COLOR_JITTER_USE_SAT_AT_STROKE);
|
||||
RNA_def_property_ui_icon(prop, ICON_GP_SELECT_STROKES, 0);
|
||||
RNA_def_property_ui_text(prop, "Stroke Random", "Use randomness at stroke level");
|
||||
|
||||
prop = RNA_def_property(srna, "use_stroke_random_val", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(
|
||||
prop, nullptr, "color_jitter_flag", BRUSH_COLOR_JITTER_USE_VAL_AT_STROKE);
|
||||
RNA_def_property_ui_icon(prop, ICON_GP_SELECT_STROKES, 0);
|
||||
RNA_def_property_ui_text(prop, "Stroke Random", "Use randomness at stroke level");
|
||||
|
||||
prop = RNA_def_property(srna, "use_random_press_hue", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(
|
||||
prop, nullptr, "color_jitter_flag", BRUSH_COLOR_JITTER_USE_HUE_RAND_PRESS);
|
||||
RNA_def_property_ui_icon(prop, ICON_STYLUS_PRESSURE, 0);
|
||||
RNA_def_property_ui_text(prop, "Use Pressure", "Use pressure to modulate randomness");
|
||||
|
||||
prop = RNA_def_property(srna, "use_random_press_sat", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(
|
||||
prop, nullptr, "color_jitter_flag", BRUSH_COLOR_JITTER_USE_SAT_RAND_PRESS);
|
||||
RNA_def_property_ui_icon(prop, ICON_STYLUS_PRESSURE, 0);
|
||||
RNA_def_property_ui_text(prop, "Use Pressure", "Use pressure to modulate randomness");
|
||||
|
||||
prop = RNA_def_property(srna, "use_random_press_val", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(
|
||||
prop, nullptr, "color_jitter_flag", BRUSH_COLOR_JITTER_USE_VAL_RAND_PRESS);
|
||||
RNA_def_property_ui_icon(prop, ICON_STYLUS_PRESSURE, 0);
|
||||
RNA_def_property_ui_text(prop, "Use Pressure", "Use pressure to modulate randomness");
|
||||
|
||||
prop = RNA_def_property(srna, "input_samples", PROP_INT, PROP_UNSIGNED);
|
||||
RNA_def_property_int_sdna(prop, nullptr, "input_samples");
|
||||
RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
|
||||
RNA_def_property_range(prop, 1, PAINT_MAX_INPUT_SAMPLES);
|
||||
RNA_def_property_ui_range(prop, 1, PAINT_MAX_INPUT_SAMPLES, 1, -1);
|
||||
RNA_def_property_ui_text(
|
||||
prop,
|
||||
"Input Samples",
|
||||
"Number of input samples to average together to smooth the brush stroke");
|
||||
RNA_def_property_update(prop, 0, "rna_UnifiedPaintSettings_update");
|
||||
|
||||
prop = RNA_def_property(srna, "use_locked_size", PROP_ENUM, PROP_NONE); /* as an enum */
|
||||
RNA_def_property_enum_bitflag_sdna(prop, nullptr, "flag");
|
||||
RNA_def_property_enum_items(prop, brush_size_unit_items);
|
||||
RNA_def_property_ui_text(
|
||||
prop, "Radius Unit", "Measure brush size relative to the view or the scene");
|
||||
}
|
||||
|
||||
static void rna_def_sculpt(BlenderRNA *brna)
|
||||
|
|
@ -1659,6 +1944,7 @@ void RNA_def_sculpt_paint(BlenderRNA *brna)
|
|||
RNA_define_animate_sdna(false);
|
||||
rna_def_paint_curve(brna);
|
||||
rna_def_paint(brna);
|
||||
rna_def_unified_paint_settings(brna);
|
||||
rna_def_sculpt(brna);
|
||||
rna_def_uv_sculpt(brna);
|
||||
rna_def_gp_paint(brna);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue