Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPablo Dobarro <pablodp606@gmail.com>2020-03-11 16:12:35 +0300
committerPablo Dobarro <pablodp606@gmail.com>2020-03-12 22:37:49 +0300
commit9dcd6ba3eb7de60aed5a6b44fbc6afcdf687f2b8 (patch)
treea2b7456c73fc74c05aa376fd657cf26f8fe9e432 /source/blender/editors/sculpt_paint/sculpt.c
parent88fd2b1dd5fab444850cb17f545fc860c0e7c88a (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/sculpt.c')
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c4
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);