Commit: 18854a65065456d9a92ad9408b7b32f1a70cafae
Author: Antony Riakiotakis
Date:   Mon Dec 29 12:34:46 2014 +0100
Branches: master
https://developer.blender.org/rB18854a65065456d9a92ad9408b7b32f1a70cafae

Rotate around selection now will work on last stroke position in texture
paint too.

===================================================================

M       source/blender/editors/sculpt_paint/paint_image_proj.c
M       source/blender/editors/sculpt_paint/paint_stroke.c
M       source/blender/editors/sculpt_paint/sculpt.c
M       source/blender/editors/space_view3d/view3d_edit.c

===================================================================

diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c 
b/source/blender/editors/sculpt_paint/paint_image_proj.c
index 0e337e9..0832782 100644
--- a/source/blender/editors/sculpt_paint/paint_image_proj.c
+++ b/source/blender/editors/sculpt_paint/paint_image_proj.c
@@ -4521,7 +4521,34 @@ static bool project_paint_op(void *state, const float 
lastpos[2], const float po
                        touch_any = 1;
                }
        }
+       
+       /* calculate pivot for rotation around seletion if needed */
+       if (U.uiflag & USER_ORBIT_SELECTION) {
+               float w[3];
+               int side, index;
+               
+               index = project_paint_PickFace(ps, pos, w, &side);
+               
+               if (index != -1) {
+                       MFace *mf;
+                       float world[3];
+                       UnifiedPaintSettings *ups = 
&ps->scene->toolsettings->unified_paint_settings;
+
+                       mf = ps->dm_mface + index;
 
+                       if (side == 0) {
+                               interp_v3_v3v3v3(world, 
ps->dm_mvert[(*(&mf->v1))].co, ps->dm_mvert[(*(&mf->v2))].co, 
ps->dm_mvert[(*(&mf->v3))].co, w);
+                       }
+                       else {
+                               interp_v3_v3v3v3(world, 
ps->dm_mvert[(*(&mf->v1))].co, ps->dm_mvert[(*(&mf->v3))].co, 
ps->dm_mvert[(*(&mf->v4))].co, w);
+                       }
+                       
+                       ups->average_stroke_counter++;
+                       add_v3_v3(ups->average_stroke_accum, world);
+                       ups->last_stroke_valid = true;
+               }
+       }
+       
        return touch_any;
 }
 
diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c 
b/source/blender/editors/sculpt_paint/paint_stroke.c
index bd5fa83..02a2893 100644
--- a/source/blender/editors/sculpt_paint/paint_stroke.c
+++ b/source/blender/editors/sculpt_paint/paint_stroke.c
@@ -662,6 +662,10 @@ PaintStroke *paint_stroke_new(bContext *C,
        /* initialize here */
        ups->overlap_factor = 1.0;
        ups->stroke_active = true;
+       
+       zero_v3(ups->average_stroke_accum);
+       ups->average_stroke_counter = 0;
+       
 
        /* initialize here to avoid initialization conflict with threaded 
strokes */
        curvemapping_initialize(br->curve);
diff --git a/source/blender/editors/sculpt_paint/sculpt.c 
b/source/blender/editors/sculpt_paint/sculpt.c
index a6e1a19..dbb2999 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -3109,6 +3109,8 @@ static void do_brush_action(Sculpt *sd, Object *ob, Brush 
*brush, UnifiedPaintSe
 
                add_v3_v3(ups->average_stroke_accum, location);
                ups->average_stroke_counter++;
+               /* update last stroke position */
+               ups->last_stroke_valid = true;
        }
 }
 
@@ -4107,7 +4109,6 @@ static void sculpt_brush_init_tex(const Scene *scene, 
Sculpt *sd, SculptSession
 static bool sculpt_brush_stroke_init(bContext *C, wmOperator *op)
 {
        Scene *scene = CTX_data_scene(C);
-       UnifiedPaintSettings *ups = 
&scene->toolsettings->unified_paint_settings;
        Object *ob = CTX_data_active_object(C);
        Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
        SculptSession *ss = CTX_data_active_object(C)->sculpt;
@@ -4126,9 +4127,6 @@ static bool sculpt_brush_stroke_init(bContext *C, 
wmOperator *op)
        is_smooth = sculpt_any_smooth_mode(brush, NULL, mode);
        BKE_sculpt_update_mesh_elements(scene, sd, ob, is_smooth, need_mask);
 
-       zero_v3(ups->average_stroke_accum);
-       ups->average_stroke_counter = 0;
-
        return 1;
 }
 
@@ -4335,9 +4333,6 @@ static void sculpt_stroke_done(const bContext *C, struct 
PaintStroke *UNUSED(str
                        }
                }
 
-               /* update last stroke position */
-               ups->last_stroke_valid = true;
-
                sculpt_cache_free(ss->cache);
                ss->cache = NULL;
 
diff --git a/source/blender/editors/space_view3d/view3d_edit.c 
b/source/blender/editors/space_view3d/view3d_edit.c
index af9b0ed..3fd59cc 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -625,7 +625,7 @@ static bool view3d_orbit_calc_center(bContext *C, float 
r_dyn_ofs[3])
                 * center, in other cases it's not clear what rotation center 
shall be
                 * so just rotate around object origin
                 */
-               if (ob->mode & OB_MODE_SCULPT) {
+               if (ob->mode & (OB_MODE_SCULPT | OB_MODE_TEXTURE_PAINT)) {
                        float stroke[3];
                        BKE_paint_stroke_get_average(scene, ob, stroke);
                        copy_v3_v3(lastofs, stroke);
@@ -2975,7 +2975,7 @@ static int viewselected_exec(bContext *C, wmOperator *op)
        else if (ob && (ob->mode & OB_MODE_PARTICLE_EDIT)) {
                ok = PE_minmax(scene, min, max);
        }
-       else if (ob && (ob->mode & OB_MODE_SCULPT)) {
+       else if (ob && (ob->mode & (OB_MODE_SCULPT | OB_MODE_TEXTURE_PAINT))) {
                BKE_paint_stroke_get_average(scene, ob, min);
                copy_v3_v3(max, min);
                ok = true;

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to