Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/sculpt_paint/sculpt.c
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
| Show First 20 Lines • Show All 11,105 Lines • ▼ Show 20 Lines | static int sculpt_face_sets_randomize_colors_invoke(bContext *C, | ||||
| PBVH *pbvh = ob->sculpt->pbvh; | PBVH *pbvh = ob->sculpt->pbvh; | ||||
| PBVHNode **nodes; | PBVHNode **nodes; | ||||
| int totnode; | int totnode; | ||||
| Mesh *mesh = ob->data; | Mesh *mesh = ob->data; | ||||
| int new_seed = BLI_hash_int(PIL_check_seconds_timer_i() & UINT_MAX); | int new_seed = BLI_hash_int(PIL_check_seconds_timer_i() & UINT_MAX); | ||||
| mesh->face_sets_color_seed = new_seed; | mesh->face_sets_color_seed = new_seed; | ||||
| if (ss->face_sets) { | if (ss->face_sets) { | ||||
| mesh->face_sets_color_default = ss->face_sets[0]; | const int random_index = clamp_i( | ||||
| ss->totpoly * BLI_hash_int_01(new_seed), 0, max_ii(0, ss->totpoly - 1)); | |||||
| mesh->face_sets_color_default = ss->face_sets[random_index]; | |||||
| } | } | ||||
| BKE_pbvh_face_sets_color_set(pbvh, new_seed, mesh->face_sets_color_default); | BKE_pbvh_face_sets_color_set(pbvh, new_seed, mesh->face_sets_color_default); | ||||
| BKE_pbvh_search_gather(pbvh, NULL, NULL, &nodes, &totnode); | BKE_pbvh_search_gather(pbvh, NULL, NULL, &nodes, &totnode); | ||||
| for (int i = 0; i < totnode; i++) { | for (int i = 0; i < totnode; i++) { | ||||
| BKE_pbvh_node_mark_redraw(nodes[i]); | BKE_pbvh_node_mark_redraw(nodes[i]); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 47 Lines • Show Last 20 Lines | |||||