Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/intern/draw_cache_impl_displist.c
| Show First 20 Lines • Show All 159 Lines • ▼ Show 20 Lines | else { | ||||
| v_idx += 3; | v_idx += 3; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| return v_idx; | return v_idx; | ||||
| } | } | ||||
| void DRW_displist_vertbuf_create_pos_and_nor_and_wiredata(ListBase *lb, GPUVertBuf *vbo) | void DRW_displist_vertbuf_create_pos_and_nor(ListBase *lb, GPUVertBuf *vbo) | ||||
| { | { | ||||
| static GPUVertFormat format = { 0 }; | static GPUVertFormat format = { 0 }; | ||||
| static struct { uint pos, nor, wd; } attr_id; | static struct { uint pos, nor; } attr_id; | ||||
| if (format.attr_len == 0) { | if (format.attr_len == 0) { | ||||
| /* initialize vertex format */ | /* initialize vertex format */ | ||||
| attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); | attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); | ||||
| attr_id.nor = GPU_vertformat_attr_add(&format, "nor", GPU_COMP_I16, 4, GPU_FETCH_INT_TO_FLOAT_UNIT); | attr_id.nor = GPU_vertformat_attr_add(&format, "nor", GPU_COMP_I10, 4, GPU_FETCH_INT_TO_FLOAT_UNIT); | ||||
| attr_id.wd = GPU_vertformat_attr_add(&format, "wd", GPU_COMP_U8, 1, GPU_FETCH_INT_TO_FLOAT_UNIT); | |||||
| } | } | ||||
| GPU_vertbuf_init_with_format(vbo, &format); | GPU_vertbuf_init_with_format(vbo, &format); | ||||
| GPU_vertbuf_data_alloc(vbo, curve_render_surface_vert_len_get(lb)); | GPU_vertbuf_data_alloc(vbo, curve_render_surface_vert_len_get(lb)); | ||||
| BKE_displist_normals_add(lb); | BKE_displist_normals_add(lb); | ||||
| int vbo_len_used = 0; | int vbo_len_used = 0; | ||||
| for (const DispList *dl = lb->first; dl; dl = dl->next) { | for (const DispList *dl = lb->first; dl; dl = dl->next) { | ||||
| const bool ndata_is_single = dl->type == DL_INDEX3; | const bool ndata_is_single = dl->type == DL_INDEX3; | ||||
| if (ELEM(dl->type, DL_INDEX3, DL_INDEX4, DL_SURF)) { | if (ELEM(dl->type, DL_INDEX3, DL_INDEX4, DL_SURF)) { | ||||
| const float *fp_co = dl->verts; | const float *fp_co = dl->verts; | ||||
| const float *fp_no = dl->nors; | const float *fp_no = dl->nors; | ||||
| const int vbo_end = vbo_len_used + dl_vert_len(dl); | const int vbo_end = vbo_len_used + dl_vert_len(dl); | ||||
| while (vbo_len_used < vbo_end) { | while (vbo_len_used < vbo_end) { | ||||
| uchar sharpness = 0xFF; | |||||
| GPU_vertbuf_attr_set(vbo, attr_id.wd, vbo_len_used, &sharpness); | |||||
| GPU_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used, fp_co); | GPU_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used, fp_co); | ||||
| if (fp_no) { | if (fp_no) { | ||||
| static short short_no[4]; | GPUPackedNormal vnor_pack = GPU_normal_convert_i10_v3(fp_no); | ||||
| normal_float_to_short_v3(short_no, fp_no); | GPU_vertbuf_attr_set(vbo, attr_id.nor, vbo_len_used, &vnor_pack); | ||||
| GPU_vertbuf_attr_set(vbo, attr_id.nor, vbo_len_used, short_no); | |||||
| if (ndata_is_single == false) { | if (ndata_is_single == false) { | ||||
| fp_no += 3; | fp_no += 3; | ||||
| } | } | ||||
| } | } | ||||
| fp_co += 3; | fp_co += 3; | ||||
| vbo_len_used += 1; | vbo_len_used += 1; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| void DRW_displist_vertbuf_create_wiredata(ListBase *lb, GPUVertBuf *vbo) | |||||
| { | |||||
| static GPUVertFormat format = { 0 }; | |||||
| static struct { uint wd; } attr_id; | |||||
| if (format.attr_len == 0) { | |||||
| /* initialize vertex format */ | |||||
| attr_id.wd = GPU_vertformat_attr_add(&format, "wd", GPU_COMP_U8, 1, GPU_FETCH_INT_TO_FLOAT_UNIT); | |||||
| } | |||||
| int vbo_len_used = curve_render_surface_vert_len_get(lb); | |||||
| GPU_vertbuf_init_with_format(vbo, &format); | |||||
| GPU_vertbuf_data_alloc(vbo, vbo_len_used); | |||||
| memset(vbo->data, 0xFF, (size_t)(vbo_len_used * format.stride)); | |||||
| } | |||||
| void DRW_displist_indexbuf_create_triangles_in_order(ListBase *lb, GPUIndexBuf *ibo) | void DRW_displist_indexbuf_create_triangles_in_order(ListBase *lb, GPUIndexBuf *ibo) | ||||
| { | { | ||||
| const int tri_len = curve_render_surface_tri_len_get(lb); | const int tri_len = curve_render_surface_tri_len_get(lb); | ||||
| const int vert_len = curve_render_surface_vert_len_get(lb); | const int vert_len = curve_render_surface_vert_len_get(lb); | ||||
| GPUIndexBufBuilder elb; | GPUIndexBufBuilder elb; | ||||
| GPU_indexbuf_init(&elb, GPU_PRIM_TRIS, tri_len, vert_len); | GPU_indexbuf_init(&elb, GPU_PRIM_TRIS, tri_len, vert_len); | ||||
| ▲ Show 20 Lines • Show All 317 Lines • Show Last 20 Lines | |||||