Blender V5.3
extract_mesh_ibo_fdots.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2021 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include "GPU_index_buffer.hh"
10
11#include "extract_mesh.hh"
12
13namespace blender::draw {
14
16{
17 IndexMask visible(mr.faces_num);
18 if (!mr.hide_poly.is_empty()) {
19 visible = IndexMask::from_bools_inverse(visible, mr.hide_poly, memory);
20 }
21 if (mr.use_subsurf_fdots) {
22 const OffsetIndices faces = mr.faces;
23 const Span<int> corner_verts = mr.corner_verts;
24 const BitSpan facedot_tags = mr.mesh->runtime->subsurf_face_dot_tags;
25 visible = IndexMask::from_predicate(visible, memory, [&](const int i) {
26 const Span<int> face_verts = corner_verts.slice(faces[i]);
27 return std::any_of(face_verts.begin(), face_verts.end(), [&](const int vert) {
28 return facedot_tags[vert];
29 });
30 });
31 }
32 return visible;
33}
34
36{
37 const int max_index = mask.min_array_size();
38 GPUIndexBufBuilder builder;
39 GPU_indexbuf_init(&builder, GPU_PRIM_POINTS, mask.size(), max_index);
41 mask.to_indices<int>(data.cast<int>());
42 return gpu::IndexBufPtr(GPU_indexbuf_build_ex(&builder, 0, max_index, false));
43}
44
46{
47 IndexMaskMemory memory;
48 const IndexMask visible_faces = calc_face_visibility_mesh(mr, memory);
49 return index_mask_to_ibo(visible_faces);
50}
51
53{
54 BMesh &bm = *mr.bm;
55 IndexMaskMemory memory;
56 const IndexMask visible_faces = IndexMask::from_predicate(
57 IndexRange(bm.totface), memory, [&](const int i) {
58 return !BM_elem_flag_test_bool(BM_face_at_index(&bm, i), BM_ELEM_HIDDEN);
59 });
60 return index_mask_to_ibo(visible_faces);
61}
62
70
71} // namespace blender::draw
static IndexMask from_predicate(const IndexMask &universe, LinearAllocator<> &memory, Fn &&predicate, exec_mode::Mode mode=exec_mode::parallel)
static IndexMask from_bools_inverse(Span< bool > bools, LinearAllocator<> &memory)
constexpr IndexRange()=default
constexpr Span slice(int64_t start, int64_t size) const
Definition BLI_span.hh:141
constexpr const T * end() const
Definition BLI_span.hh:228
constexpr const T * begin() const
Definition BLI_span.hh:224
constexpr bool is_empty() const
Extraction of Mesh data into VBO to feed to GPU.
static gpu::IndexBufPtr extract_face_dots_mesh(const MeshRenderData &mr)
gpu::IndexBufPtr extract_face_dots(const MeshRenderData &mr)
static void index_mask_to_ibo(const IndexMask &mask, gpu::IndexBuf &ibo)
static IndexMask calc_face_visibility_mesh(const MeshRenderData &mr, IndexMaskMemory &memory)
static gpu::IndexBufPtr extract_face_dots_bm(const MeshRenderData &mr)
std::unique_ptr< IndexBuf, IndexBufDeleter > IndexBufPtr
void GPU_indexbuf_init(GPUIndexBufBuilder *, GPUPrimType, uint prim_len, uint vertex_len)
BMesh const char void * data
MutableSpan< uint32_t > GPU_indexbuf_get_data(GPUIndexBufBuilder *)
gpu::IndexBuf * GPU_indexbuf_build_ex(GPUIndexBufBuilder *builder, uint index_min, uint index_max, bool uses_restart_indices)
bke::MeshRuntime * runtime
OffsetIndices< int > faces