diff options
author | Pablo Dobarro <pablodp606@gmail.com> | 2020-03-11 16:12:35 +0300 |
---|---|---|
committer | Pablo Dobarro <pablodp606@gmail.com> | 2020-03-12 22:37:49 +0300 |
commit | 9dcd6ba3eb7de60aed5a6b44fbc6afcdf687f2b8 (patch) | |
tree | a2b7456c73fc74c05aa376fd657cf26f8fe9e432 /source/blender/editors/sculpt_paint | |
parent | 88fd2b1dd5fab444850cb17f545fc860c0e7c88a (diff) |
Fix T74646: Pick a random face set to be rendered white when randomizing the colors
The previous solution was also working fine as the white face set has no
meaning, but now it is a little bit more random. Also, bigger face sets
have more chance of getting the white color.
Reviewed By: jbakker
Maniphest Tasks: T74646
Differential Revision: https://developer.blender.org/D7111
Diffstat (limited to 'source/blender/editors/sculpt_paint')
-rw-r--r-- | source/blender/editors/sculpt_paint/sculpt.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 7d929c24795..6cb4844be41 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -11111,7 +11111,9 @@ static int sculpt_face_sets_randomize_colors_invoke(bContext *C, int new_seed = BLI_hash_int(PIL_check_seconds_timer_i() & UINT_MAX); mesh->face_sets_color_seed = new_seed; 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); |