From 18d056601303b96fcc934c639421e1fd59b36b63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Fri, 14 Dec 2018 00:42:16 +0100 Subject: 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. --- source/blender/draw/intern/draw_cache_impl_metaball.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'source/blender/draw/intern/draw_cache_impl_metaball.c') 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; -- cgit v1.2.3