diff options
author | OmarSquircleArt <omar.squircleart@gmail.com> | 2019-08-10 16:18:12 +0300 |
---|---|---|
committer | OmarSquircleArt <omar.squircleart@gmail.com> | 2019-08-10 16:18:12 +0300 |
commit | 67474a7e622957044bc708119a7cfa49a82790fd (patch) | |
tree | 1689263da79f08b1c3c9725ac56c3da8b5d91fbb /source/blender/draw/engines/select/select_draw_utils.c | |
parent | b091542fe91353c15dd7240ba7ce8ecf72d4011b (diff) | |
parent | 553b581f25c1782c4231816965cd3f6ce58a449a (diff) |
Merge master to soc-2019-cycles-procedural.soc-2019-cycles-procedural
Diffstat (limited to 'source/blender/draw/engines/select/select_draw_utils.c')
-rw-r--r-- | source/blender/draw/engines/select/select_draw_utils.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/source/blender/draw/engines/select/select_draw_utils.c b/source/blender/draw/engines/select/select_draw_utils.c index c3615cb5a81..c3ee7f962a1 100644 --- a/source/blender/draw/engines/select/select_draw_utils.c +++ b/source/blender/draw/engines/select/select_draw_utils.c @@ -40,6 +40,37 @@ /** \name Draw Utilities * \{ */ +void draw_select_framebuffer_select_id_setup(struct SELECTID_Context *select_ctx) +{ + DefaultTextureList *dtxl = DRW_viewport_texture_list_get(); + int size[2]; + size[0] = GPU_texture_width(dtxl->depth); + size[1] = GPU_texture_height(dtxl->depth); + + if (select_ctx->framebuffer_select_id == NULL) { + select_ctx->framebuffer_select_id = GPU_framebuffer_create(); + } + + if ((select_ctx->texture_u32 != NULL) && + ((GPU_texture_width(select_ctx->texture_u32) != size[0]) || + (GPU_texture_height(select_ctx->texture_u32) != size[1]))) { + GPU_texture_free(select_ctx->texture_u32); + select_ctx->texture_u32 = NULL; + } + + /* Make sure the depth texture is attached. + * It may disappear when loading another Blender session. */ + GPU_framebuffer_texture_attach(select_ctx->framebuffer_select_id, dtxl->depth, 0, 0); + + if (select_ctx->texture_u32 == NULL) { + select_ctx->texture_u32 = GPU_texture_create_2d(size[0], size[1], GPU_R32UI, NULL, NULL); + GPU_framebuffer_texture_attach( + select_ctx->framebuffer_select_id, select_ctx->texture_u32, 0, 0); + + GPU_framebuffer_check_valid(select_ctx->framebuffer_select_id, NULL); + } +} + short select_id_get_object_select_mode(Scene *scene, Object *ob) { short r_select_mode = 0; @@ -179,6 +210,9 @@ static void draw_select_id_mesh(SELECTID_StorageList *stl, DRW_shgroup_call(vert_shgrp, geom_verts, ob); *r_vert_offset = *r_edge_offset + me->totvert; } + else { + *r_vert_offset = *r_edge_offset; + } } void select_id_draw_object(void *vedata, |