Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/sculpt_paint/sculpt_expand.c
| Show First 20 Lines • Show All 267 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| /** | /** | ||||
| * Main function to get the state of a face for the current state and settings of a #ExpandCache. | * Main function to get the state of a face for the current state and settings of a #ExpandCache. | ||||
| * Returns true when the target data should be modified by expand. | * Returns true when the target data should be modified by expand. | ||||
| */ | */ | ||||
| static bool sculpt_expand_face_state_get(SculptSession *ss, ExpandCache *expand_cache, const int f) | static bool sculpt_expand_face_state_get(SculptSession *ss, ExpandCache *expand_cache, const int f) | ||||
| { | { | ||||
| if (ss->face_sets[f] <= 0) { | if (expand_cache->original_face_sets[f] <= 0) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| if (!sculpt_expand_is_face_in_active_component(ss, expand_cache, f)) { | if (!sculpt_expand_is_face_in_active_component(ss, expand_cache, f)) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| if (expand_cache->all_enabled) { | if (expand_cache->all_enabled) { | ||||
| ▲ Show 20 Lines • Show All 1,108 Lines • ▼ Show 20 Lines | |||||
| /** | /** | ||||
| * Restore the state of the Face Sets before a new update. | * Restore the state of the Face Sets before a new update. | ||||
| */ | */ | ||||
| static void sculpt_expand_face_sets_restore(SculptSession *ss, ExpandCache *expand_cache) | static void sculpt_expand_face_sets_restore(SculptSession *ss, ExpandCache *expand_cache) | ||||
| { | { | ||||
| const int totfaces = ss->totfaces; | const int totfaces = ss->totfaces; | ||||
| for (int i = 0; i < totfaces; i++) { | for (int i = 0; i < totfaces; i++) { | ||||
| if (expand_cache->original_face_sets[i] <= 0) { | |||||
| /* Do not modify hidden Face Sets, even when restoring the IDs state. */ | |||||
| continue; | |||||
| } | |||||
| if (!sculpt_expand_is_face_in_active_component(ss, expand_cache, i)) { | |||||
| continue; | |||||
| } | |||||
| ss->face_sets[i] = expand_cache->initial_face_sets[i]; | ss->face_sets[i] = expand_cache->initial_face_sets[i]; | ||||
| } | } | ||||
| } | } | ||||
| static void sculpt_expand_update_for_vertex(bContext *C, Object *ob, const int vertex) | static void sculpt_expand_update_for_vertex(bContext *C, Object *ob, const int vertex) | ||||
| { | { | ||||
| 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 516 Lines • ▼ Show 20 Lines | static void sculpt_expand_delete_face_set_id(int *r_face_sets, | ||||
| for (int i = 0; i < totface; i++) { | for (int i = 0; i < totface; i++) { | ||||
| if (r_face_sets[i] == delete_id) { | if (r_face_sets[i] == delete_id) { | ||||
| BLI_LINKSTACK_PUSH(queue, POINTER_FROM_INT(i)); | BLI_LINKSTACK_PUSH(queue, POINTER_FROM_INT(i)); | ||||
| } | } | ||||
| } | } | ||||
| while (BLI_LINKSTACK_SIZE(queue)) { | while (BLI_LINKSTACK_SIZE(queue)) { | ||||
| bool any_updated = false; | |||||
| while (BLI_LINKSTACK_SIZE(queue)) { | while (BLI_LINKSTACK_SIZE(queue)) { | ||||
| const int f_index = POINTER_AS_INT(BLI_LINKSTACK_POP(queue)); | const int f_index = POINTER_AS_INT(BLI_LINKSTACK_POP(queue)); | ||||
| int other_id = delete_id; | int other_id = delete_id; | ||||
| const MPoly *c_poly = &mesh->mpoly[f_index]; | const MPoly *c_poly = &mesh->mpoly[f_index]; | ||||
| for (int l = 0; l < c_poly->totloop; l++) { | for (int l = 0; l < c_poly->totloop; l++) { | ||||
| const MLoop *c_loop = &mesh->mloop[c_poly->loopstart + l]; | const MLoop *c_loop = &mesh->mloop[c_poly->loopstart + l]; | ||||
| const MeshElemMap *vert_map = &pmap[c_loop->v]; | const MeshElemMap *vert_map = &pmap[c_loop->v]; | ||||
| for (int i = 0; i < vert_map->count; i++) { | for (int i = 0; i < vert_map->count; i++) { | ||||
| const int neighbor_face_index = vert_map->indices[i]; | const int neighbor_face_index = vert_map->indices[i]; | ||||
| if (expand_cache->original_face_sets[neighbor_face_index] <= 0) { | |||||
| /* Skip picking IDs from hidden Face Sets. */ | |||||
| continue; | |||||
| } | |||||
| if (r_face_sets[neighbor_face_index] != delete_id) { | if (r_face_sets[neighbor_face_index] != delete_id) { | ||||
| other_id = r_face_sets[neighbor_face_index]; | other_id = r_face_sets[neighbor_face_index]; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| if (other_id != delete_id) { | if (other_id != delete_id) { | ||||
| any_updated = true; | |||||
| r_face_sets[f_index] = other_id; | r_face_sets[f_index] = other_id; | ||||
| } | } | ||||
| else { | else { | ||||
| BLI_LINKSTACK_PUSH(queue_next, POINTER_FROM_INT(f_index)); | BLI_LINKSTACK_PUSH(queue_next, POINTER_FROM_INT(f_index)); | ||||
| } | } | ||||
| } | } | ||||
| if (!any_updated) { | |||||
| /* No Face Sets where updated in this iteration, which means that no more content to keep | |||||
| * filling the polys of the deleted Face Set was found. Break to avoid entering an infinite | |||||
| * loop trying to search for those polys again. */ | |||||
| break; | |||||
| } | |||||
| BLI_LINKSTACK_SWAP(queue, queue_next); | BLI_LINKSTACK_SWAP(queue, queue_next); | ||||
| } | } | ||||
| BLI_LINKSTACK_FREE(queue); | BLI_LINKSTACK_FREE(queue); | ||||
| BLI_LINKSTACK_FREE(queue_next); | BLI_LINKSTACK_FREE(queue_next); | ||||
| /* Ensure that the visibility state of the modified Face Sets is the same as the original ones. | |||||
| */ | |||||
| for (int i = 0; i < totface; i++) { | |||||
| if (expand_cache->original_face_sets[i] >= 0) { | |||||
| r_face_sets[i] = abs(r_face_sets[i]); | |||||
| } | |||||
| else { | |||||
| r_face_sets[i] = -abs(r_face_sets[i]); | |||||
| } | |||||
| } | |||||
| } | } | ||||
| static void sculpt_expand_cache_initial_config_set(bContext *C, | static void sculpt_expand_cache_initial_config_set(bContext *C, | ||||
| wmOperator *op, | wmOperator *op, | ||||
| ExpandCache *expand_cache) | ExpandCache *expand_cache) | ||||
| { | { | ||||
| /* RNA properties. */ | /* RNA properties. */ | ||||
| expand_cache->invert = RNA_boolean_get(op->ptr, "invert"); | expand_cache->invert = RNA_boolean_get(op->ptr, "invert"); | ||||
| ▲ Show 20 Lines • Show All 294 Lines • Show Last 20 Lines | |||||