diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2018-12-14 02:42:16 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2018-12-14 18:17:29 +0300 |
commit | 18d056601303b96fcc934c639421e1fd59b36b63 (patch) | |
tree | 672bd9c367be9273d97e3ca124dc51afd76e59ed /source/blender/draw/intern/draw_cache_impl_metaball.c | |
parent | c09913e9ddc2d93894549923a90ee471c3a368db (diff) |
Curve Batch Cache: Add back support for shaded geometry
This changes a bit the batches data structure. Instead of using one
vbo per material we use one for all material and use index buffers for
selecting the correct triangles.
This is less optimized than before but has potential to become more
optimized by merging the wireframe data vbo into the shading one.
Also the index buffers are not strictly necessary and could be just
ranges inside the buffer. But this needs more adding things inside
GPUIndexBuf.
Diffstat (limited to 'source/blender/draw/intern/draw_cache_impl_metaball.c')
-rw-r--r-- | source/blender/draw/intern/draw_cache_impl_metaball.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/source/blender/draw/intern/draw_cache_impl_metaball.c b/source/blender/draw/intern/draw_cache_impl_metaball.c index 304d93f465c..f406ad2380a 100644 --- a/source/blender/draw/intern/draw_cache_impl_metaball.c +++ b/source/blender/draw/intern/draw_cache_impl_metaball.c @@ -143,7 +143,8 @@ static GPUVertBuf *mball_batch_cache_get_pos_and_normals(Object *ob, MetaBallBat { if (cache->pos_nor_in_order == NULL) { ListBase *lb = &ob->runtime.curve_cache->disp; - cache->pos_nor_in_order = DRW_displist_vertbuf_calc_pos_with_normals(lb, NULL); + cache->pos_nor_in_order = MEM_callocN(sizeof(GPUVertBuf), __func__); + DRW_displist_vertbuf_create_pos_and_nor(lb, cache->pos_nor_in_order); } return cache->pos_nor_in_order; } @@ -164,10 +165,12 @@ GPUBatch *DRW_metaball_batch_cache_get_triangles_with_normals(Object *ob) if (cache->batch == NULL) { ListBase *lb = &ob->runtime.curve_cache->disp; + GPUIndexBuf *ibo = MEM_callocN(sizeof(GPUIndexBuf), __func__); + DRW_displist_indexbuf_create_triangles_in_order(lb, ibo); cache->batch = GPU_batch_create_ex( GPU_PRIM_TRIS, mball_batch_cache_get_pos_and_normals(ob, cache), - DRW_displist_indexbuf_calc_triangles_in_order(lb, NULL), + ibo, GPU_BATCH_OWNS_INDEX); } @@ -204,7 +207,9 @@ GPUBatch *DRW_metaball_batch_cache_get_wireframes_face(Object *ob) if (cache->face_wire.batch == NULL) { ListBase *lb = &ob->runtime.curve_cache->disp; - cache->face_wire.batch = DRW_displist_create_edges_overlay_batch(lb, NULL); + GPUVertBuf *vbo = MEM_callocN(sizeof(GPUVertBuf), __func__); + DRW_displist_vertbuf_create_wireframe_data_tess(lb, vbo); + cache->face_wire.batch = GPU_batch_create_ex(GPU_PRIM_TRIS, vbo, NULL, GPU_BATCH_OWNS_VBO); } return cache->face_wire.batch; |