Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/sculpt_paint/sculpt_mask_expand.c
| Show First 20 Lines • Show All 80 Lines • ▼ Show 20 Lines | static void sculpt_expand_task_cb(void *__restrict userdata, | ||||
| SculptSession *ss = data->ob->sculpt; | SculptSession *ss = data->ob->sculpt; | ||||
| PBVHNode *node = data->nodes[i]; | PBVHNode *node = data->nodes[i]; | ||||
| PBVHVertexIter vd; | PBVHVertexIter vd; | ||||
| int update_it = data->mask_expand_update_it; | int update_it = data->mask_expand_update_it; | ||||
| PBVHVertRef active_vertex = SCULPT_active_vertex_get(ss); | PBVHVertRef active_vertex = SCULPT_active_vertex_get(ss); | ||||
| int active_vertex_i = BKE_pbvh_vertex_to_index(ss->pbvh, active_vertex); | int active_vertex_i = BKE_pbvh_vertex_to_index(ss->pbvh, active_vertex); | ||||
| bool face_sets_changed = false; | |||||
| BKE_pbvh_vertex_iter_begin (ss->pbvh, node, vd, PBVH_ITER_ALL) { | BKE_pbvh_vertex_iter_begin (ss->pbvh, node, vd, PBVH_ITER_ALL) { | ||||
| int vi = vd.index; | int vi = vd.index; | ||||
| float final_mask = *vd.mask; | float final_mask = *vd.mask; | ||||
| if (data->mask_expand_use_normals) { | if (data->mask_expand_use_normals) { | ||||
| if (ss->filter_cache->normal_factor[active_vertex_i] < | if (ss->filter_cache->normal_factor[active_vertex_i] < | ||||
| ss->filter_cache->normal_factor[vd.index]) { | ss->filter_cache->normal_factor[vd.index]) { | ||||
| final_mask = 1.0f; | final_mask = 1.0f; | ||||
| } | } | ||||
| Show All 9 Lines | else { | ||||
| else { | else { | ||||
| final_mask = 0.0f; | final_mask = 0.0f; | ||||
| } | } | ||||
| } | } | ||||
| if (data->mask_expand_create_face_set) { | if (data->mask_expand_create_face_set) { | ||||
| if (final_mask == 1.0f) { | if (final_mask == 1.0f) { | ||||
| SCULPT_vertex_face_set_set(ss, vd.vertex, ss->filter_cache->new_face_set); | SCULPT_vertex_face_set_set(ss, vd.vertex, ss->filter_cache->new_face_set); | ||||
| face_sets_changed = true; | |||||
| } | } | ||||
| BKE_pbvh_node_mark_redraw(node); | BKE_pbvh_node_mark_redraw(node); | ||||
| } | } | ||||
| else { | else { | ||||
| if (data->mask_expand_keep_prev_mask) { | if (data->mask_expand_keep_prev_mask) { | ||||
| final_mask = MAX2(ss->filter_cache->prev_mask[vd.index], final_mask); | final_mask = MAX2(ss->filter_cache->prev_mask[vd.index], final_mask); | ||||
| } | } | ||||
| if (data->mask_expand_invert_mask) { | if (data->mask_expand_invert_mask) { | ||||
| final_mask = 1.0f - final_mask; | final_mask = 1.0f - final_mask; | ||||
| } | } | ||||
| if (*vd.mask != final_mask) { | if (*vd.mask != final_mask) { | ||||
| *vd.mask = final_mask; | *vd.mask = final_mask; | ||||
| BKE_pbvh_node_mark_update_mask(node); | BKE_pbvh_node_mark_update_mask(node); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| BKE_pbvh_vertex_iter_end; | BKE_pbvh_vertex_iter_end; | ||||
| if (face_sets_changed) { | |||||
| SCULPT_undo_push_node(data->ob, node, SCULPT_UNDO_FACE_SETS); | |||||
| } | |||||
| } | } | ||||
| static int sculpt_mask_expand_modal(bContext *C, wmOperator *op, const wmEvent *event) | static int sculpt_mask_expand_modal(bContext *C, wmOperator *op, const wmEvent *event) | ||||
| { | { | ||||
| Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); | Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); | ||||
| 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; | ||||
| ▲ Show 20 Lines • Show All 206 Lines • ▼ Show 20 Lines | static int sculpt_mask_expand_invoke(bContext *C, wmOperator *op, const wmEvent *event) | ||||
| ss->filter_cache = MEM_callocN(sizeof(FilterCache), "filter cache"); | ss->filter_cache = MEM_callocN(sizeof(FilterCache), "filter cache"); | ||||
| BKE_pbvh_search_gather(pbvh, NULL, NULL, &ss->filter_cache->nodes, &ss->filter_cache->totnode); | BKE_pbvh_search_gather(pbvh, NULL, NULL, &ss->filter_cache->nodes, &ss->filter_cache->totnode); | ||||
| SCULPT_undo_push_begin(ob, op); | SCULPT_undo_push_begin(ob, op); | ||||
| if (create_face_set) { | if (create_face_set) { | ||||
| SCULPT_undo_push_node(ob, ss->filter_cache->nodes[0], SCULPT_UNDO_FACE_SETS); | |||||
| for (int i = 0; i < ss->filter_cache->totnode; i++) { | for (int i = 0; i < ss->filter_cache->totnode; i++) { | ||||
| BKE_pbvh_node_mark_redraw(ss->filter_cache->nodes[i]); | BKE_pbvh_node_mark_redraw(ss->filter_cache->nodes[i]); | ||||
| SCULPT_undo_push_node(ob, ss->filter_cache->nodes[i], SCULPT_UNDO_FACE_SETS); | |||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| for (int i = 0; i < ss->filter_cache->totnode; i++) { | for (int i = 0; i < ss->filter_cache->totnode; i++) { | ||||
| SCULPT_undo_push_node(ob, ss->filter_cache->nodes[i], SCULPT_UNDO_MASK); | SCULPT_undo_push_node(ob, ss->filter_cache->nodes[i], SCULPT_UNDO_MASK); | ||||
| BKE_pbvh_node_mark_redraw(ss->filter_cache->nodes[i]); | BKE_pbvh_node_mark_redraw(ss->filter_cache->nodes[i]); | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 142 Lines • Show Last 20 Lines | |||||