diff options
Diffstat (limited to 'source/blender/editors/sculpt_paint/paint_cursor.c')
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_cursor.c | 43 |
1 files changed, 35 insertions, 8 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c index c8c857d721b..a41ff09e514 100644 --- a/source/blender/editors/sculpt_paint/paint_cursor.c +++ b/source/blender/editors/sculpt_paint/paint_cursor.c @@ -1093,17 +1093,15 @@ static bool ommit_cursor_drawing(Paint *paint, ePaintMode mode, Brush *brush) return true; } -static void cursor_draw_point_screen_space(const uint gpuattr, - const ARegion *ar, - const float true_location[3], - const float obmat[4][4]) +static void cursor_draw_point_screen_space( + const uint gpuattr, const ARegion *ar, float true_location[3], float obmat[4][4], int size) { float translation_vertex_cursor[3], location[3]; copy_v3_v3(location, true_location); mul_m4_v3(obmat, location); ED_view3d_project(ar, location, translation_vertex_cursor); imm_draw_circle_fill_3d( - gpuattr, translation_vertex_cursor[0], translation_vertex_cursor[1], 3, 10); + gpuattr, translation_vertex_cursor[0], translation_vertex_cursor[1], size, 10); } static void cursor_draw_tiling_preview(const uint gpuattr, @@ -1145,7 +1143,7 @@ static void cursor_draw_tiling_preview(const uint gpuattr, for (dim = 0; dim < 3; dim++) { location[dim] = cur[dim] * step[dim] + orgLoc[dim]; } - cursor_draw_point_screen_space(gpuattr, ar, location, ob->obmat); + cursor_draw_point_screen_space(gpuattr, ar, location, ob->obmat, 3); } } } @@ -1166,7 +1164,7 @@ static void cursor_draw_point_with_symmetry(const uint gpuattr, /* Axis Symmetry */ flip_v3_v3(location, true_location, (char)i); - cursor_draw_point_screen_space(gpuattr, ar, location, ob->obmat); + cursor_draw_point_screen_space(gpuattr, ar, location, ob->obmat, 3); /* Tiling */ cursor_draw_tiling_preview(gpuattr, ar, location, sd, ob, radius); @@ -1181,7 +1179,7 @@ static void cursor_draw_point_with_symmetry(const uint gpuattr, mul_m4_v3(symm_rot_mat, location); cursor_draw_tiling_preview(gpuattr, ar, location, sd, ob, radius); - cursor_draw_point_screen_space(gpuattr, ar, location, ob->obmat); + cursor_draw_point_screen_space(gpuattr, ar, location, ob->obmat, 3); } } } @@ -1215,6 +1213,7 @@ static void sculpt_geometry_preview_lines_draw(const uint gpuattr, SculptSession static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused)) { + Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); Scene *scene = CTX_data_scene(C); ARegion *ar = CTX_wm_region(C); UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings; @@ -1338,8 +1337,14 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused)) if (!ups->stroke_active) { SculptCursorGeometryInfo gi; float mouse[2] = {x - ar->winrct.xmin, y - ar->winrct.ymin}; + int prev_active_vertex_index = ss->active_vertex_index; + bool update_previews = false; if (sculpt_cursor_geometry_info_update(C, &gi, mouse, true) && !alpha_overlay_active) { + if (prev_active_vertex_index != ss->active_vertex_index) { + update_previews = true; + } + float rds; if (!BKE_brush_use_locked_size(scene, brush)) { rds = paint_calc_object_space_radius(&vc, gi.location, BKE_brush_size_get(scene, brush)); @@ -1355,6 +1360,16 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused)) cursor_draw_point_with_symmetry(pos, ar, gi.active_vertex_co, sd, vc.obact, rds); } + /* Draw pose brush origin */ + if (brush->sculpt_tool == SCULPT_TOOL_POSE && !is_multires) { + immUniformColor4f(1.0f, 1.0f, 1.0f, 0.8f); + if (update_previews) { + BKE_sculpt_update_object_for_edit(depsgraph, vc.obact, true, false); + sculpt_pose_calc_pose_data(sd, vc.obact, ss, gi.location, rds, ss->pose_origin, NULL); + } + cursor_draw_point_screen_space(pos, ar, ss->pose_origin, vc.obact->obmat, 5); + } + /* Draw 3D brush cursor */ GPU_matrix_push_projection(); ED_view3d_draw_setup_view(CTX_wm_window(C), @@ -1378,6 +1393,7 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused)) GPU_matrix_push(); GPU_matrix_mul(cursor_trans); GPU_matrix_mul(cursor_rot); + immUniformColor3fvAlpha(outline_col, outline_alpha); imm_draw_circle_wire_3d(pos, 0, 0, rds, 40); GPU_matrix_pop(); @@ -1390,6 +1406,17 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused)) sculpt_geometry_preview_lines_draw(pos, ss); } } + + /* Draw pose brush line preview */ + if (brush->sculpt_tool == SCULPT_TOOL_POSE && !is_multires) { + immUniformColor4f(1.0f, 1.0f, 1.0f, 0.8f); + GPU_line_width(2.0f); + immBegin(GPU_PRIM_LINES, 2); + immVertex3fv(pos, ss->pose_origin); + immVertex3fv(pos, gi.location); + immEnd(); + } + GPU_matrix_pop(); GPU_matrix_pop_projection(); |