svn merge -r 30566:30717 https://svn.blender.org/svnroot/bf-blender/trunk/blender
[blender.git] / source / blender / editors / sculpt_paint / paint_stroke.c
index 81f471481fbd49067776df883b02a2a4c0977782..5eeb8492019f77674b6f469074eb2f04ab09b1f3 100644 (file)
@@ -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);