Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/intern/draw_cache_extract_mesh.c
| Show First 20 Lines • Show All 895 Lines • ▼ Show 20 Lines | |||||
| static void extract_tris_finish(const MeshRenderData *mr, | static void extract_tris_finish(const MeshRenderData *mr, | ||||
| struct MeshBatchCache *cache, | struct MeshBatchCache *cache, | ||||
| void *ibo, | void *ibo, | ||||
| void *_data) | 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. */ | ||||
| /* The `surface_per_mat` tests are there when object shading type is set to Wire or Bounds. In | /* The `surface_per_mat` tests are there when object shading type is set to Wire or Bounds. In | ||||
| * these cases there isn't a surface per material. */ | * these cases there isn't a surface per material. */ | ||||
| if (mr->use_final_mesh && cache->surface_per_mat && cache->surface_per_mat[0]) { | if (mr->use_final_mesh && cache->surface_per_mat && cache->surface_per_mat[0]) { | ||||
| MeshBufferCache *mbc = &cache->final; | |||||
| 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 mat_start = data->tri_mat_start[i]; | const int mat_start = data->tri_mat_start[i]; | ||||
| const int mat_end = data->tri_mat_end[i]; | const int mat_end = data->tri_mat_end[i]; | ||||
| const int start = mat_start * 3; | const int start = mat_start * 3; | ||||
| const int len = (mat_end - mat_start) * 3; | const int len = (mat_end - mat_start) * 3; | ||||
| GPUIndexBuf *sub_ibo = GPU_indexbuf_create_subrange(ibo, start, len); | GPU_indexbuf_create_subrange_in_place(mbc->tris_per_mat[i], ibo, start, len); | ||||
| /* WARNING: We modify the #GPUBatch here! */ | |||||
| GPU_batch_elembuf_set(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); | ||||
| } | } | ||||
| static const MeshExtract extract_tris = { | static const MeshExtract extract_tris = { | ||||
| ▲ Show 20 Lines • Show All 4,970 Lines • Show Last 20 Lines | |||||