[Bf-blender-cvs] [5166132708a] blender2.8: Fix random color drawing having similar colors for similar names.

Brecht Van Lommel noreply at git.blender.org
Sat Nov 24 20:08:12 CET 2018


Commit: 5166132708a42ce57ac83a6e5f85fe4190dba312
Author: Brecht Van Lommel
Date:   Sat Nov 24 18:37:21 2018 +0100
Branches: blender2.8
https://developer.blender.org/rB5166132708a42ce57ac83a6e5f85fe4190dba312

Fix random color drawing having similar colors for similar names.

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

M	source/blender/draw/engines/workbench/workbench_materials.c

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

diff --git a/source/blender/draw/engines/workbench/workbench_materials.c b/source/blender/draw/engines/workbench/workbench_materials.c
index 572a26c86bd..2faa9e288f8 100644
--- a/source/blender/draw/engines/workbench/workbench_materials.c
+++ b/source/blender/draw/engines/workbench/workbench_materials.c
@@ -5,6 +5,7 @@
 #include "BIF_gl.h"
 
 #include "BLI_dynstr.h"
+#include "BLI_hash.h"
 
 #define HSV_SATURATION 0.5
 #define HSV_VALUE 0.9
@@ -27,9 +28,9 @@ void workbench_material_update_data(WORKBENCH_PrivateData *wpd, Object *ob, Mate
 		if (ob->id.lib) {
 			hash = (hash * 13) ^ BLI_ghashutil_strhash_p_murmur(ob->id.lib->name);
 		}
-		float offset = fmodf((hash / 100000.0) * M_GOLDEN_RATION_CONJUGATE, 1.0);
 
-		float hsv[3] = {offset, HSV_SATURATION, HSV_VALUE};
+		float hue = BLI_hash_int_01(hash);
+		float hsv[3] = {hue, HSV_SATURATION, HSV_VALUE};
 		hsv_to_rgb_v(hsv, data->diffuse_color);
 	}
 	else {



More information about the Bf-blender-cvs mailing list