Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/intern/draw_cache_extract_mesh.c
| Show First 20 Lines • Show All 884 Lines • ▼ Show 20 Lines | static void extract_tris_iter_looptri_mesh(const MeshRenderData *mr, | ||||
| EXTRACT_TRIS_LOOPTRI_FOREACH_MESH_END; | EXTRACT_TRIS_LOOPTRI_FOREACH_MESH_END; | ||||
| } | } | ||||
| static void extract_tris_finish(const MeshRenderData *mr, void *ibo, void *_data) | static void extract_tris_finish(const MeshRenderData *mr, void *ibo, void *_data) | ||||
| { | { | ||||
| MeshExtract_Tri_Data *data = _data; | MeshExtract_Tri_Data *data = _data; | ||||
| GPU_indexbuf_build_in_place(&data->elb, ibo); | GPU_indexbuf_build_in_place(&data->elb, ibo); | ||||
| /* HACK: Create ibo sub-ranges and assign them to each #GPUBatch. */ | /* HACK: Create ibo sub-ranges and assign them to each #GPUBatch. */ | ||||
| if (mr->use_final_mesh && mr->cache->surface_per_mat && mr->cache->surface_per_mat[0]) { | if (mr->use_final_mesh) { | ||||
| BLI_assert(mr->cache->surface_per_mat[0]->elem == ibo); | |||||
| for (int i = 0; i < mr->mat_len; i++) { | for (int i = 0; i < mr->mat_len; i++) { | ||||
| /* Multiply by 3 because these are triangle indices. */ | /* Multiply by 3 because these are triangle indices. */ | ||||
| const int start = data->tri_mat_start[i] * 3; | const int mat_start = data->tri_mat_start[i]; | ||||
| const int len = data->tri_mat_end[i] * 3 - data->tri_mat_start[i] * 3; | const int mat_end = data->tri_mat_end[i]; | ||||
| const int start = mat_start * 3; | |||||
| const int len = (mat_end - mat_start) * 3; | |||||
| GPUIndexBuf *sub_ibo = GPU_indexbuf_create_subrange(ibo, start, len); | GPUIndexBuf *sub_ibo = GPU_indexbuf_create_subrange(ibo, start, len); | ||||
| /* WARNING: We modify the #GPUBatch here! */ | /* WARNING: We modify the #GPUBatch here! */ | ||||
| GPU_batch_elembuf_set(mr->cache->surface_per_mat[i], sub_ibo, true); | GPU_batch_elembuf_set(mr->cache->surface_per_mat[i], sub_ibo, true); | ||||
| } | } | ||||
| } | } | ||||
| MEM_freeN(data->tri_mat_start); | MEM_freeN(data->tri_mat_start); | ||||
| MEM_freeN(data->tri_mat_end); | MEM_freeN(data->tri_mat_end); | ||||
| MEM_freeN(data); | MEM_freeN(data); | ||||
| ▲ Show 20 Lines • Show All 4,752 Lines • Show Last 20 Lines | |||||