Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/sculpt_paint/sculpt_filter_mesh.c
| Show First 20 Lines • Show All 175 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, bool use_face_sets) | static bool sculpt_mesh_filter_needs_pmap(int filter_type, bool use_face_sets) | ||||
sergey: Always make no-functional-changes in the separate commit.
There is no need to introduce… | |||||
| { | { | ||||
| return use_face_sets || ELEM(filter_type, | return use_face_sets || ELEM(filter_type, | ||||
| MESH_FILTER_SMOOTH, | MESH_FILTER_SMOOTH, | ||||
| MESH_FILTER_RELAX, | MESH_FILTER_RELAX, | ||||
| MESH_FILTER_RELAX_FACE_SETS, | MESH_FILTER_RELAX_FACE_SETS, | ||||
| MESH_FILTER_SURFACE_SMOOTH, | MESH_FILTER_SURFACE_SMOOTH, | ||||
| MESH_FILTER_SHARPEN); | MESH_FILTER_SHARPEN); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | if (filter_type == MESH_FILTER_RELAX_FACE_SETS) { | ||||
| if (relax_face_sets == SCULPT_vertex_has_unique_face_set(ss, vd.index)) { | if (relax_face_sets == SCULPT_vertex_has_unique_face_set(ss, vd.index)) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| } | } | ||||
| switch (filter_type) { | switch (filter_type) { | ||||
| case MESH_FILTER_SMOOTH: | case MESH_FILTER_SMOOTH: | ||||
| CLAMP(fade, -1.0f, 1.0f); | CLAMP(fade, -1.0f, 1.0f); | ||||
| switch (BKE_pbvh_type(ss->pbvh)) { | SCULPT_neighbor_coords_average_interior(ss, avg, vd.index); | ||||
| case PBVH_FACES: | |||||
| SCULPT_neighbor_average(ss, avg, vd.index); | |||||
| break; | |||||
| case PBVH_BMESH: | |||||
| SCULPT_bmesh_neighbor_average(avg, vd.bm_vert); | |||||
| break; | |||||
| case PBVH_GRIDS: | |||||
| SCULPT_neighbor_coords_average(ss, avg, vd.index); | |||||
| break; | |||||
| } | |||||
| sub_v3_v3v3(val, avg, orig_co); | sub_v3_v3v3(val, avg, orig_co); | ||||
| madd_v3_v3v3fl(val, orig_co, val, fade); | madd_v3_v3v3fl(val, orig_co, val, fade); | ||||
| sub_v3_v3v3(disp, val, orig_co); | sub_v3_v3v3(disp, val, orig_co); | ||||
| break; | break; | ||||
| case MESH_FILTER_INFLATE: | case MESH_FILTER_INFLATE: | ||||
| normal_short_to_float_v3(normal, orig_data.no); | normal_short_to_float_v3(normal, orig_data.no); | ||||
| mul_v3_v3fl(disp, normal, fade); | mul_v3_v3fl(disp, normal, fade); | ||||
| break; | break; | ||||
| ▲ Show 20 Lines • Show All 252 Lines • ▼ Show 20 Lines | if (RNA_boolean_get(op->ptr, "use_face_sets")) { | ||||
| 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"); | 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, use_face_sets); | const bool needs_topology_info = sculpt_mesh_filter_needs_pmap(filter_type, use_face_sets); | ||||
| BKE_sculpt_update_object_for_edit(depsgraph, ob, needs_pmap, false, false); | BKE_sculpt_update_object_for_edit(depsgraph, ob, needs_topology_info, false, false); | ||||
| if (needs_topology_info) { | |||||
| SCULPT_boundary_info_ensure(ob); | |||||
| } | |||||
Done Inline Actionsconst sergey: `const` | |||||
| const int totvert = SCULPT_vertex_count_get(ss); | const int totvert = SCULPT_vertex_count_get(ss); | ||||
| if (BKE_pbvh_type(pbvh) == PBVH_FACES && needs_pmap && !ob->sculpt->pmap) { | if (BKE_pbvh_type(pbvh) == PBVH_FACES && needs_topology_info && !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_UNDO_COORDS); | SCULPT_filter_cache_init(ob, sd, SCULPT_UNDO_COORDS); | ||||
| if (use_face_sets) { | if (use_face_sets) { | ||||
| ▲ Show 20 Lines • Show All 104 Lines • Show Last 20 Lines | |||||
Always make no-functional-changes in the separate commit.
There is no need to introduce functional changes to qualify for making a change which makes naming more generic and prepares foundation for the further development.