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 102 Lines • ▼ Show 20 Lines | |||||
| * | * | ||||
| * For multires, the same vertex in multiple grids is counted multiple times, with | * For multires, the same vertex in multiple grids is counted multiple times, with | ||||
| * different index for each grid. */ | * different index for each grid. */ | ||||
| static void sculpt_vertex_random_access_init(SculptSession *ss) | static void sculpt_vertex_random_access_init(SculptSession *ss) | ||||
| { | { | ||||
| if (BKE_pbvh_type(ss->pbvh) == PBVH_BMESH) { | if (BKE_pbvh_type(ss->pbvh) == PBVH_BMESH) { | ||||
| BM_mesh_elem_index_ensure(ss->bm, BM_VERT); | BM_mesh_elem_index_ensure(ss->bm, BM_VERT); | ||||
| BM_mesh_elem_table_ensure(ss->bm, BM_VERT); | |||||
| } | } | ||||
| } | } | ||||
| static int sculpt_vertex_count_get(SculptSession *ss) | static int sculpt_vertex_count_get(SculptSession *ss) | ||||
| { | { | ||||
| switch (BKE_pbvh_type(ss->pbvh)) { | switch (BKE_pbvh_type(ss->pbvh)) { | ||||
| case PBVH_FACES: | case PBVH_FACES: | ||||
| return ss->totvert; | return ss->totvert; | ||||
| ▲ Show 20 Lines • Show All 2,948 Lines • ▼ Show 20 Lines | static void sculpt_relax_vertex(SculptSession *ss, | ||||
| if (count > 0) { | if (count > 0) { | ||||
| mul_v3_fl(smooth_pos, 1.0f / (float)count); | mul_v3_fl(smooth_pos, 1.0f / (float)count); | ||||
| } | } | ||||
| float plane[4]; | float plane[4]; | ||||
| float smooth_closest_plane[3]; | float smooth_closest_plane[3]; | ||||
| float vno[3]; | float vno[3]; | ||||
| if (vd->no) { | |||||
| normal_short_to_float_v3(vno, vd->no); | normal_short_to_float_v3(vno, vd->no); | ||||
| } | |||||
| else { | |||||
| copy_v3_v3(vno, vd->fno); | |||||
| } | |||||
| plane_from_point_normal_v3(plane, vd->co, vno); | plane_from_point_normal_v3(plane, vd->co, vno); | ||||
| closest_to_plane_v3(smooth_closest_plane, plane, smooth_pos); | closest_to_plane_v3(smooth_closest_plane, plane, smooth_pos); | ||||
| sub_v3_v3v3(final_disp, smooth_closest_plane, vd->co); | sub_v3_v3v3(final_disp, smooth_closest_plane, vd->co); | ||||
| mul_v3_fl(final_disp, factor); | mul_v3_fl(final_disp, factor); | ||||
| add_v3_v3v3(r_final_pos, vd->co, final_disp); | add_v3_v3v3(r_final_pos, vd->co, final_disp); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 5,824 Lines • ▼ Show 20 Lines | BKE_pbvh_vertex_iter_begin(ss->pbvh, node, vd, PBVH_ITER_UNIQUE) | ||||
| add_v3_v3v3(final_pos, orig_co, disp); | add_v3_v3v3(final_pos, orig_co, disp); | ||||
| copy_v3_v3(vd.co, final_pos); | copy_v3_v3(vd.co, final_pos); | ||||
| if (vd.mvert) { | if (vd.mvert) { | ||||
| vd.mvert->flag |= ME_VERT_PBVH_UPDATE; | vd.mvert->flag |= ME_VERT_PBVH_UPDATE; | ||||
| } | } | ||||
| } | } | ||||
| BKE_pbvh_vertex_iter_end; | BKE_pbvh_vertex_iter_end; | ||||
| BKE_pbvh_node_mark_redraw(node); | BKE_pbvh_node_mark_update(node); | ||||
| BKE_pbvh_node_mark_normals_update(node); | |||||
| } | } | ||||
| 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; | ||||
| Show All 31 Lines | static int sculpt_mesh_filter_modal(bContext *C, wmOperator *op, const wmEvent *event) | ||||
| BKE_pbvh_parallel_range_settings( | BKE_pbvh_parallel_range_settings( | ||||
| &settings, (sd->flags & SCULPT_USE_OPENMP), ss->filter_cache->totnode); | &settings, (sd->flags & SCULPT_USE_OPENMP), ss->filter_cache->totnode); | ||||
| BKE_pbvh_parallel_range(0, ss->filter_cache->totnode, &data, mesh_filter_task_cb, &settings); | BKE_pbvh_parallel_range(0, ss->filter_cache->totnode, &data, mesh_filter_task_cb, &settings); | ||||
| if (ss->deform_modifiers_active || ss->shapekey_active) { | if (ss->deform_modifiers_active || ss->shapekey_active) { | ||||
| sculpt_flush_stroke_deform(sd, ob, true); | sculpt_flush_stroke_deform(sd, ob, true); | ||||
| } | } | ||||
| /* The relax mesh filter needs the updated normals of the modified mesh after each iteration */ | |||||
| if (filter_type == MESH_FILTER_RELAX) { | |||||
| BKE_pbvh_update_normals(ss->pbvh, ss->subdiv_ccg); | |||||
| } | |||||
| sculpt_flush_update_step(C, SCULPT_UPDATE_COORDS); | sculpt_flush_update_step(C, SCULPT_UPDATE_COORDS); | ||||
| return OPERATOR_RUNNING_MODAL; | return OPERATOR_RUNNING_MODAL; | ||||
| } | } | ||||
| static int sculpt_mesh_filter_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) | static int sculpt_mesh_filter_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) | ||||
| { | { | ||||
| Object *ob = CTX_data_active_object(C); | Object *ob = CTX_data_active_object(C); | ||||
| ▲ Show 20 Lines • Show All 1,351 Lines • Show Last 20 Lines | |||||