forked from bartvdbraak/blender
Rotate around selection now will work on last stroke position in texture
paint too.
This commit is contained in:
parent
51a66a5a6e
commit
18854a6506
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user