Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/sculpt_paint/paint_vertex.cc
| Show First 20 Lines • Show All 992 Lines • ▼ Show 20 Lines | |||||
| if (wpi->do_multipaint) { | if (wpi->do_multipaint) { | ||||
| do_weight_paint_vertex_multi(wp, ob, wpi, index, alpha, paintweight); | do_weight_paint_vertex_multi(wp, ob, wpi, index, alpha, paintweight); | ||||
| } | } | ||||
| else { | else { | ||||
| do_weight_paint_vertex_single(wp, ob, wpi, index, alpha, paintweight); | do_weight_paint_vertex_single(wp, ob, wpi, index, alpha, paintweight); | ||||
| } | } | ||||
| } | } | ||||
| /* Toggle operator for turning vertex paint mode on or off (copied from sculpt.c) */ | /* Toggle operator for turning vertex paint mode on or off (copied from sculpt.cc) */ | ||||
| static void vertex_paint_init_session(Depsgraph *depsgraph, | static void vertex_paint_init_session(Depsgraph *depsgraph, | ||||
| Scene *scene, | Scene *scene, | ||||
| Object *ob, | Object *ob, | ||||
| eObjectMode object_mode) | eObjectMode object_mode) | ||||
| { | { | ||||
| /* Create persistent sculpt mode data */ | /* Create persistent sculpt mode data */ | ||||
| BKE_sculpt_toolsettings_data_ensure(scene); | BKE_sculpt_toolsettings_data_ensure(scene); | ||||
| ▲ Show 20 Lines • Show All 1,209 Lines • ▼ Show 20 Lines | |||||
| static void wpaint_do_paint(bContext *C, | static void wpaint_do_paint(bContext *C, | ||||
| Object *ob, | Object *ob, | ||||
| VPaint *wp, | VPaint *wp, | ||||
| Sculpt *sd, | Sculpt *sd, | ||||
| WPaintData *wpd, | WPaintData *wpd, | ||||
| WeightPaintInfo *wpi, | WeightPaintInfo *wpi, | ||||
| Mesh *me, | Mesh *me, | ||||
| Brush *brush, | Brush *brush, | ||||
| const char symm, | const ePaintSymmetryFlags symm, | ||||
| const int axis, | const int axis, | ||||
| const int i, | const int i, | ||||
| const float angle) | const float angle) | ||||
| { | { | ||||
| SculptSession *ss = ob->sculpt; | SculptSession *ss = ob->sculpt; | ||||
| ss->cache->radial_symmetry_pass = i; | ss->cache->radial_symmetry_pass = i; | ||||
| SCULPT_cache_calc_brushdata_symm(ss->cache, symm, axis, angle); | SCULPT_cache_calc_brushdata_symm(ss->cache, symm, axis, angle); | ||||
| Show All 10 Lines | |||||
| static void wpaint_do_radial_symmetry(bContext *C, | static void wpaint_do_radial_symmetry(bContext *C, | ||||
| Object *ob, | Object *ob, | ||||
| VPaint *wp, | VPaint *wp, | ||||
| Sculpt *sd, | Sculpt *sd, | ||||
| WPaintData *wpd, | WPaintData *wpd, | ||||
| WeightPaintInfo *wpi, | WeightPaintInfo *wpi, | ||||
| Mesh *me, | Mesh *me, | ||||
| Brush *brush, | Brush *brush, | ||||
| const char symm, | const ePaintSymmetryFlags symm, | ||||
| const int axis) | const int axis) | ||||
| { | { | ||||
| for (int i = 1; i < wp->radial_symm[axis - 'X']; i++) { | for (int i = 1; i < wp->radial_symm[axis - 'X']; i++) { | ||||
| const float angle = (2.0 * M_PI) * i / wp->radial_symm[axis - 'X']; | const float angle = (2.0 * M_PI) * i / wp->radial_symm[axis - 'X']; | ||||
| wpaint_do_paint(C, ob, wp, sd, wpd, wpi, me, brush, symm, axis, i, angle); | wpaint_do_paint(C, ob, wp, sd, wpd, wpi, me, brush, symm, axis, i, angle); | ||||
| } | } | ||||
| } | } | ||||
| /* near duplicate of: sculpt.c's, | /* near duplicate of: sculpt.cc's, | ||||
| * 'do_symmetrical_brush_actions' and 'vpaint_do_symmetrical_brush_actions'. */ | * 'do_symmetrical_brush_actions' and 'vpaint_do_symmetrical_brush_actions'. */ | ||||
| static void wpaint_do_symmetrical_brush_actions( | static void wpaint_do_symmetrical_brush_actions( | ||||
| bContext *C, Object *ob, VPaint *wp, Sculpt *sd, WPaintData *wpd, WeightPaintInfo *wpi) | bContext *C, Object *ob, VPaint *wp, Sculpt *sd, WPaintData *wpd, WeightPaintInfo *wpi) | ||||
| { | { | ||||
| Brush *brush = BKE_paint_brush(&wp->paint); | Brush *brush = BKE_paint_brush(&wp->paint); | ||||
| Mesh *me = (Mesh *)ob->data; | Mesh *me = (Mesh *)ob->data; | ||||
| SculptSession *ss = ob->sculpt; | SculptSession *ss = ob->sculpt; | ||||
| StrokeCache *cache = ss->cache; | StrokeCache *cache = ss->cache; | ||||
| const char symm = SCULPT_mesh_symmetry_xyz_get(ob); | const char symm = SCULPT_mesh_symmetry_xyz_get(ob); | ||||
| int i = 0; | int i = 0; | ||||
| /* initial stroke */ | /* initial stroke */ | ||||
| cache->mirror_symmetry_pass = 0; | cache->mirror_symmetry_pass = ePaintSymmetryFlags(0); | ||||
| wpaint_do_paint(C, ob, wp, sd, wpd, wpi, me, brush, 0, 'X', 0, 0); | wpaint_do_paint(C, ob, wp, sd, wpd, wpi, me, brush, ePaintSymmetryFlags(0), 'X', 0, 0); | ||||
| wpaint_do_radial_symmetry(C, ob, wp, sd, wpd, wpi, me, brush, 0, 'X'); | wpaint_do_radial_symmetry(C, ob, wp, sd, wpd, wpi, me, brush, ePaintSymmetryFlags(0), 'X'); | ||||
| wpaint_do_radial_symmetry(C, ob, wp, sd, wpd, wpi, me, brush, 0, 'Y'); | wpaint_do_radial_symmetry(C, ob, wp, sd, wpd, wpi, me, brush, ePaintSymmetryFlags(0), 'Y'); | ||||
| wpaint_do_radial_symmetry(C, ob, wp, sd, wpd, wpi, me, brush, 0, 'Z'); | wpaint_do_radial_symmetry(C, ob, wp, sd, wpd, wpi, me, brush, ePaintSymmetryFlags(0), 'Z'); | ||||
| cache->symmetry = symm; | cache->symmetry = symm; | ||||
| if (me->editflag & ME_EDIT_MIRROR_VERTEX_GROUPS) { | if (me->editflag & ME_EDIT_MIRROR_VERTEX_GROUPS) { | ||||
| /* We don't do any symmetry strokes when mirroring vertex groups. */ | /* We don't do any symmetry strokes when mirroring vertex groups. */ | ||||
| copy_v3_v3(cache->true_last_location, cache->true_location); | copy_v3_v3(cache->true_last_location, cache->true_location); | ||||
| cache->is_last_valid = true; | cache->is_last_valid = true; | ||||
| return; | return; | ||||
| } | } | ||||
| /* symm is a bit combination of XYZ - 1 is mirror | /* symm is a bit combination of XYZ - 1 is mirror | ||||
| * X; 2 is Y; 3 is XY; 4 is Z; 5 is XZ; 6 is YZ; 7 is XYZ */ | * X; 2 is Y; 3 is XY; 4 is Z; 5 is XZ; 6 is YZ; 7 is XYZ */ | ||||
| for (i = 1; i <= symm; i++) { | for (i = 1; i <= symm; i++) { | ||||
| if (symm & i && (symm != 5 || i != 3) && (symm != 6 || !ELEM(i, 3, 5))) { | if (symm & i && (symm != 5 || i != 3) && (symm != 6 || !ELEM(i, 3, 5))) { | ||||
| cache->mirror_symmetry_pass = i; | const ePaintSymmetryFlags symm = ePaintSymmetryFlags(i); | ||||
| cache->mirror_symmetry_pass = symm; | |||||
| cache->radial_symmetry_pass = 0; | cache->radial_symmetry_pass = 0; | ||||
| SCULPT_cache_calc_brushdata_symm(cache, i, 0, 0); | SCULPT_cache_calc_brushdata_symm(cache, symm, 0, 0); | ||||
| if (i & (1 << 0)) { | if (i & (1 << 0)) { | ||||
| wpaint_do_paint(C, ob, wp, sd, wpd, wpi, me, brush, i, 'X', 0, 0); | wpaint_do_paint(C, ob, wp, sd, wpd, wpi, me, brush, symm, 'X', 0, 0); | ||||
| wpaint_do_radial_symmetry(C, ob, wp, sd, wpd, wpi, me, brush, i, 'X'); | wpaint_do_radial_symmetry(C, ob, wp, sd, wpd, wpi, me, brush, symm, 'X'); | ||||
| } | } | ||||
| if (i & (1 << 1)) { | if (i & (1 << 1)) { | ||||
| wpaint_do_paint(C, ob, wp, sd, wpd, wpi, me, brush, i, 'Y', 0, 0); | wpaint_do_paint(C, ob, wp, sd, wpd, wpi, me, brush, symm, 'Y', 0, 0); | ||||
| wpaint_do_radial_symmetry(C, ob, wp, sd, wpd, wpi, me, brush, i, 'Y'); | wpaint_do_radial_symmetry(C, ob, wp, sd, wpd, wpi, me, brush, symm, 'Y'); | ||||
| } | } | ||||
| if (i & (1 << 2)) { | if (i & (1 << 2)) { | ||||
| wpaint_do_paint(C, ob, wp, sd, wpd, wpi, me, brush, i, 'Z', 0, 0); | wpaint_do_paint(C, ob, wp, sd, wpd, wpi, me, brush, symm, 'Z', 0, 0); | ||||
| wpaint_do_radial_symmetry(C, ob, wp, sd, wpd, wpi, me, brush, i, 'Z'); | wpaint_do_radial_symmetry(C, ob, wp, sd, wpd, wpi, me, brush, symm, 'Z'); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| copy_v3_v3(cache->true_last_location, cache->true_location); | copy_v3_v3(cache->true_last_location, cache->true_location); | ||||
| cache->is_last_valid = true; | cache->is_last_valid = true; | ||||
| } | } | ||||
| static void wpaint_stroke_update_step(bContext *C, | static void wpaint_stroke_update_step(bContext *C, | ||||
| ▲ Show 20 Lines • Show All 1,251 Lines • ▼ Show 20 Lines | |||||
| template<typename Color, typename Traits, eAttrDomain domain> | template<typename Color, typename Traits, eAttrDomain domain> | ||||
| static void vpaint_do_paint(bContext *C, | static void vpaint_do_paint(bContext *C, | ||||
| Sculpt *sd, | Sculpt *sd, | ||||
| VPaint *vp, | VPaint *vp, | ||||
| VPaintData<Color, Traits, domain> *vpd, | VPaintData<Color, Traits, domain> *vpd, | ||||
| Object *ob, | Object *ob, | ||||
| Mesh *me, | Mesh *me, | ||||
| Brush *brush, | Brush *brush, | ||||
| const char symm, | const ePaintSymmetryFlags symm, | ||||
| const int axis, | const int axis, | ||||
| const int i, | const int i, | ||||
| const float angle) | const float angle) | ||||
| { | { | ||||
| SculptSession *ss = ob->sculpt; | SculptSession *ss = ob->sculpt; | ||||
| ss->cache->radial_symmetry_pass = i; | ss->cache->radial_symmetry_pass = i; | ||||
| SCULPT_cache_calc_brushdata_symm(ss->cache, symm, axis, angle); | SCULPT_cache_calc_brushdata_symm(ss->cache, symm, axis, angle); | ||||
| Show All 14 Lines | |||||
| template<typename Color, typename Traits, eAttrDomain domain> | template<typename Color, typename Traits, eAttrDomain domain> | ||||
| static void vpaint_do_radial_symmetry(bContext *C, | static void vpaint_do_radial_symmetry(bContext *C, | ||||
| Sculpt *sd, | Sculpt *sd, | ||||
| VPaint *vp, | VPaint *vp, | ||||
| VPaintData<Color, Traits, domain> *vpd, | VPaintData<Color, Traits, domain> *vpd, | ||||
| Object *ob, | Object *ob, | ||||
| Mesh *me, | Mesh *me, | ||||
| Brush *brush, | Brush *brush, | ||||
| const char symm, | const ePaintSymmetryFlags symm, | ||||
| const int axis) | const int axis) | ||||
| { | { | ||||
| for (int i = 1; i < vp->radial_symm[axis - 'X']; i++) { | for (int i = 1; i < vp->radial_symm[axis - 'X']; i++) { | ||||
| const float angle = (2.0 * M_PI) * i / vp->radial_symm[axis - 'X']; | const float angle = (2.0 * M_PI) * i / vp->radial_symm[axis - 'X']; | ||||
| vpaint_do_paint<Color, Traits, domain>(C, sd, vp, vpd, ob, me, brush, symm, axis, i, angle); | vpaint_do_paint<Color, Traits, domain>(C, sd, vp, vpd, ob, me, brush, symm, axis, i, angle); | ||||
| } | } | ||||
| } | } | ||||
| /* near duplicate of: sculpt.c's, | /* near duplicate of: sculpt.cc's, | ||||
| * 'do_symmetrical_brush_actions' and 'wpaint_do_symmetrical_brush_actions'. */ | * 'do_symmetrical_brush_actions' and 'wpaint_do_symmetrical_brush_actions'. */ | ||||
| template<typename Color, typename Traits, eAttrDomain domain> | template<typename Color, typename Traits, eAttrDomain domain> | ||||
| static void vpaint_do_symmetrical_brush_actions( | static void vpaint_do_symmetrical_brush_actions( | ||||
| bContext *C, Sculpt *sd, VPaint *vp, VPaintData<Color, Traits, domain> *vpd, Object *ob) | bContext *C, Sculpt *sd, VPaint *vp, VPaintData<Color, Traits, domain> *vpd, Object *ob) | ||||
| { | { | ||||
| Brush *brush = BKE_paint_brush(&vp->paint); | Brush *brush = BKE_paint_brush(&vp->paint); | ||||
| Mesh *me = (Mesh *)ob->data; | Mesh *me = (Mesh *)ob->data; | ||||
| SculptSession *ss = ob->sculpt; | SculptSession *ss = ob->sculpt; | ||||
| StrokeCache *cache = ss->cache; | StrokeCache *cache = ss->cache; | ||||
| const char symm = SCULPT_mesh_symmetry_xyz_get(ob); | const char symm = SCULPT_mesh_symmetry_xyz_get(ob); | ||||
| int i = 0; | int i = 0; | ||||
| /* initial stroke */ | /* initial stroke */ | ||||
| cache->mirror_symmetry_pass = 0; | const ePaintSymmetryFlags initial_symm = ePaintSymmetryFlags(0); | ||||
| vpaint_do_paint<Color, Traits, domain>(C, sd, vp, vpd, ob, me, brush, i, 'X', 0, 0); | cache->mirror_symmetry_pass = ePaintSymmetryFlags(0); | ||||
| vpaint_do_radial_symmetry<Color, Traits, domain>(C, sd, vp, vpd, ob, me, brush, i, 'X'); | vpaint_do_paint<Color, Traits, domain>(C, sd, vp, vpd, ob, me, brush, initial_symm, 'X', 0, 0); | ||||
| vpaint_do_radial_symmetry<Color, Traits, domain>(C, sd, vp, vpd, ob, me, brush, i, 'Y'); | vpaint_do_radial_symmetry<Color, Traits, domain>( | ||||
| vpaint_do_radial_symmetry<Color, Traits, domain>(C, sd, vp, vpd, ob, me, brush, i, 'Z'); | C, sd, vp, vpd, ob, me, brush, initial_symm, 'X'); | ||||
| vpaint_do_radial_symmetry<Color, Traits, domain>( | |||||
| C, sd, vp, vpd, ob, me, brush, initial_symm, 'Y'); | |||||
| vpaint_do_radial_symmetry<Color, Traits, domain>( | |||||
| C, sd, vp, vpd, ob, me, brush, initial_symm, 'Z'); | |||||
| cache->symmetry = symm; | cache->symmetry = symm; | ||||
| /* symm is a bit combination of XYZ - 1 is mirror | /* symm is a bit combination of XYZ - 1 is mirror | ||||
| * X; 2 is Y; 3 is XY; 4 is Z; 5 is XZ; 6 is YZ; 7 is XYZ */ | * X; 2 is Y; 3 is XY; 4 is Z; 5 is XZ; 6 is YZ; 7 is XYZ */ | ||||
| for (i = 1; i <= symm; i++) { | for (i = 1; i <= symm; i++) { | ||||
| if (symm & i && (symm != 5 || i != 3) && (symm != 6 || !ELEM(i, 3, 5))) { | if (symm & i && (symm != 5 || i != 3) && (symm != 6 || !ELEM(i, 3, 5))) { | ||||
| cache->mirror_symmetry_pass = i; | const ePaintSymmetryFlags symm_pass = ePaintSymmetryFlags(i); | ||||
| cache->mirror_symmetry_pass = symm_pass; | |||||
| cache->radial_symmetry_pass = 0; | cache->radial_symmetry_pass = 0; | ||||
| SCULPT_cache_calc_brushdata_symm(cache, i, 0, 0); | SCULPT_cache_calc_brushdata_symm(cache, symm_pass, 0, 0); | ||||
| if (i & (1 << 0)) { | if (i & (1 << 0)) { | ||||
| vpaint_do_paint<Color, Traits, domain>(C, sd, vp, vpd, ob, me, brush, i, 'X', 0, 0); | vpaint_do_paint<Color, Traits, domain>( | ||||
| vpaint_do_radial_symmetry<Color, Traits, domain>(C, sd, vp, vpd, ob, me, brush, i, 'X'); | C, sd, vp, vpd, ob, me, brush, symm_pass, 'X', 0, 0); | ||||
| vpaint_do_radial_symmetry<Color, Traits, domain>( | |||||
| C, sd, vp, vpd, ob, me, brush, symm_pass, 'X'); | |||||
| } | } | ||||
| if (i & (1 << 1)) { | if (i & (1 << 1)) { | ||||
| vpaint_do_paint<Color, Traits, domain>(C, sd, vp, vpd, ob, me, brush, i, 'Y', 0, 0); | vpaint_do_paint<Color, Traits, domain>( | ||||
| vpaint_do_radial_symmetry<Color, Traits, domain>(C, sd, vp, vpd, ob, me, brush, i, 'Y'); | C, sd, vp, vpd, ob, me, brush, symm_pass, 'Y', 0, 0); | ||||
| vpaint_do_radial_symmetry<Color, Traits, domain>( | |||||
| C, sd, vp, vpd, ob, me, brush, symm_pass, 'Y'); | |||||
| } | } | ||||
| if (i & (1 << 2)) { | if (i & (1 << 2)) { | ||||
| vpaint_do_paint<Color, Traits, domain>(C, sd, vp, vpd, ob, me, brush, i, 'Z', 0, 0); | vpaint_do_paint<Color, Traits, domain>( | ||||
| vpaint_do_radial_symmetry<Color, Traits, domain>(C, sd, vp, vpd, ob, me, brush, i, 'Z'); | C, sd, vp, vpd, ob, me, brush, symm_pass, 'Z', 0, 0); | ||||
| vpaint_do_radial_symmetry<Color, Traits, domain>( | |||||
| C, sd, vp, vpd, ob, me, brush, symm_pass, 'Z'); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| copy_v3_v3(cache->true_last_location, cache->true_location); | copy_v3_v3(cache->true_last_location, cache->true_location); | ||||
| cache->is_last_valid = true; | cache->is_last_valid = true; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 411 Lines • Show Last 20 Lines | |||||