Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGermano <germano.costa@ig.com.br>2017-12-14 19:31:08 +0300
committerGermano <germano.costa@ig.com.br>2017-12-14 19:31:08 +0300
commit6b794565aa0658bafff40491cad05c01d1d65000 (patch)
tree747ecb2f6a784ba832e31a7c39361ed0f16499cc
parent14ac709455065062134b21cf573fcfc99830da42 (diff)
Fix crash with DispLists without vertices
Wee must return VertBuffers even when its size is zero
-rw-r--r--source/blender/draw/intern/draw_cache_impl_curve.c15
-rw-r--r--source/blender/draw/intern/draw_cache_impl_displist.c14
-rw-r--r--source/blender/draw/intern/draw_cache_impl_metaball.c12
3 files changed, 15 insertions, 26 deletions
diff --git a/source/blender/draw/intern/draw_cache_impl_curve.c b/source/blender/draw/intern/draw_cache_impl_curve.c
index 8e38e22a210..42533cc2802 100644
--- a/source/blender/draw/intern/draw_cache_impl_curve.c
+++ b/source/blender/draw/intern/draw_cache_impl_curve.c
@@ -813,13 +813,11 @@ static Gwn_Batch *curve_batch_cache_get_pos_and_normals(CurveRenderData *rdata,
if (cache->surface.verts == NULL) {
cache->surface.verts = DRW_displist_vertbuf_calc_pos_with_normals(lb);
}
- if (cache->surface.verts) {
- if (cache->surface.triangles_in_order == NULL) {
- cache->surface.triangles_in_order = DRW_displist_indexbuf_calc_triangles_in_order(lb);
- }
- cache->surface.batch = GWN_batch_create_ex(
- GWN_PRIM_TRIS, cache->surface.verts, cache->surface.triangles_in_order, 0);
+ if (cache->surface.triangles_in_order == NULL) {
+ cache->surface.triangles_in_order = DRW_displist_indexbuf_calc_triangles_in_order(lb);
}
+ cache->surface.batch = GWN_batch_create_ex(
+ GWN_PRIM_TRIS, cache->surface.verts, cache->surface.triangles_in_order, 0);
}
return cache->surface.batch;
@@ -1051,8 +1049,9 @@ Gwn_Batch **DRW_curve_batch_cache_get_surface_shaded(
}
for (int i = 0; i < gpumat_array_len; ++i) {
- cache->surface.shaded_triangles[i] = GWN_batch_create(
- GWN_PRIM_TRIS, cache->surface.verts, el[i]);
+ cache->surface.shaded_triangles[i] = GWN_batch_create_ex(
+ GWN_PRIM_TRIS, cache->surface.verts, el[i], GWN_BATCH_OWNS_INDEX);
+
/* TODO: Add vertbuff for UV */
}
diff --git a/source/blender/draw/intern/draw_cache_impl_displist.c b/source/blender/draw/intern/draw_cache_impl_displist.c
index 87ff52c951c..33c4a938a56 100644
--- a/source/blender/draw/intern/draw_cache_impl_displist.c
+++ b/source/blender/draw/intern/draw_cache_impl_displist.c
@@ -121,9 +121,6 @@ static void displist_indexbufbuilder_set(Gwn_IndexBufBuilder *elb, const DispLis
Gwn_VertBuf *DRW_displist_vertbuf_calc_pos_with_normals(ListBase *lb)
{
const int tri_len = curve_render_surface_tri_len_get(lb);
- if (tri_len == 0) {
- return NULL;
- }
static Gwn_VertFormat format = { 0 };
static struct { uint pos, nor; } attr_id;
@@ -191,16 +188,11 @@ Gwn_IndexBuf *DRW_displist_indexbuf_calc_triangles_in_order(ListBase *lb)
Gwn_IndexBuf **DRW_displist_indexbuf_calc_triangles_in_order_split_by_material(ListBase *lb, uint gpumat_array_len)
{
- const int tri_len = curve_render_surface_tri_len_get(lb);
- if (tri_len == 0) {
- return NULL;
- }
-
- const int vert_len = curve_render_surface_vert_len_get(lb);
-
Gwn_IndexBuf **shaded_triangles_in_order = MEM_callocN(sizeof(*shaded_triangles_in_order) * gpumat_array_len, __func__);
+ const int tri_len = curve_render_surface_tri_len_get(lb);
- {
+ if (tri_len != 0) {
+ const int vert_len = curve_render_surface_vert_len_get(lb);
int i;
Gwn_IndexBufBuilder *elb = BLI_array_alloca(elb, gpumat_array_len);
diff --git a/source/blender/draw/intern/draw_cache_impl_metaball.c b/source/blender/draw/intern/draw_cache_impl_metaball.c
index 762564cc2a5..9a9bbbd2c0c 100644
--- a/source/blender/draw/intern/draw_cache_impl_metaball.c
+++ b/source/blender/draw/intern/draw_cache_impl_metaball.c
@@ -134,13 +134,11 @@ Gwn_Batch *DRW_metaball_batch_cache_get_triangles_with_normals(Object *ob)
if (cache->batch == NULL) {
ListBase *lb = &ob->curve_cache->disp;
Gwn_VertBuf *verts = DRW_displist_vertbuf_calc_pos_with_normals(lb);
- if (verts) {
- cache->batch = GWN_batch_create_ex(
- GWN_PRIM_TRIS,
- verts,
- DRW_displist_indexbuf_calc_triangles_in_order(lb),
- GWN_BATCH_OWNS_VBO | GWN_BATCH_OWNS_INDEX);
- }
+ cache->batch = GWN_batch_create_ex(
+ GWN_PRIM_TRIS,
+ verts,
+ DRW_displist_indexbuf_calc_triangles_in_order(lb),
+ GWN_BATCH_OWNS_VBO | GWN_BATCH_OWNS_INDEX);
}
return cache->batch;