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:
authorJason Wilkins <Jason.A.Wilkins@gmail.com>2010-07-22 22:56:46 +0400
committerJason Wilkins <Jason.A.Wilkins@gmail.com>2010-07-22 22:56:46 +0400
commit3b5b761a56424987790bd1aad6fcb9ac1f0a281b (patch)
treeb0b8c51df20dc3613ab265858c0ca072151e83ea /source/blender/editors/sculpt_paint/paint_stroke.c
parent528cce431380d53176ce7a9f5835612e2536566a (diff)
== Sculpt/Paint Fixes ==
* Fix: unify strength and size did work consistently with other paint modes * Fix: If [ and ] keys were used to resize a brush it was not possible to increase the size of the brush if it went under 10 pixels * Fix: Made interpretation of brush size consistent across all modes, Texture/Image paint interpreted brush size as the diameter while all the other modes interpret it as radius * Fix: The default spacing for vertex paint brushes was 3%, should be 10% * Fix: due to fixes to unified strength, re-enabled 'Unify Size' by default * Fix: Unified size and strength were stored in UserPrefs, moved this to ToolSettings * Fix: The setting of pressure sensitivity was not unified when strength or size were unified. Now the appropriate pressure sensitivity setting is also unified across all brushes when corresponding unification option is selected * Fix: When using [ and ] to resize the brush it didn't immediately redraw * Fix: fkey resizing/"re-strength-ing" was not working consistently accross all paint modes due to only sculpt mode having full support for unified size and strength, now it works properly. * Fix: other paint modes did expose the ability to have a custom brush colors, so I added the small bit of code to allow it. Note: I made all of the other paint mode brushes white. Note2: Actually, probably want to make the paint modes use the selected color for painting instead of a constant brush color. * I had removed OPTYPE_REGISTER from some Sculpt/Paint operators but in this commit I add them back. I'm not completely sure what this option does so I don't want to disturb it for now.
Diffstat (limited to 'source/blender/editors/sculpt_paint/paint_stroke.c')
-rw-r--r--source/blender/editors/sculpt_paint/paint_stroke.c58
1 files changed, 30 insertions, 28 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c
index 81f471481fb..5eeb8492019 100644
--- a/source/blender/editors/sculpt_paint/paint_stroke.c
+++ b/source/blender/editors/sculpt_paint/paint_stroke.c
@@ -227,7 +227,7 @@ static int same_snap(Snapshot* snap, Brush* brush, ViewContext* vc)
mtex->size[1] == snap->size[1] &&
mtex->size[2] == snap->size[2] &&
mtex->rot == snap->rot) &&
- ((mtex->brush_map_mode == MTEX_MAP_MODE_FIXED && sculpt_get_brush_size(brush) <= snap->brush_size) || (sculpt_get_brush_size(brush) == snap->brush_size)) && // 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)) && // make brush smaller shouldn't cause a resample
mtex->brush_map_mode == snap->brush_map_mode &&
vc->ar->winx == snap->winx &&
vc->ar->winy == snap->winy;
@@ -248,7 +248,7 @@ static void make_snap(Snapshot* snap, Brush* brush, ViewContext* vc)
snap->rot = -1;
}
- snap->brush_size = sculpt_get_brush_size(brush);
+ snap->brush_size = brush_size(brush);
snap->winx = vc->ar->winx;
snap->winy = vc->ar->winy;
}
@@ -289,7 +289,7 @@ 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 = sculpt_get_brush_size(br);
+ int s = brush_size(br);
int r = 1;
for (s >>= 1; s > 0; s >>= 1)
@@ -330,7 +330,7 @@ int load_tex(Sculpt *sd, Brush* br, ViewContext* vc)
// largely duplicated from tex_strength
const float rotation = -br->mtex.rot;
- float diameter = sculpt_get_brush_size(br);
+ float radius = brush_size(br);
int index = j*size + i;
float x;
float avg;
@@ -342,8 +342,8 @@ int load_tex(Sculpt *sd, Brush* br, ViewContext* vc)
y -= 0.5f;
if (br->mtex.brush_map_mode == MTEX_MAP_MODE_TILED) {
- x *= vc->ar->winx / diameter;
- y *= vc->ar->winy / diameter;
+ x *= vc->ar->winx / radius;
+ y *= vc->ar->winy / radius;
}
else {
x *= 2;
@@ -488,10 +488,10 @@ int sculpt_get_brush_geometry(bContext* C, int x, int y, int* pixel_radius, floa
memcpy(viewport, stroke->mats.viewport, sizeof(int[4]));
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, sculpt_get_brush_unprojected_radius(stroke->brush), location, &stroke->mats);
+ *pixel_radius = project_brush_radius(stroke->vc.rv3d, brush_unprojected_radius(stroke->brush), location, &stroke->mats);
if (*pixel_radius == 0)
- *pixel_radius = sculpt_get_brush_size(stroke->brush);
+ *pixel_radius = brush_size(stroke->brush);
mul_m4_v3(stroke->vc.obact->sculpt->ob->obmat, location);
@@ -501,7 +501,7 @@ int sculpt_get_brush_geometry(bContext* C, int x, int y, int* pixel_radius, floa
Sculpt* sd = CTX_data_tool_settings(C)->sculpt;
Brush* brush = paint_brush(&sd->paint);
- *pixel_radius = sculpt_get_brush_size(brush);
+ *pixel_radius = brush_size(brush);
hit = 0;
}
@@ -556,7 +556,7 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *unused)
float* col;
float alpha;
- float visual_strength = sculpt_get_brush_alpha(brush)*sculpt_get_brush_alpha(brush);
+ float visual_strength = brush_alpha(brush)*brush_alpha(brush);
const float min_alpha = 0.20f;
const float max_alpha = 0.80f;
@@ -577,13 +577,13 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *unused)
}
}
- if(!sculpt_get_lock_brush_size(brush) && !(paint->flags & PAINT_SHOW_BRUSH))
+ if(!brush_use_locked_size(brush) && !(paint->flags & PAINT_SHOW_BRUSH))
return;
hit = sculpt_get_brush_geometry(C, x, y, &pixel_radius, location, modelview, projection, viewport);
- if (sculpt_get_lock_brush_size(brush))
- sculpt_set_brush_size(brush, pixel_radius);
+ if (brush_use_locked_size(brush))
+ brush_set_size(brush, pixel_radius);
// XXX: no way currently to know state of pen flip or invert key modifier without starting a stroke
flip = 1;
@@ -633,7 +633,7 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *unused)
glTranslatef(-0.5f, -0.5f, 0);
- if (sd->draw_pressure && (brush->flag & BRUSH_SIZE_PRESSURE)) {
+ if (sd->draw_pressure && brush_use_size_pressure(brush)) {
glTranslatef(0.5f, 0.5f, 0);
glScalef(1.0f/sd->pressure_value, 1.0f/sd->pressure_value, 1);
glTranslatef(-0.5f, -0.5f, 0);
@@ -662,17 +662,19 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *unused)
glVertex2f(sd->anchored_initial_mouse[0]-sd->anchored_size - vc.ar->winrct.xmin, sd->anchored_initial_mouse[1]+sd->anchored_size - vc.ar->winrct.ymin);
}
else {
+ const int radius= brush_size(brush);
+
glTexCoord2f(0, 0);
- glVertex2f((float)x-sculpt_get_brush_size(brush), (float)y-sculpt_get_brush_size(brush));
+ glVertex2f((float)x-radius, (float)y-radius);
glTexCoord2f(1, 0);
- glVertex2f((float)x+sculpt_get_brush_size(brush), (float)y-sculpt_get_brush_size(brush));
+ glVertex2f((float)x+radius, (float)y-radius);
glTexCoord2f(1, 1);
- glVertex2f((float)x+sculpt_get_brush_size(brush), (float)y+sculpt_get_brush_size(brush));
+ glVertex2f((float)x+radius, (float)y+radius);
glTexCoord2f(0, 1);
- glVertex2f((float)x-sculpt_get_brush_size(brush), (float)y+sculpt_get_brush_size(brush));
+ glVertex2f((float)x-radius, (float)y+radius);
}
}
else {
@@ -702,7 +704,7 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *unused)
// XXX duplicated from brush_strength & paint_stroke_add_step, refactor later
//wmEvent* event = CTX_wm_window(C)->eventstate;
- if (sd->draw_pressure && (brush->flag & BRUSH_ALPHA_PRESSURE))
+ if (sd->draw_pressure && brush_use_alpha_pressure(brush))
visual_strength *= sd->pressure_value;
// don't show effect of strength past the soft limit
@@ -715,14 +717,14 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *unused)
if (brush->flag & BRUSH_ANCHORED)
unprojected_radius = unproject_brush_radius(CTX_data_active_object(C), &vc, location, 8);
else
- unprojected_radius = unproject_brush_radius(CTX_data_active_object(C), &vc, location, sculpt_get_brush_size(brush));
+ unprojected_radius = unproject_brush_radius(CTX_data_active_object(C), &vc, location, brush_size(brush));
}
- if (sd->draw_pressure && (brush->flag & BRUSH_SIZE_PRESSURE))
+ if (sd->draw_pressure && brush_use_size_pressure(brush))
unprojected_radius *= sd->pressure_value;
- if (!sculpt_get_lock_brush_size(brush))
- sculpt_set_brush_unprojected_radius(brush, unprojected_radius);
+ if (!brush_use_locked_size(brush))
+ brush_set_unprojected_radius(brush, unprojected_radius);
if(!(paint->flags & PAINT_SHOW_BRUSH))
return;
@@ -754,7 +756,7 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *unused)
}
else {
glTranslatef((float)x, (float)y, 0.0f);
- glutil_draw_lined_arc(0.0, M_PI*2.0, sculpt_get_brush_size(brush), 40);
+ glutil_draw_lined_arc(0.0, M_PI*2.0, brush_size(brush), 40);
glTranslatef(-(float)x, -(float)y, 0.0f);
}
@@ -767,12 +769,12 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *unused)
if(!(paint->flags & PAINT_SHOW_BRUSH))
return;
- glColor4ubv(paint_get_active(CTX_data_scene(C))->paint_cursor_col);
+ glColor4f(brush->add_col[0], brush->add_col[1], brush->add_col[2], 0.5f);
glEnable(GL_LINE_SMOOTH);
glEnable(GL_BLEND);
glTranslatef((float)x, (float)y, 0.0f);
- glutil_draw_lined_arc(0.0, M_PI*2.0, brush->size, 40); // XXX: for now use the brushes size instead of potentially using the unified size because the feature has been enabled for sculpt
+ glutil_draw_lined_arc(0.0, M_PI*2.0, brush_size(brush), 40); // XXX: for now use the brushes size instead of potentially using the unified size because the feature has been enabled for sculpt
glTranslatef((float)-x, (float)-y, 0.0f);
glDisable(GL_BLEND);
@@ -909,10 +911,10 @@ static int paint_space_stroke(bContext *C, wmOperator *op, wmEvent *event, const
if(event->custom == EVT_DATA_TABLET) {
wmTabletData *wmtab= event->customdata;
if(wmtab->Active != EVT_TABLET_NONE)
- pressure = stroke->brush->flag & BRUSH_SIZE_PRESSURE ? wmtab->Pressure : 1;
+ pressure = brush_use_size_pressure(stroke->brush) ? wmtab->Pressure : 1;
}
- scale = (sculpt_get_brush_size(stroke->brush)*pressure*stroke->brush->spacing/50.0f) / length;
+ scale = (brush_size(stroke->brush)*pressure*stroke->brush->spacing/50.0f) / length;
mul_v2_fl(vec, scale);
steps = (int)(1.0f / scale);