Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/paint.c
| Show First 20 Lines • Show All 1,600 Lines • ▼ Show 20 Lines | else { | ||||
| ss->multires.level = 0; | ss->multires.level = 0; | ||||
| ss->vmask = CustomData_get_layer(&me->vdata, CD_PAINT_MASK); | ss->vmask = CustomData_get_layer(&me->vdata, CD_PAINT_MASK); | ||||
| ss->vcol = CustomData_get_layer(&me->vdata, CD_PROP_COLOR); | ss->vcol = CustomData_get_layer(&me->vdata, CD_PROP_COLOR); | ||||
| } | } | ||||
| /* Sculpt Face Sets. */ | /* Sculpt Face Sets. */ | ||||
| if (use_face_sets) { | if (use_face_sets) { | ||||
| if (!CustomData_has_layer(&me->pdata, CD_SCULPT_FACE_SETS)) { | if (!CustomData_has_layer(&me->pdata, CD_SCULPT_FACE_SETS)) { | ||||
| ss->face_sets = CustomData_add_layer( | /* By checking here if the datalayer already exist this avoids copying the visibility from | ||||
| &me->pdata, CD_SCULPT_FACE_SETS, CD_CALLOC, NULL, me->totpoly); | * the mesh and looping over all vertices on every sculpt editing operation, using this | ||||
| for (int i = 0; i < me->totpoly; i++) { | * function only the first time the Face Sets datalayer needs to be created. */ | ||||
| ss->face_sets[i] = 1; | BKE_sculpt_face_sets_ensure_from_base_mesh_visibility(me); | ||||
| } | |||||
| /* Set the default face set color if the datalayer did not exist. */ | |||||
| me->face_sets_color_default = 1; | |||||
| } | } | ||||
| ss->face_sets = CustomData_get_layer(&me->pdata, CD_SCULPT_FACE_SETS); | ss->face_sets = CustomData_get_layer(&me->pdata, CD_SCULPT_FACE_SETS); | ||||
| } | } | ||||
| else { | else { | ||||
| ss->face_sets = NULL; | ss->face_sets = NULL; | ||||
| } | } | ||||
| ss->subdiv_ccg = me_eval->runtime.subdiv_ccg; | ss->subdiv_ccg = me_eval->runtime.subdiv_ccg; | ||||
| ▲ Show 20 Lines • Show All 248 Lines • ▼ Show 20 Lines | else { | ||||
| * final DM to give final result to user. | * final DM to give final result to user. | ||||
| */ | */ | ||||
| deformed |= object->sculpt->shapekey_active && (object->shapeflag & OB_SHAPE_LOCK) == 0; | deformed |= object->sculpt->shapekey_active && (object->shapeflag & OB_SHAPE_LOCK) == 0; | ||||
| } | } | ||||
| return deformed; | return deformed; | ||||
| } | } | ||||
| void BKE_sculpt_face_sets_ensure_from_base_mesh_visibility(Mesh *mesh) | |||||
| { | |||||
| const int face_sets_default_visible_id = 1; | |||||
| const int face_sets_default_hidden_id = -(face_sets_default_visible_id + 1); | |||||
| bool initialize_new_face_sets = false; | |||||
| if (CustomData_has_layer(&mesh->pdata, CD_SCULPT_FACE_SETS)) { | |||||
| /* Make everything_visible. */ | |||||
sergey: Remove underscore? | |||||
| int *current_face_sets = CustomData_get_layer(&mesh->pdata, CD_SCULPT_FACE_SETS); | |||||
| for (int i = 0; i < mesh->totpoly; i++) { | |||||
| current_face_sets[i] = abs(current_face_sets[i]); | |||||
| } | |||||
| } | |||||
| else { | |||||
| initialize_new_face_sets = true; | |||||
| int *new_face_sets = CustomData_add_layer( | |||||
| &mesh->pdata, CD_SCULPT_FACE_SETS, CD_CALLOC, NULL, mesh->totpoly); | |||||
| /* Initialize the new Face Set datalayer with a default valid visible ID and set the default | |||||
| * color to render it white. */ | |||||
| for (int i = 0; i < mesh->totpoly; i++) { | |||||
| new_face_sets[i] = face_sets_default_visible_id; | |||||
| } | |||||
| mesh->face_sets_color_default = face_sets_default_visible_id; | |||||
| } | |||||
| int *face_sets = CustomData_get_layer(&mesh->pdata, CD_SCULPT_FACE_SETS); | |||||
| /* Show the only the face sets that have all visibile vertices. */ | |||||
| for (int i = 0; i < mesh->totpoly; i++) { | |||||
| for (int l = 0; l < mesh->mpoly[i].totloop; l++) { | |||||
| MLoop *loop = &mesh->mloop[mesh->mpoly[i].loopstart + l]; | |||||
| if (mesh->mvert[loop->v].flag & ME_HIDE) { | |||||
| if (initialize_new_face_sets) { | |||||
| /* When initializing a new Face Set datalayer, assing a new hidden Face Set ID to hidden | |||||
| * vertices. This way, we get at initial split in two Face Sets between hidden and | |||||
| * visible vertices based on the previous mesh visibily from other mode that can be | |||||
| * useful in some cases. */ | |||||
| face_sets[i] = face_sets_default_hidden_id; | |||||
| } | |||||
| else { | |||||
| /* Otherwise, set the already existing Face Set ID to hidden. */ | |||||
| face_sets[i] = -abs(face_sets[i]); | |||||
| } | |||||
| break; | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| static void sculpt_sync_face_sets_visibility_to_base_mesh(Mesh *mesh) | static void sculpt_sync_face_sets_visibility_to_base_mesh(Mesh *mesh) | ||||
| { | { | ||||
| int *face_sets = CustomData_get_layer(&mesh->pdata, CD_SCULPT_FACE_SETS); | int *face_sets = CustomData_get_layer(&mesh->pdata, CD_SCULPT_FACE_SETS); | ||||
| if (!face_sets) { | if (!face_sets) { | ||||
| return; | return; | ||||
| } | } | ||||
| for (int i = 0; i < mesh->totvert; i++) { | for (int i = 0; i < mesh->totvert; i++) { | ||||
| Show All 38 Lines | for (int i = 0; i < mesh->totloop; i++) { | ||||
| if (gh) { | if (gh) { | ||||
| BLI_bitmap_set_all(gh, is_hidden, key.grid_area); | BLI_bitmap_set_all(gh, is_hidden, key.grid_area); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| void BKE_sculpt_sync_face_set_visibility(struct Mesh *mesh, struct SubdivCCG *subdiv_ccg) | void BKE_sculpt_sync_face_set_visibility(struct Mesh *mesh, struct SubdivCCG *subdiv_ccg) | ||||
| { | { | ||||
| BKE_sculpt_face_sets_ensure_from_base_mesh_visibility(mesh); | |||||
| sculpt_sync_face_sets_visibility_to_base_mesh(mesh); | sculpt_sync_face_sets_visibility_to_base_mesh(mesh); | ||||
| sculpt_sync_face_sets_visibility_to_grids(mesh, subdiv_ccg); | sculpt_sync_face_sets_visibility_to_grids(mesh, subdiv_ccg); | ||||
| } | } | ||||
| static PBVH *build_pbvh_for_dynamic_topology(Object *ob) | static PBVH *build_pbvh_for_dynamic_topology(Object *ob) | ||||
| { | { | ||||
| PBVH *pbvh = BKE_pbvh_new(); | PBVH *pbvh = BKE_pbvh_new(); | ||||
| BKE_pbvh_build_bmesh(pbvh, | BKE_pbvh_build_bmesh(pbvh, | ||||
| ▲ Show 20 Lines • Show All 146 Lines • Show Last 20 Lines | |||||
Remove underscore?