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 9,192 Lines • ▼ Show 20 Lines | |||||
| static EnumPropertyItem prop_mesh_filter_deform_axis_items[] = { | static EnumPropertyItem prop_mesh_filter_deform_axis_items[] = { | ||||
| {MESH_FILTER_DEFORM_X, "X", 0, "X", "Deform in the X axis"}, | {MESH_FILTER_DEFORM_X, "X", 0, "X", "Deform in the X axis"}, | ||||
| {MESH_FILTER_DEFORM_Y, "Y", 0, "Y", "Deform in the Y axis"}, | {MESH_FILTER_DEFORM_Y, "Y", 0, "Y", "Deform in the Y axis"}, | ||||
| {MESH_FILTER_DEFORM_Z, "Z", 0, "Z", "Deform in the Z axis"}, | {MESH_FILTER_DEFORM_Z, "Z", 0, "Z", "Deform in the Z axis"}, | ||||
| {0, NULL, 0, NULL, NULL}, | {0, NULL, 0, NULL, NULL}, | ||||
| }; | }; | ||||
| static bool sculpt_mesh_filter_needs_pmap(int filter_type) | static bool sculpt_mesh_filter_needs_pmap(int filter_type, bool use_face_sets) | ||||
| { | { | ||||
| return ELEM(filter_type, MESH_FILTER_SMOOTH, MESH_FILTER_RELAX, MESH_FILTER_RELAX_FACE_SETS); | return use_face_sets || | ||||
| ELEM(filter_type, MESH_FILTER_SMOOTH, MESH_FILTER_RELAX, MESH_FILTER_RELAX_FACE_SETS); | |||||
| } | } | ||||
| static void mesh_filter_task_cb(void *__restrict userdata, | static void mesh_filter_task_cb(void *__restrict userdata, | ||||
| const int i, | const int i, | ||||
| const TaskParallelTLS *__restrict UNUSED(tls)) | const TaskParallelTLS *__restrict UNUSED(tls)) | ||||
| { | { | ||||
| SculptThreadedTaskData *data = userdata; | SculptThreadedTaskData *data = userdata; | ||||
| SculptSession *ss = data->ob->sculpt; | SculptSession *ss = data->ob->sculpt; | ||||
| ▲ Show 20 Lines • Show All 143 Lines • ▼ Show 20 Lines | |||||
| static int sculpt_mesh_filter_modal(bContext *C, wmOperator *op, const wmEvent *event) | static int sculpt_mesh_filter_modal(bContext *C, wmOperator *op, const wmEvent *event) | ||||
| { | { | ||||
| Object *ob = CTX_data_active_object(C); | Object *ob = CTX_data_active_object(C); | ||||
| Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); | Depsgraph *depsgraph = CTX_data_depsgraph_pointer(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; | ||||
| int filter_type = RNA_enum_get(op->ptr, "type"); | int filter_type = RNA_enum_get(op->ptr, "type"); | ||||
| float filter_strength = RNA_float_get(op->ptr, "strength"); | float filter_strength = RNA_float_get(op->ptr, "strength"); | ||||
| const bool use_face_sets = RNA_boolean_get(op->ptr, "use_face_sets"); | |||||
| if (event->type == LEFTMOUSE && event->val == KM_RELEASE) { | if (event->type == LEFTMOUSE && event->val == KM_RELEASE) { | ||||
| sculpt_filter_cache_free(ss); | sculpt_filter_cache_free(ss); | ||||
| SCULPT_undo_push_end(); | SCULPT_undo_push_end(); | ||||
| sculpt_flush_update_done(C, ob, SCULPT_UPDATE_COORDS); | sculpt_flush_update_done(C, ob, SCULPT_UPDATE_COORDS); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| if (event->type != MOUSEMOVE) { | if (event->type != MOUSEMOVE) { | ||||
| return OPERATOR_RUNNING_MODAL; | return OPERATOR_RUNNING_MODAL; | ||||
| } | } | ||||
| float len = event->prevclickx - event->mval[0]; | float len = event->prevclickx - event->mval[0]; | ||||
| filter_strength = filter_strength * -len * 0.001f * UI_DPI_FAC; | filter_strength = filter_strength * -len * 0.001f * UI_DPI_FAC; | ||||
| SCULPT_vertex_random_access_init(ss); | SCULPT_vertex_random_access_init(ss); | ||||
| bool needs_pmap = sculpt_mesh_filter_needs_pmap(filter_type); | bool needs_pmap = sculpt_mesh_filter_needs_pmap(filter_type, use_face_sets); | ||||
| BKE_sculpt_update_object_for_edit(depsgraph, ob, needs_pmap, false); | BKE_sculpt_update_object_for_edit(depsgraph, ob, needs_pmap, false); | ||||
| SculptThreadedTaskData data = { | SculptThreadedTaskData data = { | ||||
| .sd = sd, | .sd = sd, | ||||
| .ob = ob, | .ob = ob, | ||||
| .nodes = ss->filter_cache->nodes, | .nodes = ss->filter_cache->nodes, | ||||
| .filter_type = filter_type, | .filter_type = filter_type, | ||||
| .filter_strength = filter_strength, | .filter_strength = filter_strength, | ||||
| Show All 38 Lines | if (RNA_boolean_get(op->ptr, "use_face_sets")) { | ||||
| /* Update the active vertex */ | /* Update the active vertex */ | ||||
| float mouse[2]; | float mouse[2]; | ||||
| SculptCursorGeometryInfo sgi; | SculptCursorGeometryInfo sgi; | ||||
| 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); | ||||
| } | } | ||||
| const bool use_face_sets = RNA_boolean_get(op->ptr, "use_face_sets"); | |||||
| SCULPT_vertex_random_access_init(ss); | SCULPT_vertex_random_access_init(ss); | ||||
| bool needs_pmap = sculpt_mesh_filter_needs_pmap(filter_type); | bool needs_pmap = sculpt_mesh_filter_needs_pmap(filter_type, use_face_sets); | ||||
| BKE_sculpt_update_object_for_edit(depsgraph, ob, needs_pmap, false); | BKE_sculpt_update_object_for_edit(depsgraph, ob, needs_pmap, false); | ||||
| if (BKE_pbvh_type(pbvh) == PBVH_FACES && needs_pmap && !ob->sculpt->pmap) { | if (BKE_pbvh_type(pbvh) == PBVH_FACES && needs_pmap && !ob->sculpt->pmap) { | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| SCULPT_undo_push_begin("Mesh filter"); | SCULPT_undo_push_begin("Mesh filter"); | ||||
| sculpt_filter_cache_init(ob, sd); | sculpt_filter_cache_init(ob, sd); | ||||
| if (RNA_boolean_get(op->ptr, "use_face_sets")) { | if (use_face_sets) { | ||||
| ss->filter_cache->active_face_set = SCULPT_vertex_face_set_get(ss, | ss->filter_cache->active_face_set = SCULPT_vertex_face_set_get(ss, | ||||
| SCULPT_active_vertex_get(ss)); | SCULPT_active_vertex_get(ss)); | ||||
| } | } | ||||
| else { | else { | ||||
| ss->filter_cache->active_face_set = SCULPT_FACE_SET_NONE; | ss->filter_cache->active_face_set = SCULPT_FACE_SET_NONE; | ||||
| } | } | ||||
| ss->filter_cache->enabled_axis[0] = deform_axis & MESH_FILTER_DEFORM_X; | ss->filter_cache->enabled_axis[0] = deform_axis & MESH_FILTER_DEFORM_X; | ||||
| ▲ Show 20 Lines • Show All 1,726 Lines • Show Last 20 Lines | |||||