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:
Diffstat (limited to 'source/blender/editors/sculpt_paint/paint_stroke.c')
-rw-r--r--source/blender/editors/sculpt_paint/paint_stroke.c70
1 files changed, 37 insertions, 33 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c
index 7b8d7c4b7ef..6d58731d79c 100644
--- a/source/blender/editors/sculpt_paint/paint_stroke.c
+++ b/source/blender/editors/sculpt_paint/paint_stroke.c
@@ -30,6 +30,7 @@
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
+#include "DNA_brush_types.h"
#include "RNA_access.h"
@@ -52,7 +53,6 @@
#include "paint_intern.h"
#include "sculpt_intern.h" // XXX, for expedience in getting this working, refactor later (or this just shows that this needs unification)
-#include "BKE_image.h"
#include <float.h>
#include <math.h>
@@ -69,7 +69,7 @@ typedef struct PaintStroke {
float last_mouse_position[2];
- /* Set whether any stroke step has yet occured
+ /* Set whether any stroke step has yet occurred
e.g. in sculpt mode, stroke doesn't start until cursor
passes over the mesh */
int stroke_started;
@@ -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;
@@ -376,7 +376,7 @@ int load_tex(Sculpt *sd, Brush* br, ViewContext* vc)
if (br->mtex.brush_map_mode == MTEX_MAP_MODE_FIXED)
avg *= brush_curve_strength(br, len, 1); /* Falloff curve */
- buffer[index] = (GLubyte)(255*avg);
+ buffer[index] = 255 - (GLubyte)(255*avg);
}
else {
buffer[index] = 0;
@@ -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,8 @@ 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);
+ const float root_alpha = brush_alpha(brush);
+ float visual_strength = root_alpha*root_alpha;
const float min_alpha = 0.20f;
const float max_alpha = 0.80f;
@@ -577,13 +578,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 +634,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 +663,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 +705,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 +718,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 +757,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 +770,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);
@@ -786,7 +789,7 @@ static void paint_brush_stroke_add_step(bContext *C, wmOperator *op, wmEvent *ev
Paint *paint = paint_get_active(CTX_data_scene(C)); // XXX
Brush *brush = paint_brush(paint); // XXX
- float mouse[2];
+ float mouse[3];
PointerRNA itemptr;
@@ -909,10 +912,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);
@@ -1002,8 +1005,9 @@ int paint_stroke_modal(bContext *C, wmOperator *op, wmEvent *event)
paint_brush_stroke_add_step(C, op, event, mouse);
}
}
- else
+ else {
;//ED_region_tag_redraw(ar);
+ }
}
}