[Bf-blender-cvs] [21081429347] blender2.8: Workbench: use SET_UINT_IN_POINTER for hashes

Jeroen Bakker noreply at git.blender.org
Wed Apr 18 15:17:07 CEST 2018


Commit: 21081429347e274de29040c04c377ddce5d060ef
Author: Jeroen Bakker
Date:   Wed Apr 18 15:16:21 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB21081429347e274de29040c04c377ddce5d060ef

Workbench: use SET_UINT_IN_POINTER for hashes

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

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 4aef21c736f..e9337761231 100644
--- a/source/blender/draw/engines/workbench/workbench_materials.c
+++ b/source/blender/draw/engines/workbench/workbench_materials.c
@@ -51,7 +51,7 @@ static uint get_material_hash(const float color[3]) {
 	uint g = (uint)(color[1] * 512);
 	uint b = (uint)(color[2] * 512);
 	
-	return r + g * 4096 + b * 4096*4096;
+	return r + g * 4096 + b * 4096 * 4096;
 }
 
 WORKBENCH_MaterialData* workbench_get_or_create_solid_flat_material_data(WORKBENCH_Data *vedata, const float color[3]) {
@@ -62,7 +62,7 @@ WORKBENCH_MaterialData* workbench_get_or_create_solid_flat_material_data(WORKBEN
 	uint hash = get_material_hash(color);
 	WORKBENCH_MaterialData *material;
 	
-	material = BLI_ghash_lookup(wpd->material_hash, (void *)hash);
+	material = BLI_ghash_lookup(wpd->material_hash, SET_UINT_IN_POINTER(hash));
 	if (material == NULL) {
 		material = MEM_mallocN(sizeof(WORKBENCH_MaterialData), "WORKBENCH_MaterialData");
 		material->shgrp = DRW_shgroup_create(e_data.solid_flat_sh, psl->solid_pass);
@@ -70,7 +70,7 @@ WORKBENCH_MaterialData* workbench_get_or_create_solid_flat_material_data(WORKBEN
 		material->color[1] = color[1];
 		material->color[2] = color[2];
 		DRW_shgroup_uniform_vec3(material->shgrp, "color", material->color, 1);
-		BLI_ghash_insert(wpd->material_hash, (void *)hash, material);
+		BLI_ghash_insert(wpd->material_hash, SET_UINT_IN_POINTER(hash), material);
 	}
 	return material;
 }
@@ -83,7 +83,7 @@ WORKBENCH_MaterialData* workbench_get_or_create_solid_studio_material_data(WORKB
 	uint hash = get_material_hash(color);
 	WORKBENCH_MaterialData *material;
 	
-	material = BLI_ghash_lookup(wpd->material_hash, (void *)hash);
+	material = BLI_ghash_lookup(wpd->material_hash, SET_UINT_IN_POINTER(hash));
 	if (material == NULL) {
 		material = MEM_mallocN(sizeof(WORKBENCH_MaterialData), "WORKBENCH_MaterialData");
 		material->shgrp = DRW_shgroup_create(e_data.solid_studio_sh, psl->solid_pass);
@@ -91,7 +91,7 @@ WORKBENCH_MaterialData* workbench_get_or_create_solid_studio_material_data(WORKB
 		material->color[1] = color[1];
 		material->color[2] = color[2];
 		DRW_shgroup_uniform_vec3(material->shgrp, "color", material->color, 1);
-		BLI_ghash_insert(wpd->material_hash, (void *)hash, material);
+		BLI_ghash_insert(wpd->material_hash, SET_UINT_IN_POINTER(hash), material);
 	}
 	return material;
 }



More information about the Bf-blender-cvs mailing list