Blender  V3.3
extract_mesh_ibo_fdots.cc
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2021 Blender Foundation. All rights reserved. */
3 
8 #include "BLI_bitmap.h"
9 
10 #include "extract_mesh.hh"
11 
12 namespace blender::draw {
13 /* ---------------------------------------------------------------------- */
17 static void extract_fdots_init(const MeshRenderData *mr,
18  MeshBatchCache *UNUSED(cache),
19  void *UNUSED(buf),
20  void *tls_data)
21 {
22  GPUIndexBufBuilder *elb = static_cast<GPUIndexBufBuilder *>(tls_data);
24 }
25 
27  const BMFace *f,
28  const int f_index,
29  void *_userdata)
30 {
31  GPUIndexBufBuilder *elb = static_cast<GPUIndexBufBuilder *>(_userdata);
33  GPU_indexbuf_set_point_vert(elb, f_index, f_index);
34  }
35  else {
36  GPU_indexbuf_set_point_restart(elb, f_index);
37  }
38 }
39 
41  const MPoly *mp,
42  const int mp_index,
43  void *_userdata)
44 {
45  GPUIndexBufBuilder *elb = static_cast<GPUIndexBufBuilder *>(_userdata);
46  if (mr->use_subsurf_fdots) {
47  const BLI_bitmap *facedot_tags = mr->me->runtime.subsurf_face_dot_tags;
48 
49  const MLoop *mloop = mr->mloop;
50  const int ml_index_end = mp->loopstart + mp->totloop;
51  for (int ml_index = mp->loopstart; ml_index < ml_index_end; ml_index += 1) {
52  const MLoop *ml = &mloop[ml_index];
53  if (BLI_BITMAP_TEST(facedot_tags, ml->v) && !(mr->use_hide && (mp->flag & ME_HIDE))) {
54  GPU_indexbuf_set_point_vert(elb, mp_index, mp_index);
55  return;
56  }
57  }
58  GPU_indexbuf_set_point_restart(elb, mp_index);
59  }
60  else {
61  if (!(mr->use_hide && (mp->flag & ME_HIDE))) {
62  GPU_indexbuf_set_point_vert(elb, mp_index, mp_index);
63  }
64  else {
65  GPU_indexbuf_set_point_restart(elb, mp_index);
66  }
67  }
68 }
69 
71  MeshBatchCache *UNUSED(cache),
72  void *buf,
73  void *_userdata)
74 {
75  GPUIndexBufBuilder *elb = static_cast<GPUIndexBufBuilder *>(_userdata);
76  GPUIndexBuf *ibo = static_cast<GPUIndexBuf *>(buf);
78 }
79 
81 {
82  MeshExtract extractor = {nullptr};
83  extractor.init = extract_fdots_init;
86  extractor.finish = extract_fdots_finish;
87  extractor.data_type = MR_DATA_NONE;
88  extractor.data_size = sizeof(GPUIndexBufBuilder);
89  extractor.use_threading = false;
90  extractor.mesh_buffer_offset = offsetof(MeshBufferList, ibo.fdots);
91  return extractor;
92 }
93 
96 } // namespace blender::draw
97 
#define BLI_BITMAP_TEST(_bitmap, _index)
Definition: BLI_bitmap.h:64
unsigned int BLI_bitmap
Definition: BLI_bitmap.h:16
#define UNUSED(x)
@ ME_HIDE
struct GPUIndexBufBuilder GPUIndexBufBuilder
struct GPUIndexBuf GPUIndexBuf
void GPU_indexbuf_set_point_vert(GPUIndexBufBuilder *builder, uint elem, uint v1)
void GPU_indexbuf_set_point_restart(GPUIndexBufBuilder *builder, uint elem)
void GPU_indexbuf_init(GPUIndexBufBuilder *, GPUPrimType, uint prim_len, uint vertex_len)
void GPU_indexbuf_build_in_place(GPUIndexBufBuilder *, GPUIndexBuf *)
@ GPU_PRIM_POINTS
Definition: GPU_primitive.h:19
@ BM_ELEM_HIDDEN
Definition: bmesh_class.h:472
#define BM_elem_flag_test(ele, hflag)
Definition: bmesh_inline.h:12
@ MR_DATA_NONE
Extraction of Mesh data into VBO to feed to GPU.
const MeshExtract extract_fdots
constexpr MeshExtract create_extractor_fdots()
static void extract_fdots_finish(const MeshRenderData *UNUSED(mr), MeshBatchCache *UNUSED(cache), void *buf, void *_userdata)
static void extract_fdots_init(const MeshRenderData *mr, MeshBatchCache *UNUSED(cache), void *UNUSED(buf), void *tls_data)
static void extract_fdots_iter_poly_mesh(const MeshRenderData *mr, const MPoly *mp, const int mp_index, void *_userdata)
static void extract_fdots_iter_poly_bm(const MeshRenderData *UNUSED(mr), const BMFace *f, const int f_index, void *_userdata)
unsigned int v
GPUIndexBuf * fdots
size_t mesh_buffer_offset
eMRDataType data_type
ExtractFinishFn * finish
size_t data_size
ExtractPolyBMeshFn * iter_poly_bm
ExtractPolyMeshFn * iter_poly_mesh
bool use_threading
ExtractInitFn * init
const MLoop * mloop
Definition: extract_mesh.hh:76
bool use_subsurf_fdots
Definition: extract_mesh.hh:47
uint32_t * subsurf_face_dot_tags
Mesh_Runtime runtime