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,692 Lines • ▼ Show 20 Lines | if (((op->flag & OP_IS_INVOKE) == 0) || (mouse == NULL) || | ||||
| Object *ob = CTX_data_active_object(C); | Object *ob = CTX_data_active_object(C); | ||||
| SculptSession *ss = ob->sculpt; | SculptSession *ss = ob->sculpt; | ||||
| Sculpt *sd = CTX_data_tool_settings(C)->sculpt; | Sculpt *sd = CTX_data_tool_settings(C)->sculpt; | ||||
| ED_view3d_init_mats_rv3d(ob, CTX_wm_region_view3d(C)); | ED_view3d_init_mats_rv3d(ob, CTX_wm_region_view3d(C)); | ||||
| sculpt_update_cache_invariants(C, sd, ss, op, mouse); | sculpt_update_cache_invariants(C, sd, ss, op, mouse); | ||||
| SCULPT_undo_push_begin(sculpt_tool_name(sd)); | SCULPT_undo_push_begin(ob, sculpt_tool_name(sd)); | ||||
| return true; | return true; | ||||
| } | } | ||||
| return false; | return false; | ||||
| } | } | ||||
| static void sculpt_stroke_update_step(bContext *C, | static void sculpt_stroke_update_step(bContext *C, | ||||
| struct PaintStroke *UNUSED(stroke), | struct PaintStroke *UNUSED(stroke), | ||||
| ▲ Show 20 Lines • Show All 342 Lines • ▼ Show 20 Lines | static int sculpt_symmetrize_exec(bContext *C, wmOperator *op) | ||||
| switch (BKE_pbvh_type(pbvh)) { | switch (BKE_pbvh_type(pbvh)) { | ||||
| case PBVH_BMESH: | case PBVH_BMESH: | ||||
| /* Dyntopo Symmetrize. */ | /* Dyntopo Symmetrize. */ | ||||
| /* To simplify undo for symmetrize, all BMesh elements are logged | /* To simplify undo for symmetrize, all BMesh elements are logged | ||||
| * as deleted, then after symmetrize operation all BMesh elements | * as deleted, then after symmetrize operation all BMesh elements | ||||
| * are logged as added (as opposed to attempting to store just the | * are logged as added (as opposed to attempting to store just the | ||||
| * parts that symmetrize modifies). */ | * parts that symmetrize modifies). */ | ||||
| SCULPT_undo_push_begin("Dynamic topology symmetrize"); | SCULPT_undo_push_begin(ob, "Dynamic topology symmetrize"); | ||||
| SCULPT_undo_push_node(ob, NULL, SCULPT_UNDO_DYNTOPO_SYMMETRIZE); | SCULPT_undo_push_node(ob, NULL, SCULPT_UNDO_DYNTOPO_SYMMETRIZE); | ||||
| BM_log_before_all_removed(ss->bm, ss->bm_log); | BM_log_before_all_removed(ss->bm, ss->bm_log); | ||||
| BM_mesh_toolflags_set(ss->bm, true); | BM_mesh_toolflags_set(ss->bm, true); | ||||
| /* Symmetrize and re-triangulate. */ | /* Symmetrize and re-triangulate. */ | ||||
| BMO_op_callf(ss->bm, | BMO_op_callf(ss->bm, | ||||
| (BMO_FLAG_DEFAULTS & ~BMO_FLAG_RESPECT_HIDE), | (BMO_FLAG_DEFAULTS & ~BMO_FLAG_RESPECT_HIDE), | ||||
| ▲ Show 20 Lines • Show All 223 Lines • ▼ Show 20 Lines | if (me->flag & ME_SCULPT_DYNAMIC_TOPOLOGY) { | ||||
| } | } | ||||
| if ((message_unsupported == NULL) || force_dyntopo) { | if ((message_unsupported == NULL) || force_dyntopo) { | ||||
| /* Needed because we may be entering this mode before the undo system loads. */ | /* Needed because we may be entering this mode before the undo system loads. */ | ||||
| wmWindowManager *wm = bmain->wm.first; | wmWindowManager *wm = bmain->wm.first; | ||||
| bool has_undo = wm->undo_stack != NULL; | bool has_undo = wm->undo_stack != NULL; | ||||
| /* Undo push is needed to prevent memory leak. */ | /* Undo push is needed to prevent memory leak. */ | ||||
| if (has_undo) { | if (has_undo) { | ||||
| SCULPT_undo_push_begin("Dynamic topology enable"); | SCULPT_undo_push_begin(ob, "Dynamic topology enable"); | ||||
| } | } | ||||
| SCULPT_dynamic_topology_enable_ex(bmain, depsgraph, scene, ob); | SCULPT_dynamic_topology_enable_ex(bmain, depsgraph, scene, ob); | ||||
| if (has_undo) { | if (has_undo) { | ||||
| SCULPT_undo_push_node(ob, NULL, SCULPT_UNDO_DYNTOPO_BEGIN); | SCULPT_undo_push_node(ob, NULL, SCULPT_UNDO_DYNTOPO_BEGIN); | ||||
| SCULPT_undo_push_end(); | SCULPT_undo_push_end(); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| ▲ Show 20 Lines • Show All 99 Lines • ▼ Show 20 Lines | else { | ||||
| if (ob->mode & mode_flag) { | if (ob->mode & mode_flag) { | ||||
| Mesh *me = ob->data; | Mesh *me = ob->data; | ||||
| /* Dyntopo adds its own undo step. */ | /* Dyntopo adds its own undo step. */ | ||||
| if ((me->flag & ME_SCULPT_DYNAMIC_TOPOLOGY) == 0) { | if ((me->flag & ME_SCULPT_DYNAMIC_TOPOLOGY) == 0) { | ||||
| /* Without this the memfile undo step is used, | /* Without this the memfile undo step is used, | ||||
| * while it works it causes lag when undoing the first undo step, see T71564. */ | * while it works it causes lag when undoing the first undo step, see T71564. */ | ||||
| wmWindowManager *wm = CTX_wm_manager(C); | wmWindowManager *wm = CTX_wm_manager(C); | ||||
| if (wm->op_undo_depth <= 1) { | if (wm->op_undo_depth <= 1) { | ||||
| SCULPT_undo_push_begin(op->type->name); | SCULPT_undo_push_begin(ob, op->type->name); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| WM_event_add_notifier(C, NC_SCENE | ND_MODE, scene); | WM_event_add_notifier(C, NC_SCENE | ND_MODE, scene); | ||||
| WM_msg_publish_rna_prop(mbus, &ob->id, ob, Object, mode); | WM_msg_publish_rna_prop(mbus, &ob->id, ob, Object, mode); | ||||
| ▲ Show 20 Lines • Show All 776 Lines • ▼ Show 20 Lines | static int sculpt_mask_by_color_invoke(bContext *C, wmOperator *op, const wmEvent *event) | ||||
| /* Tools that are not brushes do not have the brush gizmo to update the vertex as the mouse move, | /* Tools that are not brushes do not have the brush gizmo to update the vertex as the mouse move, | ||||
| * so it needs to be updated here. */ | * so it needs to be updated here. */ | ||||
| SculptCursorGeometryInfo sgi; | SculptCursorGeometryInfo sgi; | ||||
| float mouse[2]; | float mouse[2]; | ||||
| mouse[0] = event->mval[0]; | mouse[0] = event->mval[0]; | ||||
| mouse[1] = event->mval[1]; | mouse[1] = event->mval[1]; | ||||
| SCULPT_cursor_geometry_info_update(C, &sgi, mouse, false); | SCULPT_cursor_geometry_info_update(C, &sgi, mouse, false); | ||||
| SCULPT_undo_push_begin("Mask by color"); | SCULPT_undo_push_begin(ob, "Mask by color"); | ||||
| const int active_vertex = SCULPT_active_vertex_get(ss); | const int active_vertex = SCULPT_active_vertex_get(ss); | ||||
| const float threshold = RNA_float_get(op->ptr, "threshold"); | const float threshold = RNA_float_get(op->ptr, "threshold"); | ||||
| const bool invert = RNA_boolean_get(op->ptr, "invert"); | const bool invert = RNA_boolean_get(op->ptr, "invert"); | ||||
| const bool preserve_mask = RNA_boolean_get(op->ptr, "preserve_previous_mask"); | const bool preserve_mask = RNA_boolean_get(op->ptr, "preserve_previous_mask"); | ||||
| if (RNA_boolean_get(op->ptr, "contiguous")) { | if (RNA_boolean_get(op->ptr, "contiguous")) { | ||||
| sculpt_mask_by_color_contiguous(ob, active_vertex, threshold, invert, preserve_mask); | sculpt_mask_by_color_contiguous(ob, active_vertex, threshold, invert, preserve_mask); | ||||
| ▲ Show 20 Lines • Show All 412 Lines • Show Last 20 Lines | |||||