svn merge ^/trunk/blender -r43482:43524
[blender.git] / source / blender / editors / sculpt_paint / sculpt.c
index b84fea29e6258d54ce4ce1b55cbee97ec7623bc7..308534ab35cfc756a469ac3f4eb4c42985096de1 100644 (file)
@@ -107,7 +107,7 @@ struct MultiresModifierData *sculpt_multires_active(Scene *scene, Object *ob)
        Mesh *me= (Mesh*)ob->data;
        ModifierData *md;
 
-       if(!CustomData_get_layer(&me->fdata, CD_MDISPS)) {
+       if(!CustomData_get_layer(&me->ldata, CD_MDISPS)) {
                /* multires can't work without displacement layer */
                return NULL;
        }
@@ -236,7 +236,7 @@ typedef struct StrokeCache {
 
        float vertex_rotation;
 
-       char saved_active_brush_name[24];
+       char saved_active_brush_name[MAX_ID_NAME];
        int alt_smooth;
 
        float plane_trim_squared;
@@ -248,90 +248,51 @@ typedef struct StrokeCache {
 
 /* Get a screen-space rectangle of the modified area */
 static int sculpt_get_redraw_rect(ARegion *ar, RegionView3D *rv3d,
-                               Object *ob, rcti *rect)
+                                                                 Object *ob, rcti *rect)
 {
+       SculptSession *ss;
        PBVH *pbvh= ob->sculpt->pbvh;
-       float bb_min[3], bb_max[3], pmat[4][4];
-       int i, j, k;
-
-       ED_view3d_ob_project_mat_get(rv3d, ob, pmat);
+       float bb_min[3], bb_max[3];
 
        if(!pbvh)
                return 0;
 
        BLI_pbvh_redraw_BB(pbvh, bb_min, bb_max);
 
-       rect->xmin = rect->ymin = INT_MAX;
-       rect->xmax = rect->ymax = INT_MIN;
-
-       if(bb_min[0] > bb_max[0] || bb_min[1] > bb_max[1] || bb_min[2] > bb_max[2])
+       /* convert 3D bounding box to screen space */
+       if(!paint_convert_bb_to_rect(rect,
+                                                                bb_min,
+                                                                bb_max,
+                                                                ar,
+                                                                rv3d,
+                                                                ob)) {
                return 0;
-
-       for(i = 0; i < 2; ++i) {
-               for(j = 0; j < 2; ++j) {
-                       for(k = 0; k < 2; ++k) {
-                               float vec[3], proj[2];
-                               vec[0] = i ? bb_min[0] : bb_max[0];
-                               vec[1] = j ? bb_min[1] : bb_max[1];
-                               vec[2] = k ? bb_min[2] : bb_max[2];
-                               ED_view3d_project_float(ar, vec, proj, pmat);
-                               rect->xmin = MIN2(rect->xmin, proj[0]);
-                               rect->xmax = MAX2(rect->xmax, proj[0]);
-                               rect->ymin = MIN2(rect->ymin, proj[1]);
-                               rect->ymax = MAX2(rect->ymax, proj[1]);
-                       }
-               }
        }
-       
-       if (rect->xmin < rect->xmax && rect->ymin < rect->ymax) {
-               /* expand redraw rect with redraw rect from previous step to prevent
-                  partial-redraw issues caused by fast strokes. This is needed here (not in sculpt_flush_update)
-                  as it was before because redraw rectangle should be the same in both of
-                  optimized PBVH draw function and 3d view redraw (if not -- some mesh parts could
-                  disapper from screen (sergey) */
-               SculptSession *ss = ob->sculpt;
-
-               if (ss->cache) {
-                       if (!BLI_rcti_is_empty(&ss->cache->previous_r))
-                               BLI_union_rcti(rect, &ss->cache->previous_r);
-               }
 
-               return 1;
+       /* expand redraw rect with redraw rect from previous step to
+          prevent partial-redraw issues caused by fast strokes. This is
+          needed here (not in sculpt_flush_update) as it was before
+          because redraw rectangle should be the same in both of
+          optimized PBVH draw function and 3d view redraw (if not -- some
+          mesh parts could disapper from screen (sergey) */
+       ss = ob->sculpt;
+       if(ss->cache) {
+               if(!BLI_rcti_is_empty(&ss->cache->previous_r))
+                       BLI_union_rcti(rect, &ss->cache->previous_r);
        }
 
-       return 0;
+       return 1;
 }
 
 void sculpt_get_redraw_planes(float planes[4][4], ARegion *ar,
                                  RegionView3D *rv3d, Object *ob)
 {
        PBVH *pbvh= ob->sculpt->pbvh;
-       BoundBox bb;
-       bglMats mats;
        rcti rect;
 
-       memset(&bb, 0, sizeof(BoundBox));
-
-       view3d_get_transformation(ar, rv3d, ob, &mats);
-       sculpt_get_redraw_rect(ar, rv3d,ob, &rect);
-
-#if 1
-       /* use some extra space just in case */
-       rect.xmin -= 2;
-       rect.xmax += 2;
-       rect.ymin -= 2;
-       rect.ymax += 2;
-#else
-       /* it was doing this before, allows to redraw a smaller
-          part of the screen but also gives artifaces .. */
-       rect.xmin += 2;
-       rect.xmax -= 2;
-       rect.ymin += 2;
-       rect.ymax -= 2;
-#endif
+       sculpt_get_redraw_rect(ar, rv3d, ob, &rect);
 
-       ED_view3d_calc_clipping(&bb, planes, &mats, &rect);
-       mul_m4_fl(planes, -1.0f);
+       paint_calc_redraw_planes(planes, ar, rv3d, ob, &rect);
 
        /* clear redraw flag from nodes */
        if(pbvh)
@@ -582,17 +543,23 @@ 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(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);
-       float overlap      = (brush->flag & BRUSH_SPACE_ATTEN && brush->flag & BRUSH_SPACE && !(brush->flag & BRUSH_ANCHORED)) && (brush->spacing < 100) ? 1.0f/accum : 1; // spacing is integer percentage of radius, divide by 50 to get normalized diameter
+       /* spacing is integer percentage of radius, divide by 50 to get
+          normalized diameter */
+       float overlap      = (brush->flag & BRUSH_SPACE_ATTEN &&
+                                                 brush->flag & BRUSH_SPACE &&
+                                                 !(brush->flag & BRUSH_ANCHORED) &&
+                                                 (brush->spacing < 100)) ? 1.0f/accum : 1;
        float flip         = dir * invert * pen_flip;
 
        switch(brush->sculpt_tool){
@@ -707,16 +674,16 @@ static float tex_strength(SculptSession *ss, Brush *br, float point[3],
 
                        radius = ss->cache->pixel_radius; // use pressure adjusted size for fixed mode
 
-                       x = point_2d[0];
-                       y = point_2d[1];
+                       x = point_2d[0] + ss->cache->vc->ar->winrct.xmin;
+                       y = point_2d[1] + ss->cache->vc->ar->winrct.ymin;
                }
                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] - ss->cache->vc->ar->winrct.xmin;
-                       y = point_2d[1] - ss->cache->vc->ar->winrct.ymin;
+                       x = point_2d[0];
+                       y = point_2d[1];
                }
 
                x /= ss->cache->vc->ar->winx;
@@ -1201,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;
@@ -1216,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;
 
@@ -1688,7 +1656,7 @@ static void calc_flatten_center(Sculpt *sd, Object *ob, PBVHNode **nodes, int to
                if(ss->cache->original) {
                        BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) {
                                if(sculpt_brush_test_fast(&test, unode->co[vd.i])) {
-                                       add_v3_v3(private_fc, vd.co);
+                                       add_v3_v3(private_fc, unode->co[vd.i]);
                                        private_count++;
                                }
                        }
@@ -1716,7 +1684,9 @@ static void calc_flatten_center(Sculpt *sd, Object *ob, PBVHNode **nodes, int to
 
 /* this calculates flatten center and area normal together, 
 amortizing the memory bandwidth and loop overhead to calculate both at the same time */
-static void calc_area_normal_and_flatten_center(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode, float an[3], float fc[3])
+static void calc_area_normal_and_flatten_center(Sculpt *sd, Object *ob,
+                                                                                               PBVHNode **nodes, int totnode,
+                                                                                               float an[3], float fc[3])
 {
        SculptSession *ss = ob->sculpt;
        int n;
@@ -1758,7 +1728,7 @@ static void calc_area_normal_and_flatten_center(Sculpt *sd, Object *ob, PBVHNode
                                        add_norm_if(ss->cache->view_normal, private_an, private_out_flip, fno);
 
                                        // fc
-                                       add_v3_v3(private_fc, vd.co);
+                                       add_v3_v3(private_fc, unode->co[vd.i]);
                                        private_count++;
                                }
                        }
@@ -2121,7 +2091,7 @@ static void do_clay_tubes_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int to
        copy_v3_v3(mat[3], ss->cache->location);  mat[3][3] = 1;
        normalize_m4(mat);
        scale_m4_fl(scale, ss->cache->radius);
-       mul_m4_m4m4(tmat, scale, mat);
+       mult_m4_m4m4(tmat, mat, scale);
        invert_m4_m4(mat, tmat);
 
        #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP)
@@ -2331,7 +2301,7 @@ void sculpt_vertcos_to_key(Object *ob, KeyBlock *kb, float (*vertCos)[3])
                for (a= 0; a < me->totvert; a++, mvert++)
                        copy_v3_v3(mvert->co, vertCos[a]);
 
-               mesh_calc_normals(me->mvert, me->totvert, me->mface, me->totface, NULL);
+               mesh_calc_normals_mapping(me->mvert, me->totvert, me->mloop, me->mpoly, me->totloop, me->totpoly, NULL, NULL, 0, NULL, NULL);
        }
 
        /* apply new coords on active key block */
@@ -2564,7 +2534,7 @@ static void sculpt_flush_stroke_deform(Sculpt *sd, Object *ob)
                /* Modifiers could depend on mesh normals, so we should update them/
                   Note, then if sculpting happens on locked key, normals should be re-calculated
                   after applying coords from keyblock on base mesh */
-               mesh_calc_normals(me->mvert, me->totvert, me->mface, me->totface, NULL);
+               mesh_calc_normals_mapping(me->mvert, me->totvert, me->mloop, me->mpoly, me->totloop, me->totpoly, NULL, NULL, 0, NULL, NULL);
        } else if (ss->kb)
                sculpt_update_keyblock(ob);
 }
@@ -2588,7 +2558,9 @@ static void sculpt_flush_stroke_deform(Sculpt *sd, Object *ob)
 
 /* Flip all the editdata across the axis/axes specified by symm. Used to
    calculate multiple modifications to the mesh when symmetry is enabled. */
-static void calc_brushdata_symm(Sculpt *sd, StrokeCache *cache, const char symm, const char axis, const float angle, const float UNUSED(feather))
+static void calc_brushdata_symm(Sculpt *sd, StrokeCache *cache, const char symm,
+                                                               const char axis, const float angle,
+                                                               const float UNUSED(feather))
 {
        (void)sd; /* unused */
 
@@ -2620,7 +2592,9 @@ static void calc_brushdata_symm(Sculpt *sd, StrokeCache *cache, const char symm,
        mul_m4_v3(cache->symm_rot_mat, cache->grab_delta_symmetry);
 }
 
-static void do_radial_symmetry(Sculpt *sd, Object *ob, Brush *brush, const char symm, const int axis, const float feather)
+static void do_radial_symmetry(Sculpt *sd, Object *ob, Brush *brush,
+                                                          const char symm, const int axis,
+                                                          const float feather)
 {
        SculptSession *ss = ob->sculpt;
        int i;
@@ -2686,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);
@@ -2718,7 +2692,7 @@ void sculpt_update_mesh_elements(Scene *scene, Sculpt *sd, Object *ob, int need_
        if(mmd) {
                ss->multires = mmd;
                ss->totvert = dm->getNumVerts(dm);
-               ss->totface = dm->getNumFaces(dm);
+               ss->totface = dm->getNumTessFaces(dm);
                ss->mvert= NULL;
                ss->mface= NULL;
                ss->face_normals= NULL;
@@ -2954,7 +2928,10 @@ static void sculpt_update_cache_invariants(bContext* C, Sculpt *sd, SculptSessio
                cache->original = 1;
        }
 
-       if(ELEM8(brush->sculpt_tool, SCULPT_TOOL_DRAW,  SCULPT_TOOL_CREASE, SCULPT_TOOL_BLOB, SCULPT_TOOL_LAYER, SCULPT_TOOL_INFLATE, SCULPT_TOOL_CLAY, SCULPT_TOOL_CLAY_TUBES, SCULPT_TOOL_ROTATE))
+       if(ELEM8(brush->sculpt_tool,
+                        SCULPT_TOOL_DRAW, SCULPT_TOOL_CREASE, SCULPT_TOOL_BLOB,
+                        SCULPT_TOOL_LAYER, SCULPT_TOOL_INFLATE, SCULPT_TOOL_CLAY,
+                        SCULPT_TOOL_CLAY_TUBES, SCULPT_TOOL_ROTATE))
                if(!(brush->flag & BRUSH_ACCUMULATE))
                        cache->original = 1;
 
@@ -3038,8 +3015,11 @@ static void sculpt_update_brush_delta(Sculpt *sd, Object *ob, Brush *brush)
 }
 
 /* Initialize the stroke cache variants from operator properties */
-static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob, struct PaintStroke *stroke, PointerRNA *ptr)
+static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob,
+                                                                                struct PaintStroke *stroke,
+                                                                                PointerRNA *ptr)
 {
+       Scene *scene = CTX_data_scene(C);
        SculptSession *ss = ob->sculpt;
        StrokeCache *cache = ss->cache;
        Brush *brush = paint_brush(&sd->paint);
@@ -3074,19 +3054,19 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob, st
        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(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);
+               if (!brush_use_locked_size(scene, brush)) {
+                       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);
                }
        }
 
-       if(brush_use_size_pressure(brush)) {
+       if(brush_use_size_pressure(scene, brush)) {
                cache->pixel_radius *= cache->pressure;
                cache->radius= cache->initial_radius * cache->pressure;
        }
@@ -3095,7 +3075,9 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob, st
 
        cache->radius_squared = cache->radius*cache->radius;
 
-       if(!(brush->flag & BRUSH_ANCHORED || ELEM4(brush->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_SNAKE_HOOK, SCULPT_TOOL_THUMB, SCULPT_TOOL_ROTATE))) {
+       if(!(brush->flag & BRUSH_ANCHORED ||
+                ELEM4(brush->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_SNAKE_HOOK,
+                          SCULPT_TOOL_THUMB, SCULPT_TOOL_ROTATE))) {
                copy_v2_v2(cache->tex_mouse, cache->mouse);
 
                if  ( (brush->mtex.brush_map_mode == MTEX_MAP_MODE_FIXED) &&
@@ -3123,7 +3105,7 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob, st
                        halfway[0] = (float)dx * 0.5f + cache->initial_mouse[0];
                        halfway[1] = (float)dy * 0.5f + cache->initial_mouse[1];
 
-                       if (sculpt_stroke_get_location(C, stroke, out, halfway)) {
+                       if (sculpt_stroke_get_location(C, out, halfway)) {
                                copy_v3_v3(sd->anchored_location, out);
                                copy_v2_v2(sd->anchored_initial_mouse, halfway);
                                copy_v2_v2(cache->tex_mouse, halfway);
@@ -3137,7 +3119,9 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob, st
                if (!hit)
                        copy_v2_v2(sd->anchored_initial_mouse, cache->initial_mouse);
 
-               cache->radius= paint_calc_object_space_radius(paint_stroke_view_context(stroke), cache->true_location, cache->pixel_radius);
+               cache->radius= paint_calc_object_space_radius(paint_stroke_view_context(stroke),
+                                                                                                         cache->true_location,
+                                                                                                         cache->pixel_radius);
                cache->radius_squared = cache->radius*cache->radius;
 
                copy_v3_v3(sd->anchored_location, cache->true_location);
@@ -3223,23 +3207,29 @@ static void sculpt_raycast_cb(PBVHNode *node, void *data_v, float* tmin)
    (This allows us to ignore the GL depth buffer)
    Returns 0 if the ray doesn't hit the mesh, non-zero otherwise
  */
-int sculpt_stroke_get_location(bContext *C, struct PaintStroke *stroke, float out[3], float mouse[2])
+int sculpt_stroke_get_location(bContext *C, float out[3], float mouse[2])
 {
-       ViewContext *vc = paint_stroke_view_context(stroke);
-       Object *ob = vc->obact;
-       SculptSession *ss= ob->sculpt;
-       StrokeCache *cache= ss->cache;
+       ViewContext vc;
+       Object *ob;
+       SculptSession *ss;
+       StrokeCache *cache;
        float ray_start[3], ray_end[3], ray_normal[3], dist;
        float obimat[4][4];
        float mval[2];
        SculptRaycastData srd;
 
-       mval[0] = mouse[0] - vc->ar->winrct.xmin;
-       mval[1] = mouse[1] - vc->ar->winrct.ymin;
+       view3d_set_viewcontext(C, &vc);
+       
+       ob = vc.obact;
+       ss = ob->sculpt;
+       cache = ss->cache;
 
        sculpt_stroke_modifiers_check(C, ob);
 
-       ED_view3d_win_to_segment_clip(vc->ar, vc->v3d, mval, ray_start, ray_end);
+       mval[0] = mouse[0] - vc.ar->winrct.xmin;
+       mval[1] = mouse[1] - vc.ar->winrct.ymin;
+
+       ED_view3d_win_to_segment_clip(vc.ar, vc.v3d, mval, ray_start, ray_end);
 
        invert_m4_m4(obimat, ob->obmat);
        mul_m4_v3(obimat, ray_start);
@@ -3248,7 +3238,7 @@ int sculpt_stroke_get_location(bContext *C, struct PaintStroke *stroke, float ou
        sub_v3_v3v3(ray_normal, ray_end, ray_start);
        dist= normalize_v3(ray_normal);
 
-       srd.ss = vc->obact->sculpt;
+       srd.ss = vc.obact->sculpt;
        srd.ray_start = ray_start;
        srd.ray_normal = ray_normal;
        srd.dist = dist;
@@ -3264,7 +3254,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;
@@ -3276,7 +3266,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)
@@ -3290,7 +3280,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;
@@ -3306,7 +3296,8 @@ static void sculpt_restore_mesh(Sculpt *sd, SculptSession *ss)
 
        /* Restore the mesh before continuing with anchored stroke */
        if((brush->flag & BRUSH_ANCHORED) ||
-          (brush->sculpt_tool == SCULPT_TOOL_GRAB && brush_use_size_pressure(brush)) ||
+          (brush->sculpt_tool == SCULPT_TOOL_GRAB &&
+               brush_use_size_pressure(ss->cache->vc->scene, brush)) ||
           (brush->flag & BRUSH_RESTORE_MESH))
        {
                StrokeCache *cache = ss->cache;
@@ -3386,14 +3377,14 @@ static void sculpt_flush_update(bContext *C)
 
 /* Returns whether the mouse/stylus is over the mesh (1)
    or over the background (0) */
-static int over_mesh(bContext *C, struct wmOperator *op, float x, float y)
+static int over_mesh(bContext *C, struct wmOperator *UNUSED(op), float x, float y)
 {
        float mouse[2], co[3];
 
        mouse[0] = x;
        mouse[1] = y;
 
-       return sculpt_stroke_get_location(C, op->customdata, co, mouse);
+       return sculpt_stroke_get_location(C, co, mouse);
 }
 
 static int sculpt_stroke_test_start(bContext *C, struct wmOperator *op,