Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/sculpt_paint/sculpt_face_set.c
| Show First 20 Lines • Show All 714 Lines • ▼ Show 20 Lines | switch (mode) { | ||||
| case SCULPT_FACE_SETS_FROM_FACE_MAPS: | case SCULPT_FACE_SETS_FROM_FACE_MAPS: | ||||
| sculpt_face_sets_init_loop(ob, SCULPT_FACE_SETS_FROM_FACE_MAPS); | sculpt_face_sets_init_loop(ob, SCULPT_FACE_SETS_FROM_FACE_MAPS); | ||||
| break; | break; | ||||
| } | } | ||||
| SCULPT_undo_push_end(); | SCULPT_undo_push_end(); | ||||
| /* Sync face sets visibility and vertex visibility as now all Face Sets are visible. */ | /* Sync face sets visibility and vertex visibility as now all Face Sets are visible. */ | ||||
| SCULPT_visibility_sync_all_face_sets_to_vertices(ss); | SCULPT_visibility_sync_all_face_sets_to_vertices(ob); | ||||
| for (int i = 0; i < totnode; i++) { | for (int i = 0; i < totnode; i++) { | ||||
| BKE_pbvh_node_mark_update_visibility(nodes[i]); | BKE_pbvh_node_mark_update_visibility(nodes[i]); | ||||
| } | } | ||||
| BKE_pbvh_update_vertex_data(ss->pbvh, PBVH_UpdateVisibility); | BKE_pbvh_update_vertex_data(ss->pbvh, PBVH_UpdateVisibility); | ||||
| MEM_SAFE_FREE(nodes); | MEM_SAFE_FREE(nodes); | ||||
| ▲ Show 20 Lines • Show All 152 Lines • ▼ Show 20 Lines | static int sculpt_face_sets_change_visibility_exec(bContext *C, wmOperator *op) | ||||
| if (mode == SCULPT_FACE_SET_VISIBILITY_SHOW_ALL) { | if (mode == SCULPT_FACE_SET_VISIBILITY_SHOW_ALL) { | ||||
| SCULPT_face_sets_visibility_all_set(ss, true); | SCULPT_face_sets_visibility_all_set(ss, true); | ||||
| } | } | ||||
| if (mode == SCULPT_FACE_SET_VISIBILITY_SHOW_ACTIVE) { | if (mode == SCULPT_FACE_SET_VISIBILITY_SHOW_ACTIVE) { | ||||
| SCULPT_face_sets_visibility_all_set(ss, false); | SCULPT_face_sets_visibility_all_set(ss, false); | ||||
| SCULPT_face_set_visibility_set(ss, active_face_set, true); | SCULPT_face_set_visibility_set(ss, active_face_set, true); | ||||
| for (int i = 0; i < tot_vert; i++) { | |||||
| SCULPT_vertex_visible_set(ss, | |||||
| i, | |||||
| SCULPT_vertex_visible_get(ss, i) && | |||||
| SCULPT_vertex_has_face_set(ss, i, active_face_set)); | |||||
| } | |||||
| } | } | ||||
| if (mode == SCULPT_FACE_SET_VISIBILITY_HIDE_ACTIVE) { | if (mode == SCULPT_FACE_SET_VISIBILITY_HIDE_ACTIVE) { | ||||
| SCULPT_face_set_visibility_set(ss, active_face_set, false); | SCULPT_face_set_visibility_set(ss, active_face_set, false); | ||||
| } | } | ||||
| if (mode == SCULPT_FACE_SET_VISIBILITY_INVERT) { | if (mode == SCULPT_FACE_SET_VISIBILITY_INVERT) { | ||||
| SCULPT_face_sets_visibility_invert(ss); | SCULPT_face_sets_visibility_invert(ss); | ||||
| } | } | ||||
| /* For modes that use the cursor active vertex, update the rotation origin for viewport | /* For modes that use the cursor active vertex, update the rotation origin for viewport | ||||
| * navigation. */ | * navigation. */ | ||||
| if (ELEM(mode, SCULPT_FACE_SET_VISIBILITY_TOGGLE, SCULPT_FACE_SET_VISIBILITY_SHOW_ACTIVE)) { | if (ELEM(mode, SCULPT_FACE_SET_VISIBILITY_TOGGLE, SCULPT_FACE_SET_VISIBILITY_SHOW_ACTIVE)) { | ||||
| UnifiedPaintSettings *ups = &CTX_data_tool_settings(C)->unified_paint_settings; | UnifiedPaintSettings *ups = &CTX_data_tool_settings(C)->unified_paint_settings; | ||||
| float location[3]; | float location[3]; | ||||
| copy_v3_v3(location, SCULPT_active_vertex_co_get(ss)); | copy_v3_v3(location, SCULPT_active_vertex_co_get(ss)); | ||||
| mul_m4_v3(ob->obmat, location); | mul_m4_v3(ob->obmat, location); | ||||
| copy_v3_v3(ups->average_stroke_accum, location); | copy_v3_v3(ups->average_stroke_accum, location); | ||||
| ups->average_stroke_counter = 1; | ups->average_stroke_counter = 1; | ||||
| ups->last_stroke_valid = true; | ups->last_stroke_valid = true; | ||||
| } | } | ||||
| /* Sync face sets visibility and vertex visibility. */ | /* Sync face sets visibility and vertex visibility. */ | ||||
| SCULPT_visibility_sync_all_face_sets_to_vertices(ss); | SCULPT_visibility_sync_all_face_sets_to_vertices(ob); | ||||
| SCULPT_undo_push_end(); | SCULPT_undo_push_end(); | ||||
| for (int i = 0; i < totnode; i++) { | for (int i = 0; i < totnode; i++) { | ||||
| BKE_pbvh_node_mark_update_visibility(nodes[i]); | BKE_pbvh_node_mark_update_visibility(nodes[i]); | ||||
| } | } | ||||
| BKE_pbvh_update_vertex_data(ss->pbvh, PBVH_UpdateVisibility); | BKE_pbvh_update_vertex_data(ss->pbvh, PBVH_UpdateVisibility); | ||||
| MEM_SAFE_FREE(nodes); | MEM_SAFE_FREE(nodes); | ||||
| if (BKE_pbvh_type(pbvh) == PBVH_FACES) { | |||||
| BKE_mesh_flush_hidden_from_verts(ob->data); | |||||
| } | |||||
| ED_region_tag_redraw(region); | ED_region_tag_redraw(region); | ||||
| DEG_id_tag_update(&ob->id, ID_RECALC_SHADING); | DEG_id_tag_update(&ob->id, ID_RECALC_SHADING); | ||||
| View3D *v3d = CTX_wm_view3d(C); | View3D *v3d = CTX_wm_view3d(C); | ||||
| if (!BKE_sculptsession_use_pbvh_draw(ob, v3d)) { | if (!BKE_sculptsession_use_pbvh_draw(ob, v3d)) { | ||||
| DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); | DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); | ||||
| } | } | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| ▲ Show 20 Lines • Show All 244 Lines • ▼ Show 20 Lines | static int sculpt_face_set_edit_invoke(bContext *C, wmOperator *op, const wmEvent *event) | ||||
| const int active_face_set = SCULPT_active_face_set_get(ss); | const int active_face_set = SCULPT_active_face_set_get(ss); | ||||
| const bool modify_hidden = RNA_boolean_get(op->ptr, "modify_hidden"); | const bool modify_hidden = RNA_boolean_get(op->ptr, "modify_hidden"); | ||||
| sculpt_face_set_apply_edit(ob, abs(active_face_set), mode, modify_hidden); | sculpt_face_set_apply_edit(ob, abs(active_face_set), mode, modify_hidden); | ||||
| SCULPT_undo_push_end(); | SCULPT_undo_push_end(); | ||||
| /* Sync face sets visibility and vertex visibility as now all Face Sets are visible. */ | /* Sync face sets visibility and vertex visibility as now all Face Sets are visible. */ | ||||
| SCULPT_visibility_sync_all_face_sets_to_vertices(ss); | SCULPT_visibility_sync_all_face_sets_to_vertices(ob); | ||||
| for (int i = 0; i < totnode; i++) { | for (int i = 0; i < totnode; i++) { | ||||
| BKE_pbvh_node_mark_update_visibility(nodes[i]); | BKE_pbvh_node_mark_update_visibility(nodes[i]); | ||||
| } | } | ||||
| BKE_pbvh_update_vertex_data(ss->pbvh, PBVH_UpdateVisibility); | BKE_pbvh_update_vertex_data(ss->pbvh, PBVH_UpdateVisibility); | ||||
| MEM_SAFE_FREE(nodes); | MEM_SAFE_FREE(nodes); | ||||
| Show All 37 Lines | |||||