Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/sculpt_paint/sculpt.c
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
| Show First 20 Lines • Show All 7,076 Lines • ▼ Show 20 Lines | static void sculpt_brush_init_tex(const Scene *scene, Sculpt *sd, SculptSession *ss) | ||||
| /* TODO: Shouldn't really have to do this at the start of every stroke, but sculpt would need | /* TODO: Shouldn't really have to do this at the start of every stroke, but sculpt would need | ||||
| * some sort of notification when changes are made to the texture. */ | * some sort of notification when changes are made to the texture. */ | ||||
| sculpt_update_tex(scene, sd, ss); | sculpt_update_tex(scene, sd, ss); | ||||
| } | } | ||||
| static void sculpt_brush_stroke_init(bContext *C, wmOperator *op) | static void sculpt_brush_stroke_init(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); | |||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| Object *ob = CTX_data_active_object(C); | Object *ob = CTX_data_active_object(C); | ||||
| Sculpt *sd = CTX_data_tool_settings(C)->sculpt; | Sculpt *sd = CTX_data_tool_settings(C)->sculpt; | ||||
| SculptSession *ss = CTX_data_active_object(C)->sculpt; | SculptSession *ss = CTX_data_active_object(C)->sculpt; | ||||
| Brush *brush = BKE_paint_brush(&sd->paint); | Brush *brush = BKE_paint_brush(&sd->paint); | ||||
| int mode = RNA_enum_get(op->ptr, "mode"); | int mode = RNA_enum_get(op->ptr, "mode"); | ||||
| bool is_smooth, needs_colors; | bool is_smooth, needs_colors; | ||||
| bool need_mask = false; | bool need_mask = false; | ||||
| if (brush->sculpt_tool == SCULPT_TOOL_MASK) { | if (brush->sculpt_tool == SCULPT_TOOL_MASK) { | ||||
| need_mask = true; | need_mask = true; | ||||
| } | } | ||||
| if (brush->sculpt_tool == SCULPT_TOOL_CLOTH) { | if (brush->sculpt_tool == SCULPT_TOOL_CLOTH) { | ||||
| need_mask = true; | need_mask = true; | ||||
| } | } | ||||
| view3d_operator_needs_opengl(C); | view3d_operator_needs_opengl(C); | ||||
| sculpt_brush_init_tex(scene, sd, ss); | sculpt_brush_init_tex(scene, sd, ss); | ||||
| is_smooth = sculpt_needs_connectivity_info(sd, brush, ss, mode); | is_smooth = sculpt_needs_connectivity_info(sd, brush, ss, mode); | ||||
| needs_colors = ELEM(brush->sculpt_tool, SCULPT_TOOL_PAINT, SCULPT_TOOL_SMEAR); | needs_colors = ELEM(brush->sculpt_tool, SCULPT_TOOL_PAINT, SCULPT_TOOL_SMEAR); | ||||
| if (needs_colors) { | |||||
| BKE_sculpt_color_layer_create_if_needed(ob); | |||||
| } | |||||
| /* CTX_data_ensure_evaluated_depsgraph should be used at the end to include the updates of | |||||
sergey: Add a note that `CTX_data_ensure_evaluated_depsgraph` is only to be used at the end to prop… | |||||
| * earlier steps modifying the data. */ | |||||
| Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); | |||||
| BKE_sculpt_update_object_for_edit(depsgraph, ob, is_smooth, need_mask, needs_colors); | BKE_sculpt_update_object_for_edit(depsgraph, ob, is_smooth, need_mask, needs_colors); | ||||
| } | } | ||||
| static void sculpt_restore_mesh(Sculpt *sd, Object *ob) | static void sculpt_restore_mesh(Sculpt *sd, Object *ob) | ||||
| { | { | ||||
| SculptSession *ss = ob->sculpt; | SculptSession *ss = ob->sculpt; | ||||
| Brush *brush = BKE_paint_brush(&sd->paint); | Brush *brush = BKE_paint_brush(&sd->paint); | ||||
| ▲ Show 20 Lines • Show All 1,776 Lines • Show Last 20 Lines | |||||
Add a note that CTX_data_ensure_evaluated_depsgraph is only to be used at the end to prop;erly update with possible earlier steps modifying original data.