Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/sculpt_paint/sculpt_face_set.cc
| Show First 20 Lines • Show All 123 Lines • ▼ Show 20 Lines | static void do_draw_face_sets_brush_task_cb_ex(void *__restrict userdata, | ||||
| PBVHVertexIter vd; | PBVHVertexIter vd; | ||||
| SculptBrushTest test; | SculptBrushTest test; | ||||
| SculptBrushTestFn sculpt_brush_test_sq_fn = SCULPT_brush_test_init_with_falloff_shape( | 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; | |||||
| SCULPT_automasking_node_begin( | |||||
| data->ob, ss, ss->cache->automasking, &automask_data, data->nodes[n]); | |||||
| 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); | |||||
| 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]]; | ||||
| float poly_center[3]; | float poly_center[3]; | ||||
| BKE_mesh_calc_poly_center(p, &ss->mloop[p->loopstart], mvert, poly_center); | BKE_mesh_calc_poly_center(p, &ss->mloop[p->loopstart], mvert, poly_center); | ||||
| if (!sculpt_brush_test_sq_fn(&test, poly_center)) { | if (!sculpt_brush_test_sq_fn(&test, poly_center)) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| const bool face_hidden = ss->hide_poly && ss->hide_poly[vert_map->indices[j]]; | const bool face_hidden = ss->hide_poly && ss->hide_poly[vert_map->indices[j]]; | ||||
| if (face_hidden) { | if (face_hidden) { | ||||
| 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); | |||||
| 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; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| 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); | |||||
| 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); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| BKE_pbvh_vertex_iter_end; | BKE_pbvh_vertex_iter_end; | ||||
| } | } | ||||
| Show All 15 Lines | static void do_relax_face_sets_brush_task_cb_ex(void *__restrict userdata, | ||||
| const bool relax_face_sets = !(ss->cache->iteration_count % 3 == 0); | const bool relax_face_sets = !(ss->cache->iteration_count % 3 == 0); | ||||
| /* This operations needs a strength tweak as the relax deformation is too weak by default. */ | /* This operations needs a strength tweak as the relax deformation is too weak by default. */ | ||||
| if (relax_face_sets) { | if (relax_face_sets) { | ||||
| bstrength *= 2.0f; | bstrength *= 2.0f; | ||||
| } | } | ||||
| const int thread_id = BLI_task_parallel_thread_id(tls); | const int thread_id = BLI_task_parallel_thread_id(tls); | ||||
| AutomaskingNodeData automask_data; | |||||
| SCULPT_automasking_node_begin( | |||||
| data->ob, ss, ss->cache->automasking, &automask_data, data->nodes[n]); | |||||
| 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); | |||||
| if (!sculpt_brush_test_sq_fn(&test, vd.co)) { | if (!sculpt_brush_test_sq_fn(&test, vd.co)) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| if (relax_face_sets == SCULPT_vertex_has_unique_face_set(ss, vd.vertex)) { | if (relax_face_sets == SCULPT_vertex_has_unique_face_set(ss, vd.vertex)) { | ||||
| 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); | |||||
| SCULPT_relax_vertex(ss, &vd, fade * bstrength, relax_face_sets, vd.co); | SCULPT_relax_vertex(ss, &vd, fade * bstrength, relax_face_sets, vd.co); | ||||
| if (vd.mvert) { | if (vd.mvert) { | ||||
| BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex); | BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex); | ||||
| } | } | ||||
| } | } | ||||
| BKE_pbvh_vertex_iter_end; | BKE_pbvh_vertex_iter_end; | ||||
| } | } | ||||
| void SCULPT_do_draw_face_sets_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) | void SCULPT_do_draw_face_sets_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) | ||||
| { | { | ||||
| SculptSession *ss = ob->sculpt; | SculptSession *ss = ob->sculpt; | ||||
| Brush *brush = BKE_paint_brush(&sd->paint); | Brush *brush = BKE_paint_brush(&sd->paint); | ||||
| if (ss->pbvh) { | |||||
| Mesh *mesh = BKE_mesh_from_object(ob); | |||||
| BKE_pbvh_face_sets_color_set( | |||||
| ss->pbvh, mesh->face_sets_color_seed, mesh->face_sets_color_default); | |||||
| } | |||||
| BKE_curvemapping_init(brush->curve); | BKE_curvemapping_init(brush->curve); | ||||
| /* Threaded loop over nodes. */ | /* Threaded loop over nodes. */ | ||||
| SculptThreadedTaskData data{}; | SculptThreadedTaskData data{}; | ||||
| data.sd = sd; | data.sd = sd; | ||||
| data.ob = ob; | data.ob = ob; | ||||
| data.brush = brush; | data.brush = brush; | ||||
| data.nodes = nodes; | data.nodes = nodes; | ||||
| ▲ Show 20 Lines • Show All 1,218 Lines • Show Last 20 Lines | |||||