diff options
author | Pablo Dobarro <pablodp606@gmail.com> | 2019-09-09 23:23:54 +0300 |
---|---|---|
committer | Pablo Dobarro <pablodp606@gmail.com> | 2019-09-10 17:24:09 +0300 |
commit | a3e7440cfdd2f307e5c57922fd22e8770f0b8390 (patch) | |
tree | 4216a9c54084fd849dd5ed552627940c67bd652a /source/blender/editors/sculpt_paint/paint_cursor.c | |
parent | e0f7ada0d2b07870820590d1b839ad7604ae1709 (diff) |
Sculpt: Grab Active Vertex and Dynamic Mesh Preview
Grab active vertex snaps the maximum strength of the grab brush to the highlighted active vertex, making it easier to manipulate low poly models or meshes with subdivision surfaces.
Dynamic Mesh Preview generates a list of connected vertices from the active vertex and draws them from the cursor code. This helps to visualize the real geometry the user is manipulating from sculpt mode when there are active modifiers.
Reviewed By: brecht
Differential Revision: https://developer.blender.org/D5646
Diffstat (limited to 'source/blender/editors/sculpt_paint/paint_cursor.c')
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_cursor.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c index a000da57383..62e44bf04c5 100644 --- a/source/blender/editors/sculpt_paint/paint_cursor.c +++ b/source/blender/editors/sculpt_paint/paint_cursor.c @@ -1180,6 +1180,20 @@ static void cursor_draw_point_with_symmetry(const uint gpuattr, } } +static void sculpt_geometry_preview_lines_draw(const uint gpuattr, SculptSession *ss) +{ + immUniformColor4f(1.0f, 1.0f, 1.0f, 0.6f); + GPU_depth_test(true); + GPU_line_width(1.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++) { + immVertex3fv(gpuattr, sculpt_vertex_co_get(ss, ss->preview_vert_index_list[i])); + } + immEnd(); + } +} + static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused)) { Scene *scene = CTX_data_scene(C); @@ -1348,6 +1362,17 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused)) imm_draw_circle_wire_3d(pos, 0, 0, rds, 40); GPU_matrix_pop(); + /* Update and draw dynamic mesh preview lines */ + GPU_matrix_push(); + GPU_matrix_mul(vc.obact->obmat); + if (brush->sculpt_tool == SCULPT_TOOL_GRAB && brush->flag2 & BRUSH_GRAB_ACTIVE_VERTEX) { + if (BKE_pbvh_type(ss->pbvh) == PBVH_FACES && ss->modifiers_active) { + sculpt_geometry_preview_lines_update(C, ss, rds); + sculpt_geometry_preview_lines_draw(pos, ss); + } + } + GPU_matrix_pop(); + GPU_matrix_pop_projection(); wmWindowViewport(win); @@ -1370,6 +1395,27 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused)) add_v3_v3(cursor_location, ss->cache->grab_delta); } cursor_draw_point_with_symmetry(pos, ar, cursor_location, sd, vc.obact, ss->cache->radius); + + /* Draw cached dynamic mesh preview lines */ + if (brush->sculpt_tool == SCULPT_TOOL_GRAB && brush->flag2 & BRUSH_GRAB_ACTIVE_VERTEX) { + if (BKE_pbvh_type(ss->pbvh) == PBVH_FACES && ss->modifiers_active) { + GPU_matrix_push_projection(); + ED_view3d_draw_setup_view(CTX_wm_window(C), + CTX_data_depsgraph_pointer(C), + CTX_data_scene(C), + ar, + CTX_wm_view3d(C), + NULL, + NULL, + NULL); + GPU_matrix_push(); + GPU_matrix_mul(vc.obact->obmat); + sculpt_geometry_preview_lines_draw(pos, ss); + GPU_matrix_pop(); + GPU_matrix_pop_projection(); + } + } + wmWindowViewport(win); } } |