Commit: 12dca31682cee168a96eb006865d20902be62966 Author: Pablo Dobarro Date: Mon Aug 12 03:35:13 2019 +0200 Branches: sculpt-mode-features https://developer.blender.org/rB12dca31682cee168a96eb006865d20902be62966
Grab active vertex and dynamic mesh preview =================================================================== M release/scripts/startup/bl_ui/space_view3d_toolbar.py M source/blender/blenkernel/BKE_paint.h M source/blender/editors/sculpt_paint/paint_cursor.c M source/blender/editors/sculpt_paint/paint_vertex.c M source/blender/editors/sculpt_paint/sculpt.c M source/blender/editors/sculpt_paint/sculpt_intern.h M source/blender/makesdna/DNA_brush_types.h M source/blender/makesrna/intern/rna_brush.c =================================================================== diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py index f644ba8d516..71a0a5925ce 100644 --- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py +++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py @@ -332,6 +332,11 @@ class VIEW3D_PT_tools_brush(Panel, View3DPaintPanel): row = col.row() row.prop(brush, "sculpt_color_mix_mode") + if brush.sculpt_tool == 'GRAB': + col.separator() + row = col.row() + row.prop(brush, "grab_active_vertex") + # topology_rake_factor if ( capabilities.has_topology_rake and diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h index caa4570cd5e..54cd51b3bff 100644 --- a/source/blender/blenkernel/BKE_paint.h +++ b/source/blender/blenkernel/BKE_paint.h @@ -283,6 +283,9 @@ typedef struct SculptSession { RegionView3D *rv3d; + int *preview_vert_index_list; + int preview_vert_index_count; + union { struct { struct SculptVertexPaintGeomMap gmap; diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c index 8a834446326..480b180ccc3 100644 --- a/source/blender/editors/sculpt_paint/paint_cursor.c +++ b/source/blender/editors/sculpt_paint/paint_cursor.c @@ -1188,6 +1188,24 @@ void cursor_draw_point_with_symmetry(const uint gpuattr, } } +static void sculpt_geometry_preview_lines_draw(const uint gpuattr, + SculptSession *ss, + float obmat[4][4]) +{ + immUniformColor4f(1.0f, 1.0f, 1.0f, 0.7f); + GPU_depth_test(true); + GPU_line_width(2.0f); + if (ss->preview_vert_index_count > 0) { + immBegin(GPU_PRIM_LINES, ss->preview_vert_index_count); + for (int i = 0; i < ss->preview_vert_index_count; i++) { + float v[3]; + mul_v3_m4v3(v, obmat, sculpt_vertex_co_get(ss, ss->preview_vert_index_list[i])); + immVertex3fv(gpuattr, v); + } + immEnd(); + } +} + static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused)) { Scene *scene = CTX_data_scene(C); @@ -1326,6 +1344,16 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused)) } /* draw brush cursor */ + + float cursor_mat4[4][4], cursor_rot_mat4[4][4]; + float z_axis[4] = {0.0f, 0.0f, 1.0f, 0.0f}; + float quat[4]; + + copy_m4_m4(cursor_mat4, vc.obact->obmat); + translate_m4(cursor_mat4, gi.location[0], gi.location[1], gi.location[2]); + rotation_between_vecs_to_quat(quat, z_axis, gi.normal); + quat_to_mat4(cursor_rot_mat4, quat); + GPU_matrix_push_projection(); GPU_matrix_push(); ED_view3d_draw_setup_view(CTX_wm_window(C), @@ -1337,20 +1365,24 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused)) NULL, NULL); - float cursor_mat4[4][4], cursor_rot_mat4[4][4]; - float z_axis[4] = {0.0f, 0.0f, 1.0f, 0.0f}; - float quat[4]; + if (brush->sculpt_tool == SCULPT_TOOL_GRAB && brush->flag2 & BRUSH_GRAB_ACTIVE_VERTEX) { + if (vc.obact->sculpt) { + SculptSession *ss = vc.obact->sculpt; + if (BKE_pbvh_type(ss->pbvh) == PBVH_FACES) { + sculpt_geometry_preview_lines_update(C, ss, rds); + sculpt_geometry_preview_lines_draw(pos3d, ss, vc.obact->obmat); + } + } + } - copy_m4_m4(cursor_mat4, vc.obact->obmat); - translate_m4(cursor_mat4, gi.location[0], gi.location[1], gi.location[2]); - rotation_between_vecs_to_quat(quat, z_axis, gi.normal); - quat_to_mat4(cursor_rot_mat4, quat); + GPU_line_width(4.0f); GPU_matrix_mul(cursor_mat4); GPU_matrix_mul(cursor_rot_mat4); + immUniformColor3fvAlpha(outline_col, outline_alpha); imm_draw_circle_wire_3d(pos3d, 0, 0, rds, 40); - GPU_matrix_pop(); GPU_matrix_pop_projection(); + wmWindowViewport(win); } else { @@ -1369,6 +1401,24 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused)) } cursor_draw_point_with_symmetry( pos3d, ar, cursor_location, sd, vc.obact, vc.rv3d->persmat, ss->cache->radius); + + if (ss->cache->brush->sculpt_tool == SCULPT_TOOL_GRAB) { + if (brush->flag2 & BRUSH_GRAB_ACTIVE_VERTEX && BKE_pbvh_type(ss->pbvh) == PBVH_FACES) { + GPU_matrix_push_projection(); + GPU_matrix_push(); + ED_view3d_draw_setup_view(CTX_wm_window(C), + CTX_data_depsgraph(C), + CTX_data_scene(C), + ar, + CTX_wm_view3d(C), + NULL, + NULL, + NULL); + sculpt_geometry_preview_lines_draw(pos3d, ss, vc.obact->obmat); + GPU_matrix_pop(); + GPU_matrix_pop_projection(); + } + } wmWindowViewport(win); } } diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index d5e8c2a1825..6d6949b68ee 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -2210,7 +2210,7 @@ static void wpaint_do_paint(bContext *C, { SculptSession *ss = ob->sculpt; ss->cache->radial_symmetry_pass = i; - sculpt_cache_calc_brushdata_symm(ss->cache, symm, axis, angle); + sculpt_cache_calc_brushdata_symm(ss, symm, axis, angle); int totnode; PBVHNode **nodes = vwpaint_pbvh_gather_generic(ob, wp, sd, brush, &totnode); @@ -2265,7 +2265,7 @@ static void wpaint_do_symmetrical_brush_actions( if ((symm & i && (symm != 5 || i != 3) && (symm != 6 || (i != 3 && i != 5)))) { cache->mirror_symmetry_pass = i; cache->radial_symmetry_pass = 0; - sculpt_cache_calc_brushdata_symm(cache, i, 0, 0); + sculpt_cache_calc_brushdata_symm(ss, i, 0, 0); if (i & (1 << 0)) { wpaint_do_paint(C, ob, wp, sd, wpd, wpi, me, brush, i, 'X', 0, 0); @@ -3220,7 +3220,7 @@ static void vpaint_do_paint(bContext *C, { SculptSession *ss = ob->sculpt; ss->cache->radial_symmetry_pass = i; - sculpt_cache_calc_brushdata_symm(ss->cache, symm, axis, angle); + sculpt_cache_calc_brushdata_symm(ss, symm, axis, angle); int totnode; PBVHNode **nodes = vwpaint_pbvh_gather_generic(ob, vp, sd, brush, &totnode); @@ -3275,7 +3275,7 @@ static void vpaint_do_symmetrical_brush_actions( if (symm & i && (symm != 5 || i != 3) && (symm != 6 || (i != 3 && i != 5))) { cache->mirror_symmetry_pass = i; cache->radial_symmetry_pass = 0; - sculpt_cache_calc_brushdata_symm(cache, i, 0, 0); + sculpt_cache_calc_brushdata_symm(ss, i, 0, 0); if (i & (1 << 0)) { vpaint_do_paint(C, sd, vp, vpd, ob, me, brush, i, 'X', 0, 0); diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index ce195373f28..6803f01a26c 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -282,10 +282,8 @@ void sculpt_vertex_neighbours_get_faces(SculptSession *ss, if (poly_get_adj_loops_from_vert(p, ss->mloop, (int)index, f_adj_v) != -1) { int j; for (j = 0; j < ARRAY_SIZE(f_adj_v); j += 1) { - if (vert_map->count != 2 || ss->pmap[f_adj_v[j]].count <= 2) { - if (f_adj_v[j] != (int)index) { - sculpt_vertex_neighbour_add(iter, f_adj_v[j]); - } + if (f_adj_v[j] != (int)index) { + sculpt_vertex_neighbour_add(iter, f_adj_v[j]); } } } @@ -5045,6 +5043,7 @@ static float *sculpt_topology_automasking_init(Sculpt *sd, Object *ob, int initi vertex_topology_it mevit; mevit.v = initial_vertex_index; mevit.it = 1; + automask_factor[initial_vertex_index] = 1.0f; BLI_gsqueue_push(queue, &mevit); while (!BLI_gsqueue_is_empty(queue)) { @@ -5498,11 +5497,12 @@ static void sculpt_flush_stroke_deform(Sculpt *sd, Object *ob) /* Flip all the editdata across the axis/axes specified by symm. Used to * calculate multiple modifications to the mesh when symmetry is enabled. */ -void sculpt_cache_calc_brushdata_symm(StrokeCache *cache, +void sculpt_cache_calc_brushdata_symm(SculptSession *ss, const char symm, const char axis, const float angle) { + StrokeCache *cache = ss->cache; flip_v3_v3(cache->location, cache->true_location, symm); flip_v3_v3(cache->last_location, cache->true_last_location, symm); flip_v3_v3(cache->grab_delta_symmetry, cache->grab_delta, symm); @@ -5618,7 +5618,7 @@ static void do_radial_symmetry(Sculpt *sd, for (i = 1; i < sd->radial_symm[axis - 'X']; ++i) { const float angle = 2 * M_PI * i / sd->radial_symm[axis - 'X']; ss->cache->radial_symmetry_pass = i; - sculpt_cache_calc_brushdata_symm(ss->cache, symm, axis, angle); + sculpt_cache_calc_brushdata_symm(ss, symm, axis, angle); do_tiled(sd, ob, brush, ups, action); } } @@ -5660,7 +5660,7 @@ static void do_symmetrical_brush_actions(Sculpt *sd, cache->mirror_symmetry_pass = i; cache->radial_symmetry_pass = 0; - sculpt_cache_calc_brushdata_symm(cache, i, 0, 0); + sculpt_cache_calc_brushdata_symm(ss, i, 0, 0); do_tiled(sd, ob, brush, ups, action); do_radial_symmetry(sd, ob, brush, ups, action, i, 'X', feather); @@ -6026,7 +6026,14 @@ static void sculpt_update_brush_delta(UnifiedPaintSettings *ups, Object *ob, Bru float grab_location[3], imat[4][4], delta[3], loc[3]; if (cache->first_time) { - copy_v3_v3(cache->orig_grab_location, cache->true_location); + if (tool @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs