Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Bishop <nicholasbishop@gmail.com>2012-01-15 03:54:51 +0400
committerNicholas Bishop <nicholasbishop@gmail.com>2012-01-15 03:54:51 +0400
commit30e759c75ba9625fe46bc6b7710358282a61d4c1 (patch)
tree872469d64544c09a9155d871d4429f701df6172b /source/blender/editors
parent046bf80881b4c7ea2fb108b5588070a6ffa14c20 (diff)
Fix all remaining unified paint settings uses of current Scene.
Things like brush size and strength accessors now take a scene parameter rather than guessing about which Scene's unified paint settings to use. Setting the size/strength through RNA can now be done separately for the brush or the UnifiedPaintSettings. The UI python code required updating to check whether the size/strength controls should use brush or UnifiedPaintSettings RNA. Radial control also required some updates to switch between the two RNA sources.
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/physics/physics_ops.c4
-rw-r--r--source/blender/editors/sculpt_paint/paint_image.c35
-rw-r--r--source/blender/editors/sculpt_paint/paint_ops.c37
-rw-r--r--source/blender/editors/sculpt_paint/paint_stroke.c58
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex.c29
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c32
6 files changed, 108 insertions, 87 deletions
diff --git a/source/blender/editors/physics/physics_ops.c b/source/blender/editors/physics/physics_ops.c
index ba0465b866f..09f99a58dd7 100644
--- a/source/blender/editors/physics/physics_ops.c
+++ b/source/blender/editors/physics/physics_ops.c
@@ -116,11 +116,11 @@ static void keymap_particle(wmKeyConfig *keyconf)
/* size radial control */
kmi = WM_keymap_add_item(keymap, "WM_OT_radial_control", FKEY, KM_PRESS, 0, 0);
- RNA_string_set(kmi->ptr, "data_path", "tool_settings.particle_edit.brush.size");
+ RNA_string_set(kmi->ptr, "data_path_primary", "tool_settings.particle_edit.brush.size");
/* size radial control */
kmi = WM_keymap_add_item(keymap, "WM_OT_radial_control", FKEY, KM_PRESS, KM_SHIFT, 0);
- RNA_string_set(kmi->ptr, "data_path", "tool_settings.particle_edit.brush.strength");
+ RNA_string_set(kmi->ptr, "data_path_primary", "tool_settings.particle_edit.brush.strength");
WM_keymap_add_menu(keymap, "VIEW3D_MT_particle_specials", WKEY, KM_PRESS, 0, 0);
diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c
index 5acc690807e..8eeca2e4e15 100644
--- a/source/blender/editors/sculpt_paint/paint_image.c
+++ b/source/blender/editors/sculpt_paint/paint_image.c
@@ -2937,7 +2937,7 @@ static void project_paint_begin(ProjPaintState *ps)
MemArena *arena; /* at the moment this is just ps->arena_mt[0], but use this to show were not multithreading */
- const int diameter= 2*brush_size(ps->brush);
+ const int diameter= 2*brush_size(ps->scene, ps->brush);
/* ---- end defines ---- */
@@ -3580,7 +3580,7 @@ static int project_bucket_iter_init(ProjPaintState *ps, const float mval_f[2])
{
if(ps->source==PROJ_SRC_VIEW) {
float min_brush[2], max_brush[2];
- const float radius = (float)brush_size(ps->brush);
+ const float radius = (float)brush_size(ps->scene, ps->brush);
/* so we dont have a bucket bounds that is way too small to paint into */
// if (radius < 1.0f) radius = 1.0f; // this doesn't work yet :/
@@ -3618,7 +3618,7 @@ static int project_bucket_iter_init(ProjPaintState *ps, const float mval_f[2])
static int project_bucket_iter_next(ProjPaintState *ps, int *bucket_index, rctf *bucket_bounds, const float mval[2])
{
- const int diameter= 2*brush_size(ps->brush);
+ const int diameter= 2*brush_size(ps->scene, ps->brush);
if (ps->thread_tot > 1)
BLI_lock_thread(LOCK_CUSTOM1);
@@ -3844,7 +3844,7 @@ static void *do_projectpaint_thread(void *ph_v)
float co[2];
float mask = 1.0f; /* airbrush wont use mask */
unsigned short mask_short;
- const float radius= (float)brush_size(ps->brush);
+ const float radius= (float)brush_size(ps->scene, ps->brush);
const float radius_squared= radius*radius; /* avoid a square root with every dist comparison */
short lock_alpha= ELEM(ps->brush->blend, IMB_BLEND_ERASE_ALPHA, IMB_BLEND_ADD_ALPHA) ? 0 : ps->brush->flag & BRUSH_LOCK_ALPHA;
@@ -3903,7 +3903,7 @@ static void *do_projectpaint_thread(void *ph_v)
if (falloff > 0.0f) {
if (ps->is_texbrush) {
/* note, for clone and smear, we only use the alpha, could be a special function */
- brush_sample_tex(ps->brush, projPixel->projCoSS, rgba, thread_index);
+ brush_sample_tex(ps->scene, ps->brush, projPixel->projCoSS, rgba, thread_index);
alpha = rgba[3];
} else {
alpha = 1.0f;
@@ -3911,7 +3911,7 @@ static void *do_projectpaint_thread(void *ph_v)
if (ps->is_airbrush) {
/* for an aurbrush there is no real mask, so just multiply the alpha by it */
- alpha *= falloff * brush_alpha(ps->brush);
+ alpha *= falloff * brush_alpha(ps->scene, ps->brush);
mask = ((float)projPixel->mask)/65535.0f;
}
else {
@@ -3919,7 +3919,7 @@ static void *do_projectpaint_thread(void *ph_v)
falloff = 1.0f - falloff;
falloff = 1.0f - (falloff * falloff);
- mask_short = (unsigned short)(projPixel->mask * (brush_alpha(ps->brush) * falloff));
+ mask_short = (unsigned short)(projPixel->mask * (brush_alpha(ps->scene, ps->brush) * falloff));
if (mask_short > projPixel->mask_max) {
mask = ((float)mask_short)/65535.0f;
projPixel->mask_max = mask_short;
@@ -4801,7 +4801,7 @@ static int texture_paint_init(bContext *C, wmOperator *op)
if(pop->mode == PAINT_MODE_3D && (pop->s.tool == PAINT_TOOL_CLONE))
pop->s.tool = PAINT_TOOL_DRAW;
pop->s.blend = brush->blend;
- pop->orig_brush_size= brush_size(brush);
+ pop->orig_brush_size= brush_size(scene, brush);
if(pop->mode != PAINT_MODE_2D) {
pop->s.ob = OBACT;
@@ -4837,8 +4837,8 @@ static int texture_paint_init(bContext *C, wmOperator *op)
return 0;
/* Dont allow brush size below 2 */
- if (brush_size(brush) < 2)
- brush_set_size(brush, 2);
+ if (brush_size(scene, brush) < 2)
+ brush_set_size(scene, brush, 2);
/* allocate and initialize spacial data structures */
project_paint_begin(&pop->ps);
@@ -4922,7 +4922,7 @@ static void paint_exit(bContext *C, wmOperator *op)
brush_painter_free(pop->painter);
if(pop->mode == PAINT_MODE_3D_PROJECT) {
- brush_set_size(pop->ps.brush, pop->orig_brush_size);
+ brush_set_size(scene, pop->ps.brush, pop->orig_brush_size);
paint_brush_exit_tex(pop->ps.brush);
project_paint_end(&pop->ps);
@@ -5111,12 +5111,13 @@ static void brush_drawcursor(bContext *C, int x, int y, void *UNUSED(customdata)
#define PX_SIZE_FADE_MAX 12.0f
#define PX_SIZE_FADE_MIN 4.0f
+ Scene *scene= CTX_data_scene(C);
Brush *brush= image_paint_brush(C);
- Paint *paint= paint_get_active(CTX_data_scene(C));
+ Paint *paint= paint_get_active(scene);
if(paint && brush && paint->flags & PAINT_SHOW_BRUSH) {
float zoomx, zoomy;
- const float size= (float)brush_size(brush);
+ const float size= (float)brush_size(scene, brush);
const short use_zoom= get_imapaint_zoom(C, &zoomx, &zoomy);
const float pixel_size= MAX2(size * zoomx, size * zoomy);
float alpha= 0.5f;
@@ -5570,8 +5571,8 @@ static int texture_paint_camera_project_exec(bContext *C, wmOperator *op)
/* override */
ps.is_texbrush= 0;
ps.is_airbrush= 1;
- orig_brush_size= brush_size(ps.brush);
- brush_set_size(ps.brush, 32); /* cover the whole image */
+ orig_brush_size= brush_size(scene, ps.brush);
+ brush_set_size(scene, ps.brush, 32); /* cover the whole image */
ps.tool= PAINT_TOOL_DRAW; /* so pixels are initialized with minimal info */
@@ -5584,7 +5585,7 @@ static int texture_paint_camera_project_exec(bContext *C, wmOperator *op)
project_paint_begin(&ps);
if(ps.dm==NULL) {
- brush_set_size(ps.brush, orig_brush_size);
+ brush_set_size(scene, ps.brush, orig_brush_size);
return OPERATOR_CANCELLED;
}
else {
@@ -5608,7 +5609,7 @@ static int texture_paint_camera_project_exec(bContext *C, wmOperator *op)
project_paint_end(&ps);
scene->toolsettings->imapaint.flag &= ~IMAGEPAINT_DRAWING;
- brush_set_size(ps.brush, orig_brush_size);
+ brush_set_size(scene, ps.brush, orig_brush_size);
return OPERATOR_FINISHED;
}
diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c
index eb20465a2ab..e81e1f6dc77 100644
--- a/source/blender/editors/sculpt_paint/paint_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_ops.c
@@ -89,7 +89,8 @@ static void BRUSH_OT_add(wmOperatorType *ot)
static int brush_scale_size_exec(bContext *C, wmOperator *op)
{
- Paint *paint= paint_get_active(CTX_data_scene(C));
+ Scene *scene = CTX_data_scene(C);
+ Paint *paint= paint_get_active(scene);
struct Brush *brush= paint_brush(paint);
// Object *ob= CTX_data_active_object(C);
float scalar= RNA_float_get(op->ptr, "scalar");
@@ -97,7 +98,7 @@ static int brush_scale_size_exec(bContext *C, wmOperator *op)
if (brush) {
// pixel radius
{
- const int old_size= brush_size(brush);
+ const int old_size= brush_size(scene, brush);
int size= (int)(scalar*old_size);
if (old_size == size) {
@@ -110,17 +111,17 @@ static int brush_scale_size_exec(bContext *C, wmOperator *op)
}
CLAMP(size, 1, 2000); // XXX magic number
- brush_set_size(brush, size);
+ brush_set_size(scene, brush, size);
}
// unprojected radius
{
- float unprojected_radius= scalar*brush_unprojected_radius(brush);
+ float unprojected_radius= scalar*brush_unprojected_radius(scene, brush);
if (unprojected_radius < 0.001f) // XXX magic number
unprojected_radius= 0.001f;
- brush_set_unprojected_radius(brush, unprojected_radius);
+ brush_set_unprojected_radius(scene, brush, unprojected_radius);
}
}
@@ -475,7 +476,7 @@ typedef enum {
} RCFlags;
static void set_brush_rc_path(PointerRNA *ptr, const char *brush_path,
- const char *output_name, const char *input_name)
+ const char *output_name, const char *input_name)
{
char *path;
@@ -485,21 +486,35 @@ static void set_brush_rc_path(PointerRNA *ptr, const char *brush_path,
}
static void set_brush_rc_props(PointerRNA *ptr, const char *paint,
- const char *prop, RCFlags flags)
+ const char *prop, const char *secondary_prop,
+ RCFlags flags)
{
+ const char *ups_path = "tool_settings.unified_paint_settings";
char *brush_path;
brush_path = BLI_sprintfN("tool_settings.%s.brush", paint);
- set_brush_rc_path(ptr, brush_path, "data_path", prop);
+ set_brush_rc_path(ptr, brush_path, "data_path_primary", prop);
+ if(secondary_prop) {
+ set_brush_rc_path(ptr, ups_path, "use_secondary", secondary_prop);
+ set_brush_rc_path(ptr, ups_path, "data_path_secondary", prop);
+ }
+ else {
+ RNA_string_set(ptr, "use_secondary", "");
+ RNA_string_set(ptr, "data_path_secondary", "");
+ }
set_brush_rc_path(ptr, brush_path, "color_path", "cursor_color_add");
set_brush_rc_path(ptr, brush_path, "rotation_path", "texture_slot.angle");
RNA_string_set(ptr, "image_id", brush_path);
if(flags & RC_COLOR)
set_brush_rc_path(ptr, brush_path, "fill_color_path", "color");
+ else
+ RNA_string_set(ptr, "fill_color_path", "");
if(flags & RC_ZOOM)
RNA_string_set(ptr, "zoom_path", "space_data.zoom");
+ else
+ RNA_string_set(ptr, "zoom_path", "");
MEM_freeN(brush_path);
}
@@ -510,14 +525,14 @@ static void ed_keymap_paint_brush_radial_control(wmKeyMap *keymap, const char *p
wmKeyMapItem *kmi;
kmi = WM_keymap_add_item(keymap, "WM_OT_radial_control", FKEY, KM_PRESS, 0, 0);
- set_brush_rc_props(kmi->ptr, paint, "size", flags);
+ set_brush_rc_props(kmi->ptr, paint, "size", "use_unified_size", flags);
kmi = WM_keymap_add_item(keymap, "WM_OT_radial_control", FKEY, KM_PRESS, KM_SHIFT, 0);
- set_brush_rc_props(kmi->ptr, paint, "strength", flags);
+ set_brush_rc_props(kmi->ptr, paint, "strength", "use_unified_strength", flags);
if(flags & RC_ROTATION) {
kmi = WM_keymap_add_item(keymap, "WM_OT_radial_control", FKEY, KM_PRESS, KM_CTRL, 0);
- set_brush_rc_props(kmi->ptr, paint, "texture_slot.angle", flags);
+ set_brush_rc_props(kmi->ptr, paint, "texture_slot.angle", NULL, flags);
}
}
diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c
index ca5abc16ec8..c3e0c35f524 100644
--- a/source/blender/editors/sculpt_paint/paint_stroke.c
+++ b/source/blender/editors/sculpt_paint/paint_stroke.c
@@ -123,19 +123,19 @@ static int same_snap(Snapshot* snap, Brush* brush, ViewContext* vc)
{
MTex* mtex = &brush->mtex;
- return ( (mtex->tex) &&
- equals_v3v3(mtex->ofs, snap->ofs) &&
- equals_v3v3(mtex->size, snap->size) &&
- mtex->rot == snap->rot
- ) &&
-
- /* make brush smaller shouldn't cause a resample */
- ( (mtex->brush_map_mode == MTEX_MAP_MODE_FIXED && (brush_size(brush) <= snap->brush_size)) ||
- (brush_size(brush) == snap->brush_size)) &&
-
- (mtex->brush_map_mode == snap->brush_map_mode) &&
- (vc->ar->winx == snap->winx) &&
- (vc->ar->winy == snap->winy);
+ return (((mtex->tex) &&
+ equals_v3v3(mtex->ofs, snap->ofs) &&
+ equals_v3v3(mtex->size, snap->size) &&
+ mtex->rot == snap->rot) &&
+
+ /* make brush smaller shouldn't cause a resample */
+ ((mtex->brush_map_mode == MTEX_MAP_MODE_FIXED &&
+ (brush_size(vc->scene, brush) <= snap->brush_size)) ||
+ (brush_size(vc->scene, brush) == snap->brush_size)) &&
+
+ (mtex->brush_map_mode == snap->brush_map_mode) &&
+ (vc->ar->winx == snap->winx) &&
+ (vc->ar->winy == snap->winy));
}
static void make_snap(Snapshot* snap, Brush* brush, ViewContext* vc)
@@ -153,7 +153,7 @@ static void make_snap(Snapshot* snap, Brush* brush, ViewContext* vc)
snap->rot = -1;
}
- snap->brush_size = brush_size(brush);
+ snap->brush_size = brush_size(vc->scene, brush);
snap->winx = vc->ar->winx;
snap->winy = vc->ar->winy;
}
@@ -198,7 +198,7 @@ static int load_tex(Sculpt *sd, Brush* br, ViewContext* vc)
make_snap(&snap, br, vc);
if (br->mtex.brush_map_mode == MTEX_MAP_MODE_FIXED) {
- int s = brush_size(br);
+ int s = brush_size(vc->scene, br);
int r = 1;
for (s >>= 1; s > 0; s >>= 1)
@@ -239,7 +239,7 @@ static int load_tex(Sculpt *sd, Brush* br, ViewContext* vc)
// largely duplicated from tex_strength
const float rotation = -br->mtex.rot;
- float radius = brush_size(br);
+ float radius = brush_size(vc->scene, br);
int index = j*size + i;
float x;
float avg;
@@ -373,6 +373,7 @@ static int sculpt_get_brush_geometry(bContext* C, int x, int y, int* pixel_radiu
float location[3])
{
struct PaintStroke *stroke;
+ const Scene *scene = CTX_data_scene(C);
float window[2];
int hit;
@@ -384,11 +385,11 @@ static int sculpt_get_brush_geometry(bContext* C, int x, int y, int* pixel_radiu
if(stroke->vc.obact->sculpt && stroke->vc.obact->sculpt->pbvh &&
sculpt_stroke_get_location(C, stroke, location, window)) {
*pixel_radius = project_brush_radius(stroke->vc.rv3d,
- brush_unprojected_radius(stroke->brush),
+ brush_unprojected_radius(scene, stroke->brush),
location, &stroke->mats);
if (*pixel_radius == 0)
- *pixel_radius = brush_size(stroke->brush);
+ *pixel_radius = brush_size(scene, stroke->brush);
mul_m4_v3(stroke->vc.obact->obmat, location);
@@ -398,7 +399,7 @@ static int sculpt_get_brush_geometry(bContext* C, int x, int y, int* pixel_radiu
Sculpt* sd = CTX_data_tool_settings(C)->sculpt;
Brush* brush = paint_brush(&sd->paint);
- *pixel_radius = brush_size(brush);
+ *pixel_radius = brush_size(scene, brush);
hit = 0;
}
@@ -468,7 +469,7 @@ static void paint_draw_alpha_overlay(Sculpt *sd, Brush *brush,
quad.ymax = aim[1]+sd->anchored_size - win->ymin;
}
else {
- const int radius= brush_size(brush);
+ const int radius= brush_size(vc->scene, brush);
quad.xmin = x - radius;
quad.ymin = y - radius;
quad.xmax = x + radius;
@@ -524,7 +525,7 @@ static void paint_cursor_on_hit(Sculpt *sd, Brush *brush, ViewContext *vc,
if(brush->flag & BRUSH_ANCHORED)
projected_radius = 8;
else
- projected_radius = brush_size(brush);
+ projected_radius = brush_size(vc->scene, brush);
}
unprojected_radius = paint_calc_object_space_radius(vc, location,
projected_radius);
@@ -533,7 +534,7 @@ static void paint_cursor_on_hit(Sculpt *sd, Brush *brush, ViewContext *vc,
unprojected_radius *= sd->pressure_value;
if(!brush_use_locked_size(vc->scene, brush))
- brush_set_unprojected_radius(brush, unprojected_radius);
+ brush_set_unprojected_radius(vc->scene, brush, unprojected_radius);
}
static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
@@ -551,7 +552,7 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
translation[1] = y;
outline_alpha = 0.5;
outline_col = brush->add_col;
- final_radius = brush_size(brush);
+ final_radius = brush_size(scene, brush);
/* check that brush drawing is enabled */
if(!(paint->flags & PAINT_SHOW_BRUSH))
@@ -567,7 +568,7 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
float location[3];
int pixel_radius, hit;
- const float root_alpha = brush_alpha(brush);
+ const float root_alpha = brush_alpha(scene, brush);
float visual_strength = root_alpha*root_alpha;
const float min_alpha = 0.20f;
const float max_alpha = 0.80f;
@@ -599,7 +600,7 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
paint_draw_alpha_overlay(sd, brush, &vc, x, y);
if(brush_use_locked_size(scene, brush))
- brush_set_size(brush, pixel_radius);
+ brush_set_size(scene, brush, pixel_radius);
/* check if brush is subtracting, use different color then */
/* TODO: no way currently to know state of pen flip or
@@ -669,7 +670,8 @@ static float event_tablet_data(wmEvent *event, int *pen_flip)
/* Put the location of the next stroke dot into the stroke RNA and apply it to the mesh */
static void paint_brush_stroke_add_step(bContext *C, wmOperator *op, wmEvent *event, float mouse_in[2])
{
- Paint *paint = paint_get_active(CTX_data_scene(C));
+ Scene *scene = CTX_data_scene(C);
+ Paint *paint = paint_get_active(scene);
Brush *brush = paint_brush(paint);
PaintStroke *stroke = op->customdata;
float mouse[3];
@@ -686,7 +688,7 @@ static void paint_brush_stroke_add_step(bContext *C, wmOperator *op, wmEvent *ev
if(stroke->vc.obact->sculpt) {
float delta[2];
- brush_jitter_pos(brush, mouse_in, mouse);
+ brush_jitter_pos(scene, brush, mouse_in, mouse);
/* XXX: meh, this is round about because
brush_jitter_pos isn't written in the best way to
@@ -775,7 +777,7 @@ static int paint_space_stroke(bContext *C, wmOperator *op, wmEvent *event, const
pressure = event_tablet_data(event, NULL);
if(pressure > FLT_EPSILON) {
- scale = (brush_size(stroke->brush)*pressure*stroke->brush->spacing/50.0f) / length;
+ scale = (brush_size(scene, stroke->brush)*pressure*stroke->brush->spacing/50.0f) / length;
if(scale > FLT_EPSILON) {
mul_v2_fl(vec, scale);
diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c
index 21b27b2d3d3..2f98ee16d45 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex.c
@@ -654,7 +654,7 @@ static unsigned int mcol_darken(unsigned int col1, unsigned int col2, int fac)
return col;
}
-static void vpaint_blend(VPaint *vp, unsigned int *col, unsigned int *colorig, unsigned int paintcol, int alpha)
+static void vpaint_blend(Scene *scene, VPaint *vp, unsigned int *col, unsigned int *colorig, unsigned int paintcol, int alpha)
{
Brush *brush = paint_brush(&vp->paint);
@@ -670,7 +670,7 @@ static void vpaint_blend(VPaint *vp, unsigned int *col, unsigned int *colorig, u
unsigned int testcol=0, a;
char *cp, *ct, *co;
- alpha= (int)(255.0f*brush_alpha(brush));
+ alpha= (int)(255.0f*brush_alpha(scene, brush));
if(brush->vertexpaint_tool==VP_MIX || brush->vertexpaint_tool==VP_BLUR) testcol= mcol_blend( *colorig, paintcol, alpha);
else if(brush->vertexpaint_tool==VP_ADD) testcol= mcol_add( *colorig, paintcol, alpha);
@@ -787,7 +787,7 @@ static float calc_vp_alpha_dl(VPaint *vp, ViewContext *vc,
return 0.0f;
}
-static void wpaint_blend(VPaint *wp, MDeformWeight *dw, MDeformWeight *dw_prev, float alpha, float paintval, int flip, int multipaint)
+static void wpaint_blend(Scene *scene, VPaint *wp, MDeformWeight *dw, MDeformWeight *dw_prev, float alpha, float paintval, int flip, int multipaint)
{
Brush *brush = paint_brush(&wp->paint);
int tool = brush->vertexpaint_tool;
@@ -832,7 +832,7 @@ static void wpaint_blend(VPaint *wp, MDeformWeight *dw, MDeformWeight *dw_prev,
if((wp->flag & VP_SPRAY)==0) {
float testw=0.0f;
- alpha= brush_alpha(brush);
+ alpha= brush_alpha(scene, brush);
if(tool==VP_MIX || tool==VP_BLUR)
testw = paintval*alpha + dw_prev->weight*(1.0f-alpha);
else if(tool==VP_ADD)
@@ -1596,7 +1596,8 @@ static char *wpaint_make_validmap(Object *ob);
static void do_weight_paint_vertex( /* vars which remain the same for every vert */
- VPaint *wp, Object *ob, const WeightPaintInfo *wpi,
+ Scene *scene, VPaint *wp, Object *ob,
+ const WeightPaintInfo *wpi,
/* vars which change on each stroke */
const unsigned int index, float alpha, float paintweight
)
@@ -1685,7 +1686,7 @@ static void do_weight_paint_vertex( /* vars which remain the same for every vert
if ( (wpi->do_multipaint == FALSE || wpi->defbase_tot_sel <= 1) &&
(wpi->lock_flags == NULL || has_locked_group(dv, wpi->defbase_tot, wpi->vgroup_validmap, wpi->lock_flags) == FALSE))
{
- wpaint_blend(wp, dw, dw_prev, alpha, paintweight, wpi->do_flip, FALSE);
+ wpaint_blend(scene, wp, dw, dw_prev, alpha, paintweight, wpi->do_flip, FALSE);
/* WATCH IT: take care of the ordering of applying mirror -> normalize,
* can give wrong results [#26193], least confusing if normalize is done last */
@@ -1750,7 +1751,7 @@ static void do_weight_paint_vertex( /* vars which remain the same for every vert
MDeformVert dv_copy= {NULL};
oldw = dw->weight;
- wpaint_blend(wp, dw, dw_prev, alpha, paintweight, wpi->do_flip, wpi->do_multipaint && wpi->defbase_tot_sel >1);
+ wpaint_blend(scene, wp, dw, dw_prev, alpha, paintweight, wpi->do_flip, wpi->do_multipaint && wpi->defbase_tot_sel >1);
neww = dw->weight;
dw->weight = oldw;
@@ -2091,7 +2092,7 @@ static int wpaint_stroke_test_start(bContext *C, wmOperator *op, wmEvent *UNUSED
static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, PointerRNA *itemptr)
{
- const Scene *scene= CTX_data_scene(C);
+ Scene *scene= CTX_data_scene(C);
ToolSettings *ts= CTX_data_tool_settings(C);
VPaint *wp= ts->wpaint;
Brush *brush = paint_brush(&wp->paint);
@@ -2110,8 +2111,8 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
char *defbase_sel;
const float pressure = RNA_float_get(itemptr, "pressure");
- const float brush_size_final = brush_size(brush) * (brush_use_size_pressure(scene, brush) ? pressure : 1.0f);
- const float brush_alpha_final = brush_alpha(brush) * (brush_use_alpha_pressure(scene, brush) ? pressure : 1.0f);
+ const float brush_size_final = brush_size(scene, brush) * (brush_use_size_pressure(scene, brush) ? pressure : 1.0f);
+ const float brush_alpha_final = brush_alpha(scene, brush) * (brush_use_alpha_pressure(scene, brush) ? pressure : 1.0f);
/* intentionally dont initialize as NULL, make sure we initialize all members below */
WeightPaintInfo wpi;
@@ -2265,7 +2266,7 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
alpha= calc_vp_alpha_dl(wp, vc, wpd->wpimat, wpd->vertexcosnos+6*vidx,
mval, brush_size_final, brush_alpha_final);
if(alpha) {
- do_weight_paint_vertex(wp, ob, &wpi, vidx, alpha, paintweight);
+ do_weight_paint_vertex(scene, wp, ob, &wpi, vidx, alpha, paintweight);
}
me->dvert[vidx].flag= 0;
}
@@ -2556,7 +2557,7 @@ static void vpaint_paint_face(VPaint *vp, VPaintData *vpd, Object *ob,
alpha = calc_vp_alpha_dl(vp, vc, vpd->vpimat, vpd->vertexcosnos+6*(&mface->v1)[i],
mval, brush_size_final, brush_alpha_final);
if(alpha) {
- vpaint_blend(vp, mcol+i, mcolorig+i, vpd->paintcol, (int)(alpha*255.0f));
+ vpaint_blend(vc->scene, vp, mcol+i, mcolorig+i, vpd->paintcol, (int)(alpha*255.0f));
}
}
}
@@ -2577,8 +2578,8 @@ static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
float mval[2];
const float pressure = RNA_float_get(itemptr, "pressure");
- const float brush_size_final = brush_size(brush) * (brush_use_size_pressure(scene, brush) ? pressure : 1.0f);
- const float brush_alpha_final = brush_alpha(brush) * (brush_use_alpha_pressure(scene, brush) ? pressure : 1.0f);
+ const float brush_size_final = brush_size(scene, brush) * (brush_use_size_pressure(scene, brush) ? pressure : 1.0f);
+ const float brush_alpha_final = brush_alpha(scene, brush) * (brush_use_alpha_pressure(scene, brush) ? pressure : 1.0f);
RNA_float_get_array(itemptr, "mouse", mval);
flip = RNA_boolean_get(itemptr, "pen_flip");
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 7712a0793c2..27a0bc8f502 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -543,13 +543,14 @@ static float calc_symmetry_feather(Sculpt *sd, StrokeCache* cache)
special multiplier found experimentally to scale the strength factor. */
static float brush_strength(Sculpt *sd, StrokeCache *cache, float feather)
{
+ const Scene *scene = cache->vc->scene;
Brush *brush = paint_brush(&sd->paint);
/* Primary strength input; square it to make lower values more sensitive */
- const float root_alpha = brush_alpha(brush);
+ const float root_alpha = brush_alpha(scene, brush);
float alpha = root_alpha*root_alpha;
float dir = brush->flag & BRUSH_DIR_IN ? -1 : 1;
- float pressure = brush_use_alpha_pressure(cache->vc->scene, brush) ? cache->pressure : 1;
+ float pressure = brush_use_alpha_pressure(scene, brush) ? cache->pressure : 1;
float pen_flip = cache->pen_flip ? -1 : 1;
float invert = cache->invert ? -1 : 1;
float accum = integrate_overlap(brush);
@@ -679,7 +680,7 @@ static float tex_strength(SculptSession *ss, Brush *br, float point[3],
else /* else (mtex->brush_map_mode == MTEX_MAP_MODE_TILED),
leave the coordinates relative to the screen */
{
- radius = brush_size(br); // use unadjusted size for tiled mode
+ radius = brush_size(ss->cache->vc->scene, br); // use unadjusted size for tiled mode
x = point_2d[0];
y = point_2d[1];
@@ -1167,6 +1168,7 @@ static void do_draw_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
static void do_crease_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
{
SculptSession *ss = ob->sculpt;
+ const Scene *scene = ss->cache->vc->scene;
Brush *brush = paint_brush(&sd->paint);
float offset[3], area_normal[3];
float bstrength= ss->cache->bstrength;
@@ -1182,8 +1184,8 @@ static void do_crease_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod
/* we divide out the squared alpha and multiply by the squared crease to give us the pinch strength */
- if(brush_alpha(brush) > 0.0f)
- crease_correction = brush->crease_pinch_factor*brush->crease_pinch_factor/(brush_alpha(brush)*brush_alpha(brush));
+ if(brush_alpha(scene, brush) > 0.0f)
+ crease_correction = brush->crease_pinch_factor*brush->crease_pinch_factor/(brush_alpha(scene, brush)*brush_alpha(scene, brush));
else
crease_correction = brush->crease_pinch_factor*brush->crease_pinch_factor;
@@ -2658,10 +2660,10 @@ static void do_symmetrical_brush_actions(Sculpt *sd, Object *ob)
cache->first_time= 0;
}
-static void sculpt_update_tex(Sculpt *sd, SculptSession *ss)
+static void sculpt_update_tex(const Scene *scene, Sculpt *sd, SculptSession *ss)
{
Brush *brush = paint_brush(&sd->paint);
- const int radius= brush_size(brush);
+ const int radius= brush_size(scene, brush);
if(ss->texcache) {
MEM_freeN(ss->texcache);
@@ -3017,7 +3019,7 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob,
struct PaintStroke *stroke,
PointerRNA *ptr)
{
- const Scene *scene = CTX_data_scene(C);
+ Scene *scene = CTX_data_scene(C);
SculptSession *ss = ob->sculpt;
StrokeCache *cache = ss->cache;
Brush *brush = paint_brush(&sd->paint);
@@ -3052,15 +3054,15 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob,
sd->pressure_value= cache->pressure;
cache->previous_pixel_radius = cache->pixel_radius;
- cache->pixel_radius = brush_size(brush);
+ cache->pixel_radius = brush_size(scene, brush);
if(cache->first_time) {
if (!brush_use_locked_size(scene, brush)) {
- cache->initial_radius= paint_calc_object_space_radius(cache->vc, cache->true_location, brush_size(brush));
- brush_set_unprojected_radius(brush, cache->initial_radius);
+ cache->initial_radius= paint_calc_object_space_radius(cache->vc, cache->true_location, brush_size(scene, brush));
+ brush_set_unprojected_radius(scene, brush, cache->initial_radius);
}
else {
- cache->initial_radius= brush_unprojected_radius(brush);
+ cache->initial_radius= brush_unprojected_radius(scene, brush);
}
}
@@ -3246,7 +3248,7 @@ int sculpt_stroke_get_location(bContext *C, struct PaintStroke *stroke, float ou
return srd.hit;
}
-static void sculpt_brush_init_tex(Sculpt *sd, SculptSession *ss)
+static void sculpt_brush_init_tex(const Scene *scene, Sculpt *sd, SculptSession *ss)
{
Brush *brush = paint_brush(&sd->paint);
MTex *mtex= &brush->mtex;
@@ -3258,7 +3260,7 @@ static void sculpt_brush_init_tex(Sculpt *sd, SculptSession *ss)
/* TODO: Shouldn't really have to do this at the start of every
stroke, but sculpt would need some sort of notification when
changes are made to the texture. */
- sculpt_update_tex(sd, ss);
+ sculpt_update_tex(scene, sd, ss);
}
static int sculpt_brush_stroke_init(bContext *C, wmOperator *op)
@@ -3272,7 +3274,7 @@ static int sculpt_brush_stroke_init(bContext *C, wmOperator *op)
int is_smooth= 0;
view3d_operator_needs_opengl(C);
- sculpt_brush_init_tex(sd, ss);
+ sculpt_brush_init_tex(scene, sd, ss);
is_smooth|= mode == BRUSH_STROKE_SMOOTH;
is_smooth|= brush->sculpt_tool == SCULPT_TOOL_SMOOTH;