[Bf-blender-cvs] [9dcd6ba3eb7] master: Fix T74646: Pick a random face set to be rendered white when randomizing the colors

Pablo Dobarro noreply at git.blender.org
Thu Mar 12 20:38:14 CET 2020


Commit: 9dcd6ba3eb7de60aed5a6b44fbc6afcdf687f2b8
Author: Pablo Dobarro
Date:   Wed Mar 11 14:12:35 2020 +0100
Branches: master
https://developer.blender.org/rB9dcd6ba3eb7de60aed5a6b44fbc6afcdf687f2b8

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

===================================================================

M	source/blender/editors/sculpt_paint/sculpt.c

===================================================================

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);



More information about the Bf-blender-cvs mailing list