Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/intern/draw_cache_extract_mesh.c
| Show First 20 Lines • Show All 896 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. */ | /* Create ibo sub-ranges. Always do this to avoid error when the standard surface batch | ||||
| /* The `surface_per_mat` tests are there when object shading type is set to Wire or Bounds. In | * is created before the surfaces-per-material. */ | ||||
| * these cases there isn't a surface per material. */ | if (mr->use_final_mesh && cache->final.tris_per_mat) { | ||||
| if (mr->use_final_mesh && cache->surface_per_mat && cache->surface_per_mat[0]) { | |||||
| MeshBufferCache *mbc = &cache->final; | 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. */ | /* Theses IBOs have not been queried yet but we create them just in case they are needed | ||||
| * later since they are not tracked by mesh_buffer_cache_create_requested(). */ | |||||
| if (mbc->tris_per_mat[i] == NULL) { | |||||
| mbc->tris_per_mat[i] = GPU_indexbuf_calloc(); | |||||
| } /* 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; | ||||
| GPU_indexbuf_create_subrange_in_place(mbc->tris_per_mat[i], ibo, start, len); | GPU_indexbuf_create_subrange_in_place(mbc->tris_per_mat[i], ibo, start, len); | ||||
| } | } | ||||
| } | } | ||||
| MEM_freeN(data->tri_mat_start); | MEM_freeN(data->tri_mat_start); | ||||
| ▲ Show 20 Lines • Show All 4,975 Lines • Show Last 20 Lines | |||||