[Bf-blender-cvs] [3a4a5ed378d] blender2.8: Workbench: added draw_scene_finish to workbench_materials

Jeroen Bakker noreply at git.blender.org
Thu Apr 19 10:42:12 CEST 2018


Commit: 3a4a5ed378d304d3b2ba272201df06eef7c945f9
Author: Jeroen Bakker
Date:   Thu Apr 19 10:41:24 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB3a4a5ed378d304d3b2ba272201df06eef7c945f9

Workbench: added draw_scene_finish to workbench_materials

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

M	source/blender/draw/engines/workbench/solid_flat_mode.c
M	source/blender/draw/engines/workbench/solid_studio_mode.c
M	source/blender/draw/engines/workbench/workbench_materials.c
M	source/blender/draw/engines/workbench/workbench_private.h

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

diff --git a/source/blender/draw/engines/workbench/solid_flat_mode.c b/source/blender/draw/engines/workbench/solid_flat_mode.c
index 1d8eb3b4362..91557832388 100644
--- a/source/blender/draw/engines/workbench/solid_flat_mode.c
+++ b/source/blender/draw/engines/workbench/solid_flat_mode.c
@@ -71,9 +71,8 @@ static void workbench_solid_flat_cache_populate(void *vedata, Object *ob)
 	workbench_materials_solid_cache_populate(data, ob, V3D_LIGHTING_FLAT);
 }
 
-static void workbench_solid_flat_cache_finish(void *vedata)
+static void workbench_solid_flat_cache_finish(void *UNUSED(vedata))
 {
-	workbench_materials_cache_finish((WORKBENCH_Data *)vedata);
 }
 
 static void workbench_solid_flat_draw_scene(void *vedata)
@@ -83,11 +82,13 @@ static void workbench_solid_flat_draw_scene(void *vedata)
 
 	DRW_draw_pass(psl->depth_pass);
 	DRW_draw_pass(psl->solid_pass);
+	
+	workbench_materials_draw_scene_finish(data);
 }
 
 static void workbench_solid_flat_engine_free(void)
 {
-	workbench_materials_engine_finish();
+	workbench_materials_engine_free();
 }
 
 static const DrawEngineDataSize workbench_data_size = DRW_VIEWPORT_DATA_SIZE(WORKBENCH_Data);
diff --git a/source/blender/draw/engines/workbench/solid_studio_mode.c b/source/blender/draw/engines/workbench/solid_studio_mode.c
index 35426e84808..37a6f1dd4fd 100644
--- a/source/blender/draw/engines/workbench/solid_studio_mode.c
+++ b/source/blender/draw/engines/workbench/solid_studio_mode.c
@@ -83,12 +83,12 @@ static void workbench_solid_studio_draw_scene(void *vedata)
 	DRW_draw_pass(psl->depth_pass);
 	DRW_draw_pass(psl->solid_pass);
 
-	workbench_materials_cache_finish((WORKBENCH_Data *)vedata);
+	workbench_materials_draw_scene_finish(data);
 }
 
 static void workbench_solid_studio_engine_free(void)
 {
-	workbench_materials_engine_finish();
+	workbench_materials_engine_free();
 }
 
 static const DrawEngineDataSize workbench_data_size = DRW_VIEWPORT_DATA_SIZE(WORKBENCH_Data);
@@ -108,3 +108,4 @@ DrawEngineType draw_engine_workbench_solid_studio = {
 	NULL,
 	NULL,
 };
+
diff --git a/source/blender/draw/engines/workbench/workbench_materials.c b/source/blender/draw/engines/workbench/workbench_materials.c
index c6625be6f36..1c80d9c3354 100644
--- a/source/blender/draw/engines/workbench/workbench_materials.c
+++ b/source/blender/draw/engines/workbench/workbench_materials.c
@@ -82,12 +82,22 @@ void workbench_materials_engine_init(void)
 	}
 }
 
-void workbench_materials_engine_finish(void)
+void workbench_materials_engine_free()
 {
 	DRW_SHADER_FREE_SAFE(e_data.solid_flat_sh);
 	DRW_SHADER_FREE_SAFE(e_data.solid_studio_sh);
+
+}
+
+void workbench_materials_draw_scene_finish(WORKBENCH_Data *vedata)
+{
+	WORKBENCH_StorageList *stl = vedata->stl;
+	WORKBENCH_PrivateData *wpd = stl->g_data;
+
+	BLI_ghash_free(wpd->material_hash, NULL, MEM_freeN);
 }
 
+
 void workbench_materials_cache_init(WORKBENCH_Data *vedata)
 {
 	WORKBENCH_StorageList *stl = vedata->stl;
@@ -123,9 +133,7 @@ void workbench_materials_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob
 		if (material == NULL) {
 			material = MEM_mallocN(sizeof(WORKBENCH_MaterialData), "WORKBENCH_MaterialData");
 			material->shgrp = DRW_shgroup_create(shader, psl->solid_pass);
-			material->color[0] = color[0];
-			material->color[1] = color[1];
-			material->color[2] = color[2];
+			copy_v3_v3(material->color, color);
 			DRW_shgroup_uniform_vec3(material->shgrp, "color", material->color, 1);
 			BLI_ghash_insert(wpd->material_hash, SET_UINT_IN_POINTER(hash), material);
 		}
@@ -134,10 +142,3 @@ void workbench_materials_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob
 	}
 
 }
-
-void workbench_materials_cache_finish(WORKBENCH_Data *vedata)
-{
-	WORKBENCH_StorageList *stl = vedata->stl;
-	WORKBENCH_PrivateData *wpd = stl->g_data;
-	BLI_ghash_free(wpd->material_hash, NULL, MEM_freeN);
-}
diff --git a/source/blender/draw/engines/workbench/workbench_private.h b/source/blender/draw/engines/workbench/workbench_private.h
index f6702a9f511..fe0180e3f79 100644
--- a/source/blender/draw/engines/workbench/workbench_private.h
+++ b/source/blender/draw/engines/workbench/workbench_private.h
@@ -77,10 +77,9 @@ void workbench_solid_materials_free(void);
 
 /* workbench_materials.c */
 void workbench_materials_engine_init(void);
-void workbench_materials_engine_finish(void);
+void workbench_materials_engine_free(void);
+void workbench_materials_draw_scene_finish(WORKBENCH_Data *vedata);
 void workbench_materials_cache_init(WORKBENCH_Data *vedata);
 void workbench_materials_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob, int lighting_mode);
-void workbench_materials_cache_finish(WORKBENCH_Data *vedata);
-
 
 #endif



More information about the Bf-blender-cvs mailing list