Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/draw/intern/draw_cache_extract_mesh_extractors.c')
-rw-r--r--source/blender/draw/intern/draw_cache_extract_mesh_extractors.c135
1 files changed, 0 insertions, 135 deletions
diff --git a/source/blender/draw/intern/draw_cache_extract_mesh_extractors.c b/source/blender/draw/intern/draw_cache_extract_mesh_extractors.c
index 1d44f9f911b..a56e22e6132 100644
--- a/source/blender/draw/intern/draw_cache_extract_mesh_extractors.c
+++ b/source/blender/draw/intern/draw_cache_extract_mesh_extractors.c
@@ -105,142 +105,7 @@ const MeshExtract *mesh_extract_override_get(const MeshExtract *extractor,
/** \} */
-/* ---------------------------------------------------------------------- */
-/** \name Extract Triangles Indices
- * \{ */
-
-typedef struct MeshExtract_Tri_Data {
- GPUIndexBufBuilder elb;
- int *tri_mat_start;
- int *tri_mat_end;
-} MeshExtract_Tri_Data;
-
-static void *extract_tris_init(const MeshRenderData *mr,
- struct MeshBatchCache *UNUSED(cache),
- void *UNUSED(ibo))
-{
- MeshExtract_Tri_Data *data = MEM_callocN(sizeof(*data), __func__);
-
- size_t mat_tri_idx_size = sizeof(int) * mr->mat_len;
- data->tri_mat_start = MEM_callocN(mat_tri_idx_size, __func__);
- data->tri_mat_end = MEM_callocN(mat_tri_idx_size, __func__);
- int *mat_tri_len = data->tri_mat_start;
- /* Count how many triangle for each material. */
- if (mr->extract_type == MR_EXTRACT_BMESH) {
- BMIter iter;
- BMFace *efa;
- BM_ITER_MESH (efa, &iter, mr->bm, BM_FACES_OF_MESH) {
- if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) {
- int mat = min_ii(efa->mat_nr, mr->mat_len - 1);
- mat_tri_len[mat] += efa->len - 2;
- }
- }
- }
- else {
- const MPoly *mp = mr->mpoly;
- for (int mp_index = 0; mp_index < mr->poly_len; mp_index++, mp++) {
- if (!(mr->use_hide && (mp->flag & ME_HIDE))) {
- int mat = min_ii(mp->mat_nr, mr->mat_len - 1);
- mat_tri_len[mat] += mp->totloop - 2;
- }
- }
- }
- /* Accumulate triangle lengths per material to have correct offsets. */
- int ofs = mat_tri_len[0];
- mat_tri_len[0] = 0;
- for (int i = 1; i < mr->mat_len; i++) {
- int tmp = mat_tri_len[i];
- mat_tri_len[i] = ofs;
- ofs += tmp;
- }
-
- memcpy(data->tri_mat_end, mat_tri_len, mat_tri_idx_size);
-
- int visible_tri_tot = ofs;
- GPU_indexbuf_init(&data->elb, GPU_PRIM_TRIS, visible_tri_tot, mr->loop_len);
-
- return data;
-}
-
-static void extract_tris_iter_looptri_bm(const MeshRenderData *mr,
- BMLoop **elt,
- const int UNUSED(elt_index),
- void *_data)
-{
- MeshExtract_Tri_Data *data = _data;
- const int mat_last = mr->mat_len - 1;
-
- if (!BM_elem_flag_test(elt[0]->f, BM_ELEM_HIDDEN)) {
- int *mat_tri_ofs = data->tri_mat_end;
- const int mat = min_ii(elt[0]->f->mat_nr, mat_last);
- GPU_indexbuf_set_tri_verts(&data->elb,
- mat_tri_ofs[mat]++,
- BM_elem_index_get(elt[0]),
- BM_elem_index_get(elt[1]),
- BM_elem_index_get(elt[2]));
- }
-}
-
-static void extract_tris_iter_looptri_mesh(const MeshRenderData *mr,
- const MLoopTri *mlt,
- const int UNUSED(elt_index),
- void *_data)
-{
- MeshExtract_Tri_Data *data = _data;
- const int mat_last = mr->mat_len - 1;
- const MPoly *mp = &mr->mpoly[mlt->poly];
- if (!(mr->use_hide && (mp->flag & ME_HIDE))) {
- int *mat_tri_ofs = data->tri_mat_end;
- const int mat = min_ii(mp->mat_nr, mat_last);
- GPU_indexbuf_set_tri_verts(
- &data->elb, mat_tri_ofs[mat]++, mlt->tri[0], mlt->tri[1], mlt->tri[2]);
- }
-}
-
-static void extract_tris_finish(const MeshRenderData *mr,
- struct MeshBatchCache *cache,
- void *buf,
- void *_data)
-{
- GPUIndexBuf *ibo = buf;
- MeshExtract_Tri_Data *data = _data;
- GPU_indexbuf_build_in_place(&data->elb, ibo);
-
- /* Create ibo sub-ranges. Always do this to avoid error when the standard surface batch
- * is created before the surfaces-per-material. */
- if (mr->use_final_mesh && cache->final.tris_per_mat) {
- MeshBufferCache *mbc_final = &cache->final;
- for (int i = 0; i < mr->mat_len; i++) {
- /* These 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_final->tris_per_mat[i] == NULL) {
- mbc_final->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_end = data->tri_mat_end[i];
- const int start = mat_start * 3;
- const int len = (mat_end - mat_start) * 3;
- GPU_indexbuf_create_subrange_in_place(mbc_final->tris_per_mat[i], ibo, start, len);
- }
- }
- MEM_freeN(data->tri_mat_start);
- MEM_freeN(data->tri_mat_end);
- MEM_freeN(data);
-}
-
-const MeshExtract extract_tris = {
- .init = extract_tris_init,
- .iter_looptri_bm = extract_tris_iter_looptri_bm,
- .iter_looptri_mesh = extract_tris_iter_looptri_mesh,
- .finish = extract_tris_finish,
- .data_type = 0,
- .use_threading = false,
- .mesh_buffer_offset = offsetof(MeshBufferCache, ibo.tris),
-};
-
-/** \} */
/* ---------------------------------------------------------------------- */
/** \name Extract Edges Indices