diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2018-12-17 13:37:27 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2018-12-17 19:05:57 +0300 |
commit | 7ac49a07c60111fe75805a5eb72824ab7d0bc777 (patch) | |
tree | 719fac8f3a2453d23d198a151e99a4e105d616e1 /source/blender/draw/modes/paint_texture_mode.c | |
parent | 9bb70e59b89423070c065f6b120b563bad47113b (diff) |
Mesh Batch Cache: Port Texture paint batches to new batch request
Diffstat (limited to 'source/blender/draw/modes/paint_texture_mode.c')
-rw-r--r-- | source/blender/draw/modes/paint_texture_mode.c | 37 |
1 files changed, 14 insertions, 23 deletions
diff --git a/source/blender/draw/modes/paint_texture_mode.c b/source/blender/draw/modes/paint_texture_mode.c index f22fa4d8721..8e78d2f03b4 100644 --- a/source/blender/draw/modes/paint_texture_mode.c +++ b/source/blender/draw/modes/paint_texture_mode.c @@ -295,40 +295,31 @@ static void PAINT_TEXTURE_cache_populate(void *vedata, Object *ob) const bool use_surface = draw_ctx->v3d->overlay.texture_paint_mode_opacity != 0.0; //DRW_object_is_mode_shade(ob) == true; const bool use_material_slots = (scene->toolsettings->imapaint.mode == IMAGEPAINT_MODE_MATERIAL); const bool use_face_sel = (me_orig->editflag & ME_EDIT_PAINT_FACE_SEL) != 0; - bool ok = false; if (use_surface) { if (me->mloopuv != NULL) { - if (use_material_slots || use_face_sel) { - struct GPUBatch **geom_array = me->totcol ? DRW_cache_mesh_surface_texpaint_get(ob) : NULL; - if ((me->totcol == 0) || (geom_array == NULL)) { - struct GPUBatch *geom = DRW_cache_mesh_surface_get(ob); - DRW_shgroup_call_add(stl->g_data->shgroup_fallback, geom, ob->obmat); - ok = true; - } - else { - for (int i = 0; i < me->totcol; i++) { - const int index = use_material_slots ? i : 0; - if (stl->g_data->shgroup_image_array[index]) { - DRW_shgroup_call_add(stl->g_data->shgroup_image_array[index], geom_array[i], ob->obmat); - } - else { - DRW_shgroup_call_add(stl->g_data->shgroup_fallback, geom_array[i], ob->obmat); - } - ok = true; + if (use_material_slots) { + int mat_nr = max_ii(1, me->totcol); + struct GPUBatch **geom_array = DRW_cache_mesh_surface_texpaint_get(ob); + + for (int i = 0; i < mat_nr; i++) { + const int index = use_material_slots ? i : 0; + if (stl->g_data->shgroup_image_array[index]) { + DRW_shgroup_call_add(stl->g_data->shgroup_image_array[index], geom_array[i], ob->obmat); + } + else { + DRW_shgroup_call_add(stl->g_data->shgroup_fallback, geom_array[i], ob->obmat); } } } else { - struct GPUBatch *geom = DRW_cache_mesh_surface_texpaint_single_get(ob); - if (geom && stl->g_data->shgroup_image_array[0]) { + if (stl->g_data->shgroup_image_array[0]) { + struct GPUBatch *geom = DRW_cache_mesh_surface_texpaint_single_get(ob); DRW_shgroup_call_add(stl->g_data->shgroup_image_array[0], geom, ob->obmat); - ok = true; } } } - - if (!ok) { + else { struct GPUBatch *geom = DRW_cache_mesh_surface_get(ob); DRW_shgroup_call_add(stl->g_data->shgroup_fallback, geom, ob->obmat); } |