Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/sculpt_paint/paint_cursor.c
| Show First 20 Lines • Show All 1,318 Lines • ▼ Show 20 Lines | static bool paint_cursor_context_init(bContext *C, | ||||
| Object *active_object = pcontext->vc.obact; | Object *active_object = pcontext->vc.obact; | ||||
| pcontext->ss = active_object ? active_object->sculpt : NULL; | pcontext->ss = active_object ? active_object->sculpt : NULL; | ||||
| if (pcontext->ss && pcontext->ss->draw_faded_cursor) { | if (pcontext->ss && pcontext->ss->draw_faded_cursor) { | ||||
| pcontext->outline_alpha = 0.3f; | pcontext->outline_alpha = 0.3f; | ||||
| copy_v3_fl(pcontext->outline_col, 0.8f); | copy_v3_fl(pcontext->outline_col, 0.8f); | ||||
| } | } | ||||
| const bool is_brush_tool = PAINT_brush_tool_poll(C); | |||||
| if (!is_brush_tool) { | |||||
| /* Use a default color for tools that are not brushes. */ | |||||
| pcontext->outline_alpha = 0.8f; | |||||
| copy_v3_fl(pcontext->outline_col, 0.8f); | |||||
| } | |||||
| pcontext->is_stroke_active = pcontext->ups->stroke_active; | pcontext->is_stroke_active = pcontext->ups->stroke_active; | ||||
| return true; | return true; | ||||
| } | } | ||||
| static void paint_cursor_update_pixel_radius(PaintCursorContext *pcontext) | static void paint_cursor_update_pixel_radius(PaintCursorContext *pcontext) | ||||
| { | { | ||||
| if (pcontext->is_cursor_over_mesh) { | if (pcontext->is_cursor_over_mesh) { | ||||
| ▲ Show 20 Lines • Show All 270 Lines • ▼ Show 20 Lines | if (len_v3v3(active_vertex_co, pcontext->location) < pcontext->radius) { | ||||
| cursor_draw_point_with_symmetry(pcontext->pos, | cursor_draw_point_with_symmetry(pcontext->pos, | ||||
| pcontext->region, | pcontext->region, | ||||
| active_vertex_co, | active_vertex_co, | ||||
| pcontext->sd, | pcontext->sd, | ||||
| pcontext->vc.obact, | pcontext->vc.obact, | ||||
| pcontext->radius); | pcontext->radius); | ||||
| } | } | ||||
| const bool is_brush_tool = PAINT_brush_tool_poll(pcontext->C); | |||||
| /* Pose brush updates and rotation origins. */ | /* Pose brush updates and rotation origins. */ | ||||
| if (brush->sculpt_tool == SCULPT_TOOL_POSE) { | if (is_brush_tool && brush->sculpt_tool == SCULPT_TOOL_POSE) { | ||||
| /* Just after switching to the Pose Brush, the active vertex can be the same and the | /* Just after switching to the Pose Brush, the active vertex can be the same and the | ||||
| * cursor won't be tagged to update, so always initialize the preview chain if it is | * cursor won't be tagged to update, so always initialize the preview chain if it is | ||||
| * null before drawing it. */ | * null before drawing it. */ | ||||
| SculptSession *ss = pcontext->ss; | SculptSession *ss = pcontext->ss; | ||||
| if (update_previews || !ss->pose_ik_chain_preview) { | if (update_previews || !ss->pose_ik_chain_preview) { | ||||
| BKE_sculpt_update_object_for_edit( | BKE_sculpt_update_object_for_edit( | ||||
| pcontext->depsgraph, pcontext->vc.obact, true, false, false); | pcontext->depsgraph, pcontext->vc.obact, true, false, false); | ||||
| Show All 16 Lines | if (pcontext->ss->expand_cache) { | ||||
| cursor_draw_point_screen_space( | cursor_draw_point_screen_space( | ||||
| pcontext->pos, | pcontext->pos, | ||||
| pcontext->region, | pcontext->region, | ||||
| SCULPT_vertex_co_get(pcontext->ss, pcontext->ss->expand_cache->initial_active_vertex), | SCULPT_vertex_co_get(pcontext->ss, pcontext->ss->expand_cache->initial_active_vertex), | ||||
| pcontext->vc.obact->obmat, | pcontext->vc.obact->obmat, | ||||
| 2); | 2); | ||||
| } | } | ||||
| if (brush->sculpt_tool == SCULPT_TOOL_BOUNDARY) { | if (is_brush_tool && brush->sculpt_tool == SCULPT_TOOL_BOUNDARY) { | ||||
| paint_cursor_preview_boundary_data_update(pcontext, update_previews); | paint_cursor_preview_boundary_data_update(pcontext, update_previews); | ||||
| paint_cursor_preview_boundary_data_pivot_draw(pcontext); | paint_cursor_preview_boundary_data_pivot_draw(pcontext); | ||||
| } | } | ||||
| /* Setup 3D perspective drawing. */ | /* Setup 3D perspective drawing. */ | ||||
| GPU_matrix_push_projection(); | GPU_matrix_push_projection(); | ||||
| ED_view3d_draw_setup_view(pcontext->wm, | ED_view3d_draw_setup_view(pcontext->wm, | ||||
| pcontext->win, | pcontext->win, | ||||
| pcontext->depsgraph, | pcontext->depsgraph, | ||||
| pcontext->scene, | pcontext->scene, | ||||
| pcontext->region, | pcontext->region, | ||||
| CTX_wm_view3d(pcontext->C), | CTX_wm_view3d(pcontext->C), | ||||
| NULL, | NULL, | ||||
| NULL, | NULL, | ||||
| NULL); | NULL); | ||||
| GPU_matrix_push(); | GPU_matrix_push(); | ||||
| GPU_matrix_mul(pcontext->vc.obact->obmat); | GPU_matrix_mul(pcontext->vc.obact->obmat); | ||||
| /* Drawing Cursor overlays in 3D object space. */ | /* Drawing Cursor overlays in 3D object space. */ | ||||
| if (brush->sculpt_tool == SCULPT_TOOL_GRAB && (brush->flag & BRUSH_GRAB_ACTIVE_VERTEX)) { | if (is_brush_tool && brush->sculpt_tool == SCULPT_TOOL_GRAB && (brush->flag & BRUSH_GRAB_ACTIVE_VERTEX)) { | ||||
| SCULPT_geometry_preview_lines_update(pcontext->C, pcontext->ss, pcontext->radius); | SCULPT_geometry_preview_lines_update(pcontext->C, pcontext->ss, pcontext->radius); | ||||
| sculpt_geometry_preview_lines_draw( | sculpt_geometry_preview_lines_draw( | ||||
| pcontext->pos, pcontext->brush, pcontext->is_multires, pcontext->ss); | pcontext->pos, pcontext->brush, pcontext->is_multires, pcontext->ss); | ||||
| } | } | ||||
| if (brush->sculpt_tool == SCULPT_TOOL_POSE) { | if (is_brush_tool && brush->sculpt_tool == SCULPT_TOOL_POSE) { | ||||
| paint_cursor_pose_brush_segments_draw(pcontext); | paint_cursor_pose_brush_segments_draw(pcontext); | ||||
| } | } | ||||
| if (brush->sculpt_tool == SCULPT_TOOL_BOUNDARY) { | if (is_brush_tool && brush->sculpt_tool == SCULPT_TOOL_BOUNDARY) { | ||||
| SCULPT_boundary_edges_preview_draw( | SCULPT_boundary_edges_preview_draw( | ||||
| pcontext->pos, pcontext->ss, pcontext->outline_col, pcontext->outline_alpha); | pcontext->pos, pcontext->ss, pcontext->outline_col, pcontext->outline_alpha); | ||||
| SCULPT_boundary_pivot_line_preview_draw(pcontext->pos, pcontext->ss); | SCULPT_boundary_pivot_line_preview_draw(pcontext->pos, pcontext->ss); | ||||
| } | } | ||||
| GPU_matrix_pop(); | GPU_matrix_pop(); | ||||
| /* Drawing Cursor overlays in Paint Cursor space (as additional info on top of the brush cursor) | /* Drawing Cursor overlays in Paint Cursor space (as additional info on top of the brush cursor) | ||||
| */ | */ | ||||
| GPU_matrix_push(); | GPU_matrix_push(); | ||||
| paint_cursor_drawing_setup_cursor_space(pcontext); | paint_cursor_drawing_setup_cursor_space(pcontext); | ||||
| /* Main inactive cursor. */ | /* Main inactive cursor. */ | ||||
| paint_cursor_draw_main_inactive_cursor(pcontext); | paint_cursor_draw_main_inactive_cursor(pcontext); | ||||
| /* Cloth brush local simulation areas. */ | /* Cloth brush local simulation areas. */ | ||||
| if (brush->sculpt_tool == SCULPT_TOOL_CLOTH && | if (is_brush_tool && brush->sculpt_tool == SCULPT_TOOL_CLOTH && | ||||
| brush->cloth_simulation_area_type != BRUSH_CLOTH_SIMULATION_AREA_GLOBAL) { | brush->cloth_simulation_area_type != BRUSH_CLOTH_SIMULATION_AREA_GLOBAL) { | ||||
| const float white[3] = {1.0f, 1.0f, 1.0f}; | const float white[3] = {1.0f, 1.0f, 1.0f}; | ||||
| const float zero_v[3] = {0.0f}; | const float zero_v[3] = {0.0f}; | ||||
| /* This functions sets its own drawing space in order to draw the simulation limits when the | /* This functions sets its own drawing space in order to draw the simulation limits when the | ||||
| * cursor is active. When used here, this cursor overlay is already in cursor space, so its | * cursor is active. When used here, this cursor overlay is already in cursor space, so its | ||||
| * position and normal should be set to 0. */ | * position and normal should be set to 0. */ | ||||
| SCULPT_cloth_simulation_limits_draw( | SCULPT_cloth_simulation_limits_draw( | ||||
| pcontext->pos, brush, zero_v, zero_v, pcontext->radius, 1.0f, white, 0.25f); | pcontext->pos, brush, zero_v, zero_v, pcontext->radius, 1.0f, white, 0.25f); | ||||
| } | } | ||||
| /* Layer brush height. */ | /* Layer brush height. */ | ||||
| if (brush->sculpt_tool == SCULPT_TOOL_LAYER) { | if (is_brush_tool && brush->sculpt_tool == SCULPT_TOOL_LAYER) { | ||||
| SCULPT_layer_brush_height_preview_draw(pcontext->pos, | SCULPT_layer_brush_height_preview_draw(pcontext->pos, | ||||
| brush, | brush, | ||||
| pcontext->radius, | pcontext->radius, | ||||
| 1.0f, | 1.0f, | ||||
| pcontext->outline_col, | pcontext->outline_col, | ||||
| pcontext->outline_alpha); | pcontext->outline_alpha); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 234 Lines • Show Last 20 Lines | |||||