Fix crash with DispLists without vertices
Wee must return VertBuffers even when its size is zero
This commit is contained in:
@@ -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 */
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user