diff options
author | Jeroen Bakker <j.bakker@atmind.nl> | 2018-06-11 09:37:56 +0300 |
---|---|---|
committer | Jeroen Bakker <j.bakker@atmind.nl> | 2018-06-11 12:52:41 +0300 |
commit | a67cc72232ae71f7c58e5aa88fc919f53fa72433 (patch) | |
tree | cee8a52227cef145e335c40dd7fc6315bbfb34eb /source/blender/draw/engines/workbench/workbench_forward.c | |
parent | 5aa8d981ec9e6d3b443d31f8e26986d364e50244 (diff) |
MetaBall support for Workbench + EEVEE
Note: Metaballs only support the first material slot. Splicing it per
material would create empty Batches. In order to overcome this we set
the batch for other materials to NULL. We added extra checks in EEVEE
and Workbench to not draw when the geom is NULL.
Diffstat (limited to 'source/blender/draw/engines/workbench/workbench_forward.c')
-rw-r--r-- | source/blender/draw/engines/workbench/workbench_forward.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/source/blender/draw/engines/workbench/workbench_forward.c b/source/blender/draw/engines/workbench/workbench_forward.c index 2c2cde5ca20..1a387c8087c 100644 --- a/source/blender/draw/engines/workbench/workbench_forward.c +++ b/source/blender/draw/engines/workbench/workbench_forward.c @@ -461,14 +461,14 @@ void workbench_forward_cache_populate(WORKBENCH_Data *vedata, Object *ob) return; } - if (ELEM(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT)) { + if (ELEM(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_MBALL)) { const DRWContextState *draw_ctx = DRW_context_state_get(); const bool is_active = (ob == draw_ctx->obact); const bool is_sculpt_mode = is_active && (draw_ctx->object_mode & OB_MODE_SCULPT) != 0; bool is_drawn = false; WORKBENCH_MaterialData *material = get_or_create_material_data(vedata, ob, NULL, NULL, OB_SOLID); - if (!is_sculpt_mode && wpd->drawtype == OB_TEXTURE && ob->type == OB_MESH) { + if (!is_sculpt_mode && wpd->drawtype == OB_TEXTURE && ELEM(ob->type, OB_MESH)) { const Mesh *me = ob->data; if (me->mloopuv) { const int materials_len = MAX2(1, (is_sculpt_mode ? 1 : ob->totcol)); @@ -476,6 +476,10 @@ void workbench_forward_cache_populate(WORKBENCH_Data *vedata, Object *ob) struct Gwn_Batch **geom_array = me->totcol ? DRW_cache_mesh_surface_texpaint_get(ob) : NULL; if (materials_len > 0 && geom_array) { for (int i = 0; i < materials_len; i++) { + if(geom_array[i] == NULL) { + continue; + } + Material *mat = give_current_material(ob, i + 1); Image *image; ED_object_get_active_image(ob, i + 1, &image, NULL, NULL, NULL); @@ -520,6 +524,10 @@ void workbench_forward_cache_populate(WORKBENCH_Data *vedata, Object *ob) ob, gpumat_array, materials_len, NULL, NULL, NULL); if (mat_geom) { for (int i = 0; i < materials_len; ++i) { + if(mat_geom[i] == NULL) { + continue; + } + Material *mat = give_current_material(ob, i + 1); material = get_or_create_material_data(vedata, ob, mat, NULL, OB_SOLID); DRW_shgroup_call_object_add(material->shgrp_object_outline, mat_geom[i], ob); |