diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2019-05-04 02:41:39 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2019-05-04 15:11:04 +0300 |
commit | fb3b2ab709bfd3aa1e9a1c9db9d3ce05ed4e6c13 (patch) | |
tree | 5d10c62ae50b03b38fb76e592122d754f766e631 /source/blender/draw/modes/sculpt_mode.c | |
parent | b2f1a6587410d00ad3bbd22e045979f80048afe2 (diff) |
Cleanup: Remove unused code in sculpt_mode, workbench and draw manager
Diffstat (limited to 'source/blender/draw/modes/sculpt_mode.c')
-rw-r--r-- | source/blender/draw/modes/sculpt_mode.c | 106 |
1 files changed, 6 insertions, 100 deletions
diff --git a/source/blender/draw/modes/sculpt_mode.c b/source/blender/draw/modes/sculpt_mode.c index fb2619ce768..053e73e4068 100644 --- a/source/blender/draw/modes/sculpt_mode.c +++ b/source/blender/draw/modes/sculpt_mode.c @@ -90,19 +90,11 @@ typedef struct SCULPT_Data { /* *********** STATIC *********** */ static struct { - /* Custom shaders : - * Add sources to source/blender/draw/modes/shaders - * init in SCULPT_engine_init(); - * free in SCULPT_engine_free(); */ - struct GPUShader *shader_smooth; + struct GPUShader *shader_mask; } e_data = {NULL}; /* Engine data */ typedef struct SCULPT_PrivateData { DRWShadingGroup *mask_overlay_grp; - /* This keeps the references of the shading groups for - * easy access in SCULPT_cache_populate() */ - DRWShadingGroup *group_flat; - DRWShadingGroup *group_smooth; } SCULPT_PrivateData; /* Transient data */ /* *********** FUNCTIONS *********** */ @@ -118,8 +110,8 @@ static void SCULPT_engine_init(void *vedata) UNUSED_VARS(txl, fbl, stl); - if (!e_data.shader_smooth) { - e_data.shader_smooth = DRW_shader_create( + if (!e_data.shader_mask) { + e_data.shader_mask = DRW_shader_create( datatoc_sculpt_mask_vert_glsl, NULL, datatoc_gpu_shader_3D_smooth_color_frag_glsl, NULL); } } @@ -142,50 +134,12 @@ static void SCULPT_cache_init(void *vedata) DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL | DRW_STATE_MULTIPLY; psl->pass = DRW_pass_create("Sculpt Pass", state); - DRWShadingGroup *shgrp = DRW_shgroup_create(e_data.shader_smooth, psl->pass); + DRWShadingGroup *shgrp = DRW_shgroup_create(e_data.shader_mask, psl->pass); DRW_shgroup_uniform_float(shgrp, "maskOpacity", &v3d->overlay.sculpt_mode_mask_opacity, 1); stl->g_data->mask_overlay_grp = shgrp; } } -static void sculpt_draw_mask_cb(DRWShadingGroup *shgroup, - void (*draw_fn)(DRWShadingGroup *shgroup, struct GPUBatch *geom), - void *user_data) -{ - Object *ob = user_data; - PBVH *pbvh = ob->sculpt->pbvh; - - if (pbvh) { - BKE_pbvh_draw_cb(pbvh, - NULL, - NULL, - false, - false, - true, - false, - (void (*)(void *, struct GPUBatch *))draw_fn, - shgroup); - } -} - -static void sculpt_update_pbvh_normals(Object *object) -{ - Mesh *mesh = object->data; - PBVH *pbvh = object->sculpt->pbvh; - SubdivCCG *subdiv_ccg = mesh->runtime.subdiv_ccg; - if (pbvh == NULL || subdiv_ccg == NULL) { - return; - } - BKE_sculpt_bvh_update_from_ccg(pbvh, subdiv_ccg); - struct CCGFace **faces; - int num_faces; - BKE_pbvh_get_grid_updates(pbvh, 1, (void ***)&faces, &num_faces); - if (num_faces > 0) { - BKE_subdiv_ccg_update_normals(subdiv_ccg, faces, num_faces); - MEM_freeN(faces); - } -} - /* Add geometry to shadingGroups. Execute for each objects */ static void SCULPT_cache_populate(void *vedata, Object *ob) { @@ -198,20 +152,6 @@ static void SCULPT_cache_populate(void *vedata, Object *ob) const DRWContextState *draw_ctx = DRW_context_state_get(); if (ob->sculpt && (ob == draw_ctx->obact)) { - sculpt_update_pbvh_normals(ob); - - /* XXX, needed for dyntopo-undo (which clears). - * probably depsgraph should handlle? in 2.7x - * getting derived-mesh does this (mesh_build_data). */ - if (ob->sculpt->pbvh == NULL) { - /* create PBVH immediately (would be created on the fly too, - * but this avoids waiting on first stroke) */ - Scene *scene = draw_ctx->scene; - - BKE_sculpt_update_mesh_elements( - draw_ctx->depsgraph, scene, scene->toolsettings->sculpt, ob, false, false); - } - PBVH *pbvh = ob->sculpt->pbvh; if (pbvh && pbvh_has_mask(pbvh)) { DRW_shgroup_call_sculpt_add(stl->g_data->mask_overlay_grp, ob, false, true, false); @@ -220,50 +160,16 @@ static void SCULPT_cache_populate(void *vedata, Object *ob) } } -/* Optional: Post-cache_populate callback */ -static void SCULPT_cache_finish(void *vedata) -{ - SCULPT_PassList *psl = ((SCULPT_Data *)vedata)->psl; - SCULPT_StorageList *stl = ((SCULPT_Data *)vedata)->stl; - - /* Do something here! dependent on the objects gathered */ - UNUSED_VARS(psl, stl); -} - -/* Draw time ! Control rendering pipeline from here */ static void SCULPT_draw_scene(void *vedata) { SCULPT_PassList *psl = ((SCULPT_Data *)vedata)->psl; - SCULPT_FramebufferList *fbl = ((SCULPT_Data *)vedata)->fbl; - - /* Default framebuffer and texture */ - DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get(); - DefaultTextureList *dtxl = DRW_viewport_texture_list_get(); - - UNUSED_VARS(fbl, dfbl, dtxl); - /* Show / hide entire passes, swap framebuffers ... whatever you fancy */ - /* - * DRW_framebuffer_texture_detach(dtxl->depth); - * DRW_framebuffer_bind(fbl->custom_fb); - * DRW_draw_pass(psl->pass); - * DRW_framebuffer_texture_attach(dfbl->default_fb, dtxl->depth, 0, 0); - * DRW_framebuffer_bind(dfbl->default_fb); - */ - - /* ... or just render passes on default framebuffer. */ DRW_draw_pass(psl->pass); - - /* If you changed framebuffer, double check you rebind - * the default one with its textures attached before finishing */ } -/* Cleanup when destroying the engine. - * This is not per viewport ! only when quitting blender. - * Mostly used for freeing shaders */ static void SCULPT_engine_free(void) { - DRW_SHADER_FREE_SAFE(e_data.shader_smooth); + DRW_SHADER_FREE_SAFE(e_data.shader_mask); } static const DrawEngineDataSize SCULPT_data_size = DRW_VIEWPORT_DATA_SIZE(SCULPT_Data); @@ -277,7 +183,7 @@ DrawEngineType draw_engine_sculpt_type = { &SCULPT_engine_free, &SCULPT_cache_init, &SCULPT_cache_populate, - &SCULPT_cache_finish, + NULL, NULL, /* draw_background but not needed by mode engines */ &SCULPT_draw_scene, NULL, |