30 if (!sync_selection) {
42 for (const int face : range) {
43 r_offset_data[face] = BM_face_at_index(&const_cast<BMesh &>(bm), face)->len;
57 return !skip_bm_face(*BM_face_at_index(&const_cast<BMesh &>(bm), face), sync_selection);
65 for (const int i : range) {
66 data[i] = uint3(BM_elem_index_get(looptris[i][0]),
67 BM_elem_index_get(looptris[i][1]),
68 BM_elem_index_get(looptris[i][2]));
77 Array<int> selected_face_offset_data(selection.size() + 1);
79 faces, selection, selected_face_offset_data);
87 selection.foreach_index(
88 [&](
const int face,
const int mask) {
97 exec_mode::grain_size(4096));
103 const bool sync_selection)
112 const BMFace *face_orig = bm_original_face_get(mr, face);
123 if (mr.hide_poly.is_empty()) {
127 selection = IndexMask::from_bools_inverse(faces.
index_range(), mr.hide_poly, memory);
130 if (!sync_selection && !mr.select_poly.is_empty()) {
131 selection = IndexMask::from_bools(selection, mr.select_poly, memory);
135 if (selection.size() == faces.
size()) {
137 corner_tris.cast<uint32_t>().data(),
144 Array<int> selected_face_offset_data(selection.size() + 1);
145 const OffsetIndices selected_faces = offset_indices::gather_selected_offsets(
146 faces, selection, selected_face_offset_data);
148 const int tris_num =
poly_to_tri_count(selected_faces.size(), selected_faces.total_size());
150 GPUIndexBufBuilder builder;
154 selection.foreach_index(
155 [&](
const int face,
const int mask) {
156 const IndexRange tris = bke::mesh::face_triangles_range(faces, face);
157 const IndexRange ibo_tris = bke::mesh::face_triangles_range(selected_faces,
mask);
158 for (
const int i : tris.index_range()) {
160 corner_tris[tris[i]][0], corner_tris[tris[i]][1], corner_tris[tris[i]][2]);
163 exec_mode::grain_size(4096));
181 const int tris_num = selection.
size() * 2;
188 [&](
const int subdiv_quad_index,
const int mask) {
189 const uint corner_start = subdiv_quad_index * 4;
190 data[
mask * 2 + 0] =
uint3(corner_start, corner_start + 1, corner_start + 2);
191 data[
mask * 2 + 1] =
uint3(corner_start, corner_start + 2, corner_start + 3);
201 const bool sync_selection)
210 const uint corner_start = subdiv_quad_index * 4;
211 const int coarse_face = subdiv_loop_face_index[corner_start];
212 const BMFace &bm_face = *BM_face_at_index(&const_cast<BMesh &>(bm), coarse_face);
213 return !skip_bm_face(bm_face, sync_selection);
221 const bool sync_selection)
229 const uint corner_start = subdiv_quad_index * 4;
230 const int coarse_face = subdiv_loop_face_index[corner_start];
231 const BMFace *face_orig = bm_original_face_get(mr, coarse_face);
261 const bool sync_selection)
294 const bool sync_selection)
317 for (
const int corner : face) {
318 const int edge = corner_edges[corner];
332 if (!sync_selection) {
342 for (
const int corner : face) {
343 const int edge = corner_edges[corner];
366 bool sync_selection =
false;
369 sync_selection =
true;
375 sync_selection =
false;
387 const bool sync_selection)
401 const int coarse_face = subdiv_loop_face_index[subdiv_quad * 4];
406 const IndexRange subdiv_face(subdiv_quad * 4, 4);
407 for (
const int subdiv_corner : subdiv_face) {
408 const int coarse_edge = subdiv_loop_edge_index[subdiv_corner];
409 if (coarse_edge == -1) {
422 const bool sync_selection)
436 const int coarse_face = subdiv_loop_face_index[subdiv_quad * 4];
449 if (!sync_selection) {
455 const IndexRange subdiv_face(subdiv_quad * 4, 4);
456 for (
const int subdiv_corner : subdiv_face) {
457 const int coarse_edge = subdiv_loop_edge_index[subdiv_corner];
458 if (coarse_edge == -1) {
481 bool sync_selection =
false;
484 sync_selection =
true;
490 sync_selection =
false;
507 const bool sync_selection,
526 const bool sync_selection,
542 for (
const int corner : faces[face_index]) {
543 const int vert = corner_verts[corner];
569 const bool sync_selection,
578 const int coarse_face = subdiv_loop_face_index[subdiv_quad * 4];
583 for (
const int subdiv_corner :
IndexRange(subdiv_quad * 4, 4)) {
584 const int coarse_vert = subdiv_loop_vert_index[subdiv_corner];
585 if (coarse_vert == -1) {
595 const bool sync_selection,
603 const int coarse_face = subdiv_loop_face_index[subdiv_quad * 4];
611 for (
const int subdiv_corner :
IndexRange(subdiv_quad * 4, 4)) {
612 const int coarse_vert = subdiv_loop_vert_index[subdiv_corner];
613 if (coarse_vert == -1) {
645 const bool sync_selection)
651 return !skip_bm_face(*BM_face_at_index(&const_cast<BMesh &>(bm), i), sync_selection);
661 const bool sync_selection)
666 const BMFace *face_orig = bm_original_face_get(mr, i);
675 if (mr.use_subsurf_fdots) {
676 const BitSpan facedot_tags = mr.mesh->runtime->subsurf_face_dot_tags;
677 const Span<int> corner_verts = mr.corner_verts;
680 return std::any_of(face_verts.
begin(), face_verts.
end(), [&](
const int vert) {
681 return facedot_tags[vert];
686 GPUIndexBufBuilder builder;
#define BM_FACE_FIRST_LOOP(p)
#define BM_elem_index_get(ele)
#define BM_elem_flag_test(ele, hflag)
#define BM_elem_flag_test_bool(ele, hflag)
#define BM_ITER_MESH(ele, iter, bm, itype)
void reinitialize(const int64_t new_size)
static IndexMask from_predicate(const IndexMask &universe, LinearAllocator<> &memory, Fn &&predicate, exec_mode::Mode mode=exec_mode::parallel)
static IndexMask from_bools(Span< bool > bools, LinearAllocator<> &memory)
static IndexMask from_bools_inverse(Span< bool > bools, LinearAllocator<> &memory)
constexpr IndexRange()=default
constexpr IndexRange index_range() const
constexpr Span slice(int64_t start, int64_t size) const
constexpr int64_t size() const
constexpr const T * end() const
constexpr IndexRange index_range() const
constexpr const T * begin() const
constexpr bool is_empty() const
constexpr bool is_empty() const
void to_indices(MutableSpan< T > r_indices) const
void foreach_index(Fn &&fn, Mode mode=exec_mode::serial) const
IndexRange index_range() const
ccl_device_inline float2 mask(const MaskType mask, const float2 a)
ccl_device_inline int4 cast(const float4 a)
IndexRange face_triangles_range(OffsetIndices< int > faces, int face_i)
BLI_INLINE BMFace * bm_original_face_get(const MeshRenderData &mr, int idx)
gpu::IndexBufPtr extract_edituv_lines_subdiv(const MeshRenderData &mr, const DRWSubdivCache &subdiv_cache, UvExtractionMode mode)
gpu::IndexBufPtr extract_edituv_face_dots(const MeshRenderData &mr)
static gpu::IndexBufPtr extract_edituv_face_dots_bm(const MeshRenderData &mr, const bool sync_selection)
static gpu::IndexBufPtr extract_edituv_lines_subdiv_mesh(const MeshRenderData &mr, const DRWSubdivCache &subdiv_cache, const bool sync_selection)
static OffsetIndices< int > build_bmesh_face_offsets(const BMesh &bm, Array< int > &r_offset_data)
gpu::IndexBufPtr extract_edituv_tris(const MeshRenderData &mr, bool edit_uvs)
static gpu::IndexBufPtr build_tris_from_subdiv_quad_selection(const DRWSubdivCache &subdiv_cache, const IndexMask &selection)
gpu::IndexBufPtr extract_edituv_points(const MeshRenderData &mr)
gpu::IndexBufPtr extract_edituv_tris_subdiv(const MeshRenderData &mr, const DRWSubdivCache &subdiv_cache)
static gpu::IndexBufPtr extract_edituv_tris_subdiv_mesh(const MeshRenderData &mr, const DRWSubdivCache &subdiv_cache, const bool sync_selection)
uint2 edge_from_corners(const IndexRange face, const int corner)
static gpu::IndexBufPtr extract_edituv_tris_subdiv_bm(const MeshRenderData &mr, const DRWSubdivCache &subdiv_cache, const bool sync_selection)
static void extract_edituv_points_subdiv_bm(const MeshRenderData &mr, const DRWSubdivCache &subdiv_cache, const bool sync_selection, GPUIndexBufBuilder &builder)
gpu::IndexBufPtr extract_edituv_points_subdiv(const MeshRenderData &mr, const DRWSubdivCache &subdiv_cache)
static gpu::IndexBufPtr extract_edituv_tris_mesh(const MeshRenderData &mr, const bool sync_selection)
static void extract_edituv_points_subdiv_mesh(const MeshRenderData &mr, const DRWSubdivCache &subdiv_cache, const bool sync_selection, GPUIndexBufBuilder &builder)
static gpu::IndexBufPtr extract_edituv_face_dots_mesh(const MeshRenderData &mr, const bool sync_selection)
static void extract_edituv_points_mesh(const MeshRenderData &mr, const bool sync_selection, GPUIndexBufBuilder &builder)
gpu::IndexBufPtr extract_edituv_lines(const MeshRenderData &mr, UvExtractionMode mode)
static gpu::IndexBufPtr extract_edituv_lines_bm(const MeshRenderData &mr, const bool sync_selection)
static void extract_edituv_points_bm(const MeshRenderData &mr, const bool sync_selection, GPUIndexBufBuilder &builder)
static gpu::IndexBufPtr extract_edituv_tris_bm(const MeshRenderData &mr, const bool sync_selection)
static gpu::IndexBufPtr extract_edituv_lines_subdiv_bm(const MeshRenderData &mr, const DRWSubdivCache &subdiv_cache, const bool sync_selection)
bool skip_bm_face(const BMFace &face, const bool sync_selection)
static gpu::IndexBufPtr extract_edituv_lines_mesh(const MeshRenderData &mr, const bool sync_selection)
constexpr ParallelGrainSize grain_size(int grain_size)
std::unique_ptr< IndexBuf, IndexBufDeleter > IndexBufPtr
constexpr int poly_to_tri_count(const int poly_count, const int corner_count)
OffsetIndices< int > accumulate_counts_to_offsets(MutableSpan< int > counts_to_offsets, int start_offset=0)
OffsetIndices< int > gather_selected_offsets(OffsetIndices< int > src_offsets, const IndexMask &selection, int start_offset, MutableSpan< int > dst_offsets)
void parallel_for(const IndexRange range, const int64_t grain_size, const Function &function, const TaskSizeHints &size_hints=detail::TaskSizeHints_Static(1))
VecBase< uint32_t, 2 > uint2
void GPU_indexbuf_init(GPUIndexBufBuilder *, GPUPrimType, uint prim_len, uint vertex_len)
VecBase< uint32_t, 3 > uint3
void GPU_indexbuf_add_point_vert(GPUIndexBufBuilder *, uint v)
gpu::IndexBuf * GPU_indexbuf_build(GPUIndexBufBuilder *)
BMesh const char void * data
MutableSpan< uint32_t > GPU_indexbuf_get_data(GPUIndexBufBuilder *)
gpu::IndexBuf * GPU_indexbuf_calloc()
gpu::IndexBuf * GPU_indexbuf_build_from_memory(GPUPrimType prim_type, const uint32_t *data, int32_t data_len, int32_t index_min, int32_t index_max, bool uses_restart_indices)
MINLINE int poly_to_tri_count(int poly_count, int corner_count)
void GPU_indexbuf_build_in_place(GPUIndexBufBuilder *, gpu::IndexBuf *)
gpu::IndexBuf * GPU_indexbuf_build_ex(GPUIndexBufBuilder *builder, uint index_min, uint index_max, bool uses_restart_indices)
BLI_INLINE BMFace * BM_face_at_index(BMesh *bm, const int index)
Array< std::array< BMLoop *, 3 > > looptris
bool uses_restart_indices
gpu::VertBuf * verts_orig_index
gpu::VertBuf * edges_orig_index
int * subdiv_loop_face_index
const int * orig_index_vert
const ToolSettings * toolsettings
MeshExtractType extract_type
const int * orig_index_face
VArraySpan< bool > select_poly
const int * orig_index_edge
VArraySpan< bool > hide_poly
OffsetIndices< int > faces