Vertex Paint: orbit last stroke support

This option works for all paint modes now.
This commit is contained in:
Campbell Barton 2015-10-30 09:53:27 +11:00
parent cd1d6d7770
commit 8014180720
2 changed files with 24 additions and 1 deletions

@ -91,6 +91,19 @@ static bool vertex_paint_use_fast_update_check(Object *ob)
return false;
}
static void paint_last_stroke_update(Scene *scene, ARegion *ar, const float mval[2])
{
const int mval_i[2] = {mval[0], mval[1]};
float world[3];
if (ED_view3d_autodist_simple(ar, mval_i, world, 0, NULL)) {
UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
ups->average_stroke_counter++;
add_v3_v3(ups->average_stroke_accum, world);
ups->last_stroke_valid = true;
}
}
/* polling - retrieve whether cursor should be set or operator should be done */
/* Returns true if vertex paint mode is active */
@ -2379,6 +2392,11 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
swap_m4m4(vc->rv3d->persmat, mat);
/* calculate pivot for rotation around seletion if needed */
if (U.uiflag & USER_ORBIT_SELECTION) {
paint_last_stroke_update(scene, vc->ar, mval);
}
DAG_id_tag_update(ob->data, 0);
ED_region_tag_redraw(vc->ar);
}
@ -2833,6 +2851,11 @@ static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
do_shared_vertexcol(me, vpd->mlooptag);
}
/* calculate pivot for rotation around seletion if needed */
if (U.uiflag & USER_ORBIT_SELECTION) {
paint_last_stroke_update(scene, vc->ar, mval);
}
ED_region_tag_redraw(vc->ar);
if (vpd->use_fast_update == false) {

@ -640,7 +640,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 | OB_MODE_TEXTURE_PAINT)) {
if (ob->mode & (OB_MODE_SCULPT | OB_MODE_TEXTURE_PAINT | OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT)) {
float stroke[3];
BKE_paint_stroke_get_average(scene, ob, stroke);
copy_v3_v3(lastofs, stroke);