merge with trunk at r31523
[blender.git] / source / blender / editors / sculpt_paint / sculpt.c
index 10af35a1b4b47d36c9d7e937f05047ccdfc612d2..b1fd32c7607f3483c692ebf32a895a5adfe0a02a 100644 (file)
@@ -188,6 +188,8 @@ typedef struct StrokeCache {
        float mouse[2];
        float bstrength;
        float tex_mouse[2];
+       
+       rctf prect;
 
        /* The rest is temporary storage that isn't saved as a property */
 
@@ -258,10 +260,20 @@ static void projectf(bglMats *mats, const float v[3], float p[2])
 int sculpt_get_redraw_rect(ARegion *ar, RegionView3D *rv3d,
                                Object *ob, rcti *rect)
 {
+       StrokeCache *cache = ob->sculpt->cache;
        PBVH *pbvh= ob->sculpt->pbvh;
        float bb_min[3], bb_max[3], pmat[4][4];
        int i, j, k;
 
+/*     if (G.rt == 1) {
+               rect->xmin = cache->prect.xmin;
+               rect->xmax = cache->prect.xmax;
+               rect->ymin = cache->prect.ymin;
+               rect->ymax = cache->prect.ymax;
+
+               return rect->xmin < rect->xmax && rect->ymin < rect->ymax;;
+       }
+*/
        view3d_get_object_project_mat(rv3d, ob, pmat);
 
        if(!pbvh)
@@ -300,6 +312,7 @@ void sculpt_get_redraw_planes(float planes[4][4], ARegion *ar,
        PBVH *pbvh= ob->sculpt->pbvh;
        BoundBox bb;
        bglMats mats;
+       StrokeCache *cache = ob->sculpt->cache;
        rcti rect;
 
        memset(&bb, 0, sizeof(BoundBox));
@@ -328,6 +341,13 @@ void sculpt_get_redraw_planes(float planes[4][4], ARegion *ar,
        /* clear redraw flag from nodes */
        if(pbvh)
                BLI_pbvh_update(pbvh, PBVH_UpdateRedraw, NULL);
+
+       /*clear prect*/
+       cache->prect.xmin = FLT_MAX;
+       cache->prect.xmax = -FLT_MAX;
+       cache->prect.ymin = FLT_MAX;
+       cache->prect.ymax = -FLT_MAX;
+
 }
 
 /************************ Brush Testing *******************/
@@ -2207,10 +2227,11 @@ static void do_fill_brush(Sculpt *sd, SculptSession *ss, PBVHNode **nodes, int t
 static void do_scrape_brush(Sculpt *sd, SculptSession *ss, PBVHNode **nodes, int totnode)
 {
        Brush *brush = paint_brush(&sd->paint);
+       rctf mr;
+       float xrad, yrad;
 
        float bstrength = ss->cache->bstrength;
        const float radius = ss->cache->radius;
-
        float an[3];
        float fc[3];
        float offset = get_offset(sd, ss);
@@ -2640,7 +2661,7 @@ void sculpt_update_mesh_elements(Scene *scene, Object *ob, int need_fmap)
        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;
@@ -2819,6 +2840,11 @@ static void sculpt_update_cache_invariants(bContext* C, Sculpt *sd, SculptSessio
        int mode;
 
        ss->cache = cache;
+       
+       cache->prect.xmin = FLT_MAX;
+       cache->prect.xmax = -FLT_MAX;
+       cache->prect.ymin = FLT_MAX;
+       cache->prect.ymax = -FLT_MAX;
 
        /* Set scaling adjustment */
        ss->cache->scale[0] = 1.0f / ob->size[0];
@@ -3307,16 +3333,17 @@ static void sculpt_flush_update(bContext *C)
        }
        else {
                rcti r;
+               int off = 0;
 
                BLI_pbvh_update(ss->pbvh, PBVH_UpdateBB, NULL);
 
                if (sculpt_get_redraw_rect(ar, CTX_wm_region_view3d(C), ob, &r)) {
                        //rcti tmp;
 
-                       r.xmin += ar->winrct.xmin + 1;
-                       r.xmax += ar->winrct.xmin - 1;
-                       r.ymin += ar->winrct.ymin + 1;
-                       r.ymax += ar->winrct.ymin - 1;
+                       r.xmin += ar->winrct.xmin + 1 + off;
+                       r.xmax += ar->winrct.xmin - 1 - off;
+                       r.ymin += ar->winrct.ymin + 1 + off;
+                       r.ymax += ar->winrct.ymin - 1 - off;
 
                        //tmp = r;