Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/intern/draw_cache_impl_displist.c
| Show First 20 Lines • Show All 130 Lines • ▼ Show 20 Lines | Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); | ||||
| } | } | ||||
| } | } | ||||
| { | { | ||||
| Gwn_IndexBufBuilder elb; | Gwn_IndexBufBuilder elb; | ||||
| GWN_indexbuf_init(&elb, GWN_PRIM_TRIS, tri_len, vert_len); | GWN_indexbuf_init(&elb, GWN_PRIM_TRIS, tri_len, vert_len); | ||||
| int ofs = 0; | int ofs = 0; | ||||
| int tri_len_used = 0; | |||||
| for (const DispList *dl = lb->first; dl; dl = dl->next) { | for (const DispList *dl = lb->first; dl; dl = dl->next) { | ||||
| if (ELEM(dl->type, DL_INDEX3, DL_INDEX4, DL_SURF)) { | if (ELEM(dl->type, DL_INDEX3, DL_INDEX4, DL_SURF)) { | ||||
| if (dl->type == DL_INDEX3) { | |||||
| const int *idx = dl->index; | const int *idx = dl->index; | ||||
| if (dl->type == DL_INDEX3) { | |||||
| const int i_end = dl->parts; | const int i_end = dl->parts; | ||||
| for (int i = 0; i < i_end; i++) { | for (int i = 0; i < i_end; i++, idx += 3) { | ||||
| GWN_indexbuf_add_tri_verts(&elb, idx[0] + ofs, idx[1] + ofs, idx[2] + ofs); | GWN_indexbuf_add_tri_verts(&elb, idx[0] + ofs, idx[1] + ofs, idx[2] + ofs); | ||||
| tri_len_used += 1; | |||||
| idx += 3; | |||||
| } | } | ||||
| } | } | ||||
| else if (ELEM(dl->type, DL_INDEX4, DL_SURF)) { | else if (dl->type == DL_SURF) { | ||||
| const int *idx = dl->index; | |||||
| const int i_end = dl->totindex; | const int i_end = dl->totindex; | ||||
| for (int i = 0; i < i_end; i++) { | for (int i = 0; i < i_end; i++, idx += 4) { | ||||
| GWN_indexbuf_add_tri_verts(&elb, idx[0] + ofs, idx[1] + ofs, idx[2] + ofs); | |||||
| GWN_indexbuf_add_tri_verts(&elb, idx[0] + ofs, idx[2] + ofs, idx[3] + ofs); | |||||
| } | |||||
| } | |||||
| else { | |||||
| BLI_assert(dl->type == DL_INDEX4); | |||||
| const int i_end = dl->parts; | |||||
| for (int i = 0; i < i_end; i++, idx += 4) { | |||||
campbellbarton: Better change this comment into a BLI_assert | |||||
| GWN_indexbuf_add_tri_verts(&elb, idx[0] + ofs, idx[1] + ofs, idx[2] + ofs); | GWN_indexbuf_add_tri_verts(&elb, idx[0] + ofs, idx[1] + ofs, idx[2] + ofs); | ||||
| tri_len_used += 1; | |||||
| if (idx[2] != idx[3]) { | |||||
| GWN_indexbuf_add_tri_verts(&elb, idx[0] + ofs, idx[2] + ofs, idx[3] + ofs); | GWN_indexbuf_add_tri_verts(&elb, idx[0] + ofs, idx[2] + ofs, idx[3] + ofs); | ||||
| tri_len_used += 1; | } | ||||
| idx += 4; | |||||
| } | } | ||||
| } | } | ||||
| ofs += dl_vert_len(dl); | ofs += dl_vert_len(dl); | ||||
| } | } | ||||
| } | } | ||||
| return GWN_batch_create_ex( | return GWN_batch_create_ex( | ||||
| GWN_PRIM_TRIS, vbo, GWN_indexbuf_build(&elb), | GWN_PRIM_TRIS, vbo, GWN_indexbuf_build(&elb), | ||||
| GWN_BATCH_OWNS_VBO | GWN_BATCH_OWNS_INDEX); | GWN_BATCH_OWNS_VBO | GWN_BATCH_OWNS_INDEX); | ||||
| } | } | ||||
| } | } | ||||
Better change this comment into a BLI_assert