diff options
author | Jeroen Bakker <j.bakker@atmind.nl> | 2018-04-19 11:41:24 +0300 |
---|---|---|
committer | Jeroen Bakker <j.bakker@atmind.nl> | 2018-04-19 11:41:24 +0300 |
commit | 3a4a5ed378d304d3b2ba272201df06eef7c945f9 (patch) | |
tree | 72823c599192922c8b14c3389b35cc8efd8ef7fd /source/blender/draw | |
parent | 79899373eb42895aaba7636dd1819bc89dc7c632 (diff) |
Workbench: added draw_scene_finish to workbench_materials
Diffstat (limited to 'source/blender/draw')
4 files changed, 21 insertions, 19 deletions
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 |