Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/sculpt_paint/sculpt_face_set.cc
| Show First 20 Lines • Show All 119 Lines • ▼ Show 20 Lines | SculptBrushTestFn sculpt_brush_test_sq_fn = SCULPT_brush_test_init_with_falloff_shape( | ||||
| ss, &test, data->brush->falloff_shape); | ss, &test, data->brush->falloff_shape); | ||||
| const int thread_id = BLI_task_parallel_thread_id(tls); | const int thread_id = BLI_task_parallel_thread_id(tls); | ||||
| MVert *mvert = SCULPT_mesh_deformed_mverts_get(ss); | MVert *mvert = SCULPT_mesh_deformed_mverts_get(ss); | ||||
| AutomaskingNodeData automask_data; | AutomaskingNodeData automask_data; | ||||
| SCULPT_automasking_node_begin( | SCULPT_automasking_node_begin( | ||||
| data->ob, ss, ss->cache->automasking, &automask_data, data->nodes[n]); | data->ob, ss, ss->cache->automasking, &automask_data, data->nodes[n]); | ||||
| bool changed = false; | |||||
| BKE_pbvh_vertex_iter_begin (ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE) { | BKE_pbvh_vertex_iter_begin (ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE) { | ||||
| SCULPT_automasking_node_update(ss, &automask_data, &vd); | SCULPT_automasking_node_update(ss, &automask_data, &vd); | ||||
| if (BKE_pbvh_type(ss->pbvh) == PBVH_FACES) { | if (BKE_pbvh_type(ss->pbvh) == PBVH_FACES) { | ||||
| MeshElemMap *vert_map = &ss->pmap[vd.index]; | MeshElemMap *vert_map = &ss->pmap[vd.index]; | ||||
| for (int j = 0; j < ss->pmap[vd.index].count; j++) { | for (int j = 0; j < ss->pmap[vd.index].count; j++) { | ||||
| const MPoly *p = &ss->mpoly[vert_map->indices[j]]; | const MPoly *p = &ss->mpoly[vert_map->indices[j]]; | ||||
| Show All 15 Lines | if (BKE_pbvh_type(ss->pbvh) == PBVH_FACES) { | ||||
| vd.fno, | vd.fno, | ||||
| vd.mask ? *vd.mask : 0.0f, | vd.mask ? *vd.mask : 0.0f, | ||||
| vd.vertex, | vd.vertex, | ||||
| thread_id, | thread_id, | ||||
| &automask_data); | &automask_data); | ||||
| if (fade > 0.05f) { | if (fade > 0.05f) { | ||||
| ss->face_sets[vert_map->indices[j]] = ss->cache->paint_face_set; | ss->face_sets[vert_map->indices[j]] = ss->cache->paint_face_set; | ||||
| changed = true; | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| else if (BKE_pbvh_type(ss->pbvh) == PBVH_GRIDS) { | else if (BKE_pbvh_type(ss->pbvh) == PBVH_GRIDS) { | ||||
| if (!sculpt_brush_test_sq_fn(&test, vd.co)) { | if (!sculpt_brush_test_sq_fn(&test, vd.co)) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| const float fade = bstrength * SCULPT_brush_strength_factor(ss, | const float fade = bstrength * SCULPT_brush_strength_factor(ss, | ||||
| brush, | brush, | ||||
| vd.co, | vd.co, | ||||
| sqrtf(test.dist), | sqrtf(test.dist), | ||||
| vd.no, | vd.no, | ||||
| vd.fno, | vd.fno, | ||||
| vd.mask ? *vd.mask : 0.0f, | vd.mask ? *vd.mask : 0.0f, | ||||
| vd.vertex, | vd.vertex, | ||||
| thread_id, | thread_id, | ||||
| &automask_data); | &automask_data); | ||||
| if (fade > 0.05f) { | if (fade > 0.05f) { | ||||
| SCULPT_vertex_face_set_set(ss, vd.vertex, ss->cache->paint_face_set); | SCULPT_vertex_face_set_set(ss, vd.vertex, ss->cache->paint_face_set); | ||||
| changed = true; | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| BKE_pbvh_vertex_iter_end; | BKE_pbvh_vertex_iter_end; | ||||
| if (changed) { | |||||
| SCULPT_undo_push_node(data->ob, data->nodes[n], SCULPT_UNDO_FACE_SETS); | |||||
| } | |||||
| } | } | ||||
| static void do_relax_face_sets_brush_task_cb_ex(void *__restrict userdata, | static void do_relax_face_sets_brush_task_cb_ex(void *__restrict userdata, | ||||
| const int n, | const int n, | ||||
| const TaskParallelTLS *__restrict tls) | const TaskParallelTLS *__restrict tls) | ||||
| { | { | ||||
| SculptThreadedTaskData *data = static_cast<SculptThreadedTaskData *>(userdata); | SculptThreadedTaskData *data = static_cast<SculptThreadedTaskData *>(userdata); | ||||
| SculptSession *ss = data->ob->sculpt; | SculptSession *ss = data->ob->sculpt; | ||||
| ▲ Show 20 Lines • Show All 148 Lines • ▼ Show 20 Lines | static int sculpt_face_set_create_exec(bContext *C, wmOperator *op) | ||||
| int totnode; | int totnode; | ||||
| BKE_pbvh_search_gather(pbvh, nullptr, nullptr, &nodes, &totnode); | BKE_pbvh_search_gather(pbvh, nullptr, nullptr, &nodes, &totnode); | ||||
| if (!nodes) { | if (!nodes) { | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| SCULPT_undo_push_begin(ob, op); | SCULPT_undo_push_begin(ob, op); | ||||
| SCULPT_undo_push_node(ob, nodes[0], SCULPT_UNDO_FACE_SETS); | for (const int i : blender::IndexRange(totnode)) { | ||||
| SCULPT_undo_push_node(ob, nodes[i], SCULPT_UNDO_FACE_SETS); | |||||
| } | |||||
| const int next_face_set = SCULPT_face_set_next_available_get(ss); | const int next_face_set = SCULPT_face_set_next_available_get(ss); | ||||
| if (mode == SCULPT_FACE_SET_MASKED) { | if (mode == SCULPT_FACE_SET_MASKED) { | ||||
| for (int i = 0; i < tot_vert; i++) { | for (int i = 0; i < tot_vert; i++) { | ||||
| PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, i); | PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, i); | ||||
| if (SCULPT_vertex_mask_get(ss, vertex) >= threshold && | if (SCULPT_vertex_mask_get(ss, vertex) >= threshold && | ||||
| ▲ Show 20 Lines • Show All 276 Lines • ▼ Show 20 Lines | static int sculpt_face_set_init_exec(bContext *C, wmOperator *op) | ||||
| int totnode; | int totnode; | ||||
| BKE_pbvh_search_gather(pbvh, nullptr, nullptr, &nodes, &totnode); | BKE_pbvh_search_gather(pbvh, nullptr, nullptr, &nodes, &totnode); | ||||
| if (!nodes) { | if (!nodes) { | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| SCULPT_undo_push_begin(ob, op); | SCULPT_undo_push_begin(ob, op); | ||||
| SCULPT_undo_push_node(ob, nodes[0], SCULPT_UNDO_FACE_SETS); | for (const int i : blender::IndexRange(totnode)) { | ||||
| SCULPT_undo_push_node(ob, nodes[i], SCULPT_UNDO_FACE_SETS); | |||||
| } | |||||
| const float threshold = RNA_float_get(op->ptr, "threshold"); | const float threshold = RNA_float_get(op->ptr, "threshold"); | ||||
| Mesh *mesh = static_cast<Mesh *>(ob->data); | Mesh *mesh = static_cast<Mesh *>(ob->data); | ||||
| ss->face_sets = BKE_sculpt_face_sets_ensure(mesh); | ss->face_sets = BKE_sculpt_face_sets_ensure(mesh); | ||||
| const bke::AttributeAccessor attributes = mesh->attributes(); | const bke::AttributeAccessor attributes = mesh->attributes(); | ||||
| switch (mode) { | switch (mode) { | ||||
| ▲ Show 20 Lines • Show All 712 Lines • ▼ Show 20 Lines | static void sculpt_face_set_edit_modify_face_sets(Object *ob, | ||||
| PBVHNode **nodes; | PBVHNode **nodes; | ||||
| int totnode; | int totnode; | ||||
| BKE_pbvh_search_gather(pbvh, nullptr, nullptr, &nodes, &totnode); | BKE_pbvh_search_gather(pbvh, nullptr, nullptr, &nodes, &totnode); | ||||
| if (!nodes) { | if (!nodes) { | ||||
| return; | return; | ||||
| } | } | ||||
| SCULPT_undo_push_begin(ob, op); | SCULPT_undo_push_begin(ob, op); | ||||
| SCULPT_undo_push_node(ob, nodes[0], SCULPT_UNDO_FACE_SETS); | for (const int i : blender::IndexRange(totnode)) { | ||||
| SCULPT_undo_push_node(ob, nodes[i], SCULPT_UNDO_FACE_SETS); | |||||
| } | |||||
| 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(ob); | SCULPT_undo_push_end(ob); | ||||
| face_set_edit_do_post_visibility_updates(ob, nodes, totnode); | face_set_edit_do_post_visibility_updates(ob, nodes, totnode); | ||||
| MEM_freeN(nodes); | MEM_freeN(nodes); | ||||
| } | } | ||||
| static void sculpt_face_set_edit_modify_coordinates(bContext *C, | static void sculpt_face_set_edit_modify_coordinates(bContext *C, | ||||
| Object *ob, | Object *ob, | ||||
| ▲ Show 20 Lines • Show All 93 Lines • Show Last 20 Lines | |||||