Cleanup: Draw: Use enum class for mesh extract type

This commit is contained in:
Hans Goudey
2024-11-12 11:41:51 -05:00
parent c1bf38fc34
commit f379acb2bf
29 changed files with 78 additions and 78 deletions

View File

@@ -122,7 +122,7 @@ static void mesh_render_data_loose_edges_bm(const MeshRenderData &mr,
static void mesh_render_data_loose_geom_build(const MeshRenderData &mr, MeshBufferCache &cache)
{
if (mr.extract_type != MR_EXTRACT_BMESH) {
if (mr.extract_type != MeshExtractType::BMesh) {
/* Mesh */
mesh_render_data_loose_geom_mesh(mr, cache);
}
@@ -233,7 +233,7 @@ static Array<int> mesh_render_data_mat_tri_len_build(const MeshRenderData &mr)
threading::EnumerableThreadSpecific<Array<int>> all_tri_counts(
[&]() { return Array<int>(mr.materials_num, 0); });
if (mr.extract_type == MR_EXTRACT_BMESH) {
if (mr.extract_type == MeshExtractType::BMesh) {
accumululate_material_counts_bm(*mr.bm, all_tri_counts);
}
else {
@@ -339,7 +339,7 @@ static SortedFaceData mesh_render_data_faces_sorted_build(const MeshRenderData &
cache.visible_tris_num = material_tri_starts.last();
/* Sort per material. */
if (mr.extract_type == MR_EXTRACT_BMESH) {
if (mr.extract_type == MeshExtractType::BMesh) {
cache.face_tri_offsets = calc_face_tri_starts_bmesh(mr, material_tri_starts);
}
else {
@@ -489,7 +489,7 @@ static bke::MeshNormalDomain bmesh_normals_domain(BMesh *bm)
void mesh_render_data_update_corner_normals(MeshRenderData &mr)
{
if (mr.extract_type != MR_EXTRACT_BMESH) {
if (mr.extract_type != MeshExtractType::BMesh) {
mr.corner_normals = mr.mesh->corner_normals();
}
else {
@@ -510,7 +510,7 @@ void mesh_render_data_update_corner_normals(MeshRenderData &mr)
void mesh_render_data_update_face_normals(MeshRenderData &mr)
{
if (mr.extract_type != MR_EXTRACT_BMESH) {
if (mr.extract_type != MeshExtractType::BMesh) {
/* Eager calculation of face normals can reduce waiting on the lazy cache's lock. */
mr.face_normals = mr.mesh->face_normals();
}
@@ -595,10 +595,10 @@ std::unique_ptr<MeshRenderData> mesh_render_data_create(Object &object,
mr->mesh->runtime->wrapper_type == ME_WRAPPER_TYPE_BMESH) ||
(do_uvedit && !do_final))
{
mr->extract_type = MR_EXTRACT_BMESH;
mr->extract_type = MeshExtractType::BMesh;
}
else {
mr->extract_type = MR_EXTRACT_MESH;
mr->extract_type = MeshExtractType::Mesh;
/* Use mapping from final to original mesh when the object is in edit mode. */
if (is_editmode && do_final) {
@@ -619,7 +619,7 @@ std::unique_ptr<MeshRenderData> mesh_render_data_create(Object &object,
else {
mr->mesh = &mesh;
mr->edit_bmesh = nullptr;
mr->extract_type = MR_EXTRACT_MESH;
mr->extract_type = MeshExtractType::Mesh;
mr->hide_unmapped_edges = false;
if (is_paint_mode && mr->mesh) {
@@ -637,7 +637,7 @@ std::unique_ptr<MeshRenderData> mesh_render_data_create(Object &object,
}
}
if (mr->extract_type != MR_EXTRACT_BMESH) {
if (mr->extract_type != MeshExtractType::BMesh) {
/* Mesh */
mr->verts_num = mr->mesh->verts_num;
mr->edges_num = mr->mesh->edges_num;

View File

@@ -820,13 +820,13 @@ static void draw_subdiv_cache_update_extra_coarse_face_data(DRWSubdivCache &cach
}
GPU_vertbuf_init_with_format_ex(*cache.extra_coarse_face_data, format, GPU_USAGE_DYNAMIC);
GPU_vertbuf_data_alloc(*cache.extra_coarse_face_data,
mr.extract_type == MR_EXTRACT_BMESH ? cache.bm->totface :
mesh->faces_num);
mr.extract_type == MeshExtractType::BMesh ? cache.bm->totface :
mesh->faces_num);
}
MutableSpan<uint32_t> flags_data = cache.extra_coarse_face_data->data<uint32_t>();
if (mr.extract_type == MR_EXTRACT_BMESH) {
if (mr.extract_type == MeshExtractType::BMesh) {
draw_subdiv_cache_extra_coarse_face_data_bm(cache.bm, mr.efa_act, flags_data);
}
else if (mr.orig_index_face != nullptr) {

View File

@@ -41,13 +41,13 @@ namespace blender::draw {
/** \name Mesh Render Data
* \{ */
enum eMRExtractType {
MR_EXTRACT_BMESH,
MR_EXTRACT_MESH,
enum class MeshExtractType {
BMesh,
Mesh,
};
struct MeshRenderData {
eMRExtractType extract_type;
MeshExtractType extract_type;
int verts_num;
int edges_num;

View File

@@ -75,7 +75,7 @@ void extract_edituv_tris(const MeshRenderData &mr, gpu::IndexBuf &ibo)
GPUIndexBufBuilder builder;
GPU_indexbuf_init(&builder, GPU_PRIM_TRIS, mr.corner_tris_num, mr.corners_num);
if (mr.extract_type == MR_EXTRACT_BMESH) {
if (mr.extract_type == MeshExtractType::BMesh) {
extract_edituv_tris_bm(mr, sync_selection, builder);
}
else {
@@ -136,7 +136,7 @@ void extract_edituv_tris_subdiv(const MeshRenderData &mr,
GPUIndexBufBuilder builder;
GPU_indexbuf_init(
&builder, GPU_PRIM_TRIS, subdiv_cache.num_subdiv_triangles, subdiv_cache.num_subdiv_loops);
if (mr.extract_type == MR_EXTRACT_BMESH) {
if (mr.extract_type == MeshExtractType::BMesh) {
extract_edituv_tris_subdiv_bm(mr, subdiv_cache, sync_selection, builder);
}
else {
@@ -235,7 +235,7 @@ void extract_edituv_lines(const MeshRenderData &mr, gpu::IndexBuf &ibo)
GPUIndexBufBuilder builder;
GPU_indexbuf_init(&builder, GPU_PRIM_LINES, mr.corners_num, mr.corners_num);
if (mr.extract_type == MR_EXTRACT_BMESH) {
if (mr.extract_type == MeshExtractType::BMesh) {
extract_edituv_lines_bm(mr, sync_selection, builder);
}
else {
@@ -322,7 +322,7 @@ void extract_edituv_lines_subdiv(const MeshRenderData &mr,
GPUIndexBufBuilder builder;
GPU_indexbuf_init(
&builder, GPU_PRIM_LINES, subdiv_cache.num_subdiv_loops, subdiv_cache.num_subdiv_loops);
if (mr.extract_type == MR_EXTRACT_BMESH) {
if (mr.extract_type == MeshExtractType::BMesh) {
extract_edituv_lines_subdiv_bm(mr, subdiv_cache, sync_selection, builder);
}
else {
@@ -390,7 +390,7 @@ void extract_edituv_points(const MeshRenderData &mr, gpu::IndexBuf &ibo)
GPUIndexBufBuilder builder;
GPU_indexbuf_init(&builder, GPU_PRIM_POINTS, mr.corners_num, mr.corners_num);
if (mr.extract_type == MR_EXTRACT_BMESH) {
if (mr.extract_type == MeshExtractType::BMesh) {
extract_edituv_points_bm(mr, sync_selection, builder);
}
else {
@@ -462,7 +462,7 @@ void extract_edituv_points_subdiv(const MeshRenderData &mr,
GPUIndexBufBuilder builder;
GPU_indexbuf_init(
&builder, GPU_PRIM_POINTS, subdiv_cache.num_subdiv_loops, subdiv_cache.num_subdiv_loops);
if (mr.extract_type == MR_EXTRACT_BMESH) {
if (mr.extract_type == MeshExtractType::BMesh) {
extract_edituv_points_subdiv_bm(mr, subdiv_cache, sync_selection, builder);
}
else {
@@ -531,7 +531,7 @@ static void extract_edituv_face_dots_mesh(const MeshRenderData &mr,
void extract_edituv_face_dots(const MeshRenderData &mr, gpu::IndexBuf &ibo)
{
const bool sync_selection = (mr.toolsettings->uv_flag & UV_SYNC_SELECTION) != 0;
if (mr.extract_type == MR_EXTRACT_BMESH) {
if (mr.extract_type == MeshExtractType::BMesh) {
extract_edituv_face_dots_bm(mr, sync_selection, ibo);
}
else {

View File

@@ -62,7 +62,7 @@ static void extract_face_dots_bm(const MeshRenderData &mr, gpu::IndexBuf &face_d
void extract_face_dots(const MeshRenderData &mr, gpu::IndexBuf &face_dots)
{
if (mr.extract_type == MR_EXTRACT_MESH) {
if (mr.extract_type == MeshExtractType::Mesh) {
extract_face_dots_mesh(mr, face_dots);
}
else {

View File

@@ -239,7 +239,7 @@ void extract_lines(const MeshRenderData &mr,
gpu::IndexBuf *lines_loose,
bool &no_loose_wire)
{
if (mr.extract_type == MR_EXTRACT_MESH) {
if (mr.extract_type == MeshExtractType::Mesh) {
extract_lines_mesh(mr, lines, lines_loose, no_loose_wire);
}
else {
@@ -273,7 +273,7 @@ static void extract_lines_loose_geom_subdiv(const DRWSubdivCache &subdiv_cache,
MutableSpan<uint> flags_data = flags->data<uint>();
switch (mr.extract_type) {
case MR_EXTRACT_MESH: {
case MeshExtractType::Mesh: {
const int *orig_index_edge = (mr.hide_unmapped_edges) ? mr.orig_index_edge : nullptr;
if (orig_index_edge == nullptr) {
const Span<bool> hide_edge = mr.hide_edge;
@@ -312,7 +312,7 @@ static void extract_lines_loose_geom_subdiv(const DRWSubdivCache &subdiv_cache,
}
break;
}
case MR_EXTRACT_BMESH: {
case MeshExtractType::BMesh: {
BMesh *bm = mr.bm;
for (const int i : loose_edges.index_range()) {
const BMEdge *bm_edge = BM_edge_at_index(bm, loose_edges[i]);

View File

@@ -174,7 +174,7 @@ void extract_lines_adjacency(const MeshRenderData &mr, gpu::IndexBuf &ibo, bool
GPUIndexBufBuilder builder;
GPU_indexbuf_init(&builder, GPU_PRIM_LINES_ADJ, tess_edge_len, mr.corners_num);
if (mr.extract_type == MR_EXTRACT_MESH) {
if (mr.extract_type == MeshExtractType::Mesh) {
calc_adjacency_mesh(mr, vert_to_corner, edge_hash, builder, is_manifold);
}
else {

View File

@@ -187,7 +187,7 @@ static void extract_points_bm(const MeshRenderData &mr, gpu::IndexBuf &points)
void extract_points(const MeshRenderData &mr, gpu::IndexBuf &points)
{
if (mr.extract_type == MR_EXTRACT_MESH) {
if (mr.extract_type == MeshExtractType::Mesh) {
extract_points_mesh(mr, points);
}
else {
@@ -334,7 +334,7 @@ void extract_points_subdiv(const MeshRenderData &mr,
const DRWSubdivCache &subdiv_cache,
gpu::IndexBuf &points)
{
if (mr.extract_type == MR_EXTRACT_MESH) {
if (mr.extract_type == MeshExtractType::Mesh) {
extract_points_subdiv_mesh(mr, subdiv_cache, points);
}
else {

View File

@@ -118,7 +118,7 @@ void extract_tris(const MeshRenderData &mr,
MeshBatchCache &cache,
gpu::IndexBuf &ibo)
{
if (mr.extract_type == MR_EXTRACT_MESH) {
if (mr.extract_type == MeshExtractType::Mesh) {
extract_tris_mesh(mr, face_sorted, ibo);
}
else {

View File

@@ -193,7 +193,7 @@ static void extract_attribute(const MeshRenderData &mr,
const DRW_AttributeRequest &request,
gpu::VertBuf &vbo)
{
if (mr.extract_type == MR_EXTRACT_BMESH) {
if (mr.extract_type == MeshExtractType::BMesh) {
const CustomData &custom_data = *get_custom_data_for_domain(*mr.bm, request.domain);
const char *name = request.attribute_name;
const int cd_offset = CustomData_get_offset_named(&custom_data, request.cd_type, name);

View File

@@ -146,7 +146,7 @@ void extract_edge_factor(const MeshRenderData &mr, gpu::VertBuf &vbo)
GPU_vertbuf_init_with_format(vbo, format);
GPU_vertbuf_data_alloc(vbo, mr.corners_num + mr.loose_indices_num);
MutableSpan vbo_data = vbo.data<float>();
if (mr.extract_type == MR_EXTRACT_MESH) {
if (mr.extract_type == MeshExtractType::Mesh) {
extract_edge_factor_mesh(mr, vbo_data);
}
else {
@@ -162,7 +162,7 @@ void extract_edge_factor(const MeshRenderData &mr, gpu::VertBuf &vbo)
GPU_vertbuf_init_with_format(vbo, format);
GPU_vertbuf_data_alloc(vbo, mr.corners_num + mr.loose_indices_num);
MutableSpan vbo_data = vbo.data<uint8_t>();
if (mr.extract_type == MR_EXTRACT_MESH) {
if (mr.extract_type == MeshExtractType::Mesh) {
extract_edge_factor_mesh(mr, vbo_data);
}
else {

View File

@@ -227,7 +227,7 @@ void extract_edit_data(const MeshRenderData &mr, gpu::VertBuf &vbo)
const int size = mr.corners_num + mr.loose_indices_num;
GPU_vertbuf_data_alloc(vbo, size);
MutableSpan vbo_data = vbo.data<EditLoopData>();
if (mr.extract_type == MR_EXTRACT_MESH) {
if (mr.extract_type == MeshExtractType::Mesh) {
extract_edit_data_mesh(mr, vbo_data);
}
else {
@@ -385,7 +385,7 @@ void extract_edit_data_subdiv(const MeshRenderData &mr,
const int size = subdiv_full_vbo_size(mr, subdiv_cache);
GPU_vertbuf_data_alloc(vbo, size);
MutableSpan vbo_data = vbo.data<EditLoopData>();
if (mr.extract_type == MR_EXTRACT_MESH) {
if (mr.extract_type == MeshExtractType::Mesh) {
extract_edit_subdiv_data_mesh(mr, subdiv_cache, vbo_data);
}
else {

View File

@@ -102,7 +102,7 @@ void extract_edituv_data(const MeshRenderData &mr, gpu::VertBuf &vbo)
GPU_vertbuf_data_alloc(vbo, mr.corners_num);
MutableSpan vbo_data = vbo.data<EditLoopData>();
if (mr.extract_type == MR_EXTRACT_BMESH) {
if (mr.extract_type == MeshExtractType::BMesh) {
extract_edituv_data_bm(mr, vbo_data);
}
else {
@@ -213,7 +213,7 @@ void extract_edituv_data_subdiv(const MeshRenderData &mr,
GPU_vertbuf_data_alloc(vbo, size);
MutableSpan vbo_data = vbo.data<EditLoopData>();
if (mr.extract_type == MR_EXTRACT_BMESH) {
if (mr.extract_type == MeshExtractType::BMesh) {
extract_edituv_subdiv_data_bm(mr, subdiv_cache, vbo_data);
}
else {

View File

@@ -204,7 +204,7 @@ void extract_edituv_stretch_angle(const MeshRenderData &mr, gpu::VertBuf &vbo)
GPU_vertbuf_data_alloc(vbo, mr.corners_num);
MutableSpan vbo_data = vbo.data<UVStretchAngle>();
if (mr.extract_type == MR_EXTRACT_BMESH) {
if (mr.extract_type == MeshExtractType::BMesh) {
extract_uv_stretch_angle_bm(mr, vbo_data);
}
else {
@@ -249,12 +249,12 @@ void extract_edituv_stretch_angle_subdiv(const MeshRenderData &mr,
/* UVs are stored contiguously so we need to compute the offset in the UVs buffer for the active
* UV layer. */
const CustomData *cd_ldata = (mr.extract_type == MR_EXTRACT_MESH) ? &mr.mesh->corner_data :
&mr.bm->ldata;
const CustomData *cd_ldata = (mr.extract_type == MeshExtractType::Mesh) ? &mr.mesh->corner_data :
&mr.bm->ldata;
uint32_t uv_layers = cache.cd_used.uv;
/* HACK to fix #68857 */
if (mr.extract_type == MR_EXTRACT_BMESH && cache.cd_used.edit_uv == 1) {
if (mr.extract_type == MeshExtractType::BMesh && cache.cd_used.edit_uv == 1) {
int layer = CustomData_get_active_layer(cd_ldata, CD_PROP_FLOAT2);
if (layer != -1 && !CustomData_layer_is_anonymous(cd_ldata, CD_PROP_FLOAT2, layer)) {
uv_layers |= (1 << layer);

View File

@@ -39,7 +39,7 @@ struct AreaInfo {
};
static AreaInfo compute_area_ratio(const MeshRenderData &mr, MutableSpan<float> r_area_ratio)
{
if (mr.extract_type == MR_EXTRACT_BMESH) {
if (mr.extract_type == MeshExtractType::BMesh) {
const BMesh &bm = *mr.bm;
const int uv_offset = CustomData_get_offset(&bm.ldata, CD_PROP_FLOAT2);
return threading::parallel_reduce(
@@ -111,7 +111,7 @@ void extract_edituv_stretch_area(const MeshRenderData &mr,
const int64_t bytes = area_ratio.as_span().size_in_bytes() + vbo_data.size_in_bytes();
threading::memory_bandwidth_bound_task(bytes, [&]() {
if (mr.extract_type == MR_EXTRACT_BMESH) {
if (mr.extract_type == MeshExtractType::BMesh) {
const BMesh &bm = *mr.bm;
threading::parallel_for(IndexRange(bm.totface), 2048, [&](const IndexRange range) {
for (const int face_index : range) {
@@ -122,7 +122,7 @@ void extract_edituv_stretch_area(const MeshRenderData &mr,
});
}
else {
BLI_assert(mr.extract_type == MR_EXTRACT_MESH);
BLI_assert(mr.extract_type == MeshExtractType::Mesh);
const OffsetIndices<int> faces = mr.faces;
threading::parallel_for(faces.index_range(), 2048, [&](const IndexRange range) {
for (const int face : range) {

View File

@@ -24,7 +24,7 @@ void extract_face_dots_edituv_data(const MeshRenderData &mr, gpu::VertBuf &vbo)
MutableSpan vbo_data = vbo.data<EditLoopData>();
const BMesh &bm = *mr.bm;
const BMUVOffsets offsets = BM_uv_map_get_offsets(&bm);
if (mr.extract_type == MR_EXTRACT_BMESH) {
if (mr.extract_type == MeshExtractType::BMesh) {
threading::parallel_for(IndexRange(bm.totface), 2048, [&](const IndexRange range) {
for (const int face_index : range) {
const BMFace &face = *BM_face_at_index(&const_cast<BMesh &>(bm), face_index);

View File

@@ -66,7 +66,7 @@ void extract_face_dot_normals(const MeshRenderData &mr, const bool use_hq, gpu::
GPU_vertbuf_data_alloc(vbo, mr.faces_num);
MutableSpan vbo_data = vbo.data<short4>();
if (mr.extract_type == MR_EXTRACT_MESH) {
if (mr.extract_type == MeshExtractType::Mesh) {
extract_face_dot_normals_mesh(mr, vbo_data);
}
else {
@@ -82,7 +82,7 @@ void extract_face_dot_normals(const MeshRenderData &mr, const bool use_hq, gpu::
GPU_vertbuf_data_alloc(vbo, mr.faces_num);
MutableSpan vbo_data = vbo.data<GPUPackedNormal>();
if (mr.extract_type == MR_EXTRACT_MESH) {
if (mr.extract_type == MeshExtractType::Mesh) {
extract_face_dot_normals_mesh(mr, vbo_data);
}
else {

View File

@@ -85,7 +85,7 @@ void extract_face_dots_position(const MeshRenderData &mr, gpu::VertBuf &vbo)
GPU_vertbuf_data_alloc(vbo, mr.corners_num + mr.loose_indices_num);
MutableSpan vbo_data = vbo.data<float3>();
if (mr.extract_type == MR_EXTRACT_MESH) {
if (mr.extract_type == MeshExtractType::Mesh) {
extract_face_dot_positions_mesh(mr, vbo_data);
}
else {

View File

@@ -75,7 +75,7 @@ void extract_face_dots_uv(const MeshRenderData &mr, gpu::VertBuf &vbo)
GPU_vertbuf_data_alloc(vbo, mr.faces_num);
MutableSpan<float2> vbo_data = vbo.data<float2>();
if (mr.extract_type == MR_EXTRACT_MESH) {
if (mr.extract_type == MeshExtractType::Mesh) {
extract_face_dots_uv_mesh(mr, vbo_data);
}
else {

View File

@@ -214,7 +214,7 @@ void extract_normals(const MeshRenderData &mr, const bool use_hq, gpu::VertBuf &
MutableSpan corners_data = vbo_data.take_front(mr.corners_num);
MutableSpan loose_data = vbo_data.take_back(mr.loose_indices_num);
if (mr.extract_type == MR_EXTRACT_MESH) {
if (mr.extract_type == MeshExtractType::Mesh) {
extract_normals_mesh(mr, corners_data);
extract_paint_overlay_flags(mr, corners_data);
}
@@ -236,7 +236,7 @@ void extract_normals(const MeshRenderData &mr, const bool use_hq, gpu::VertBuf &
MutableSpan corners_data = vbo_data.take_front(mr.corners_num);
MutableSpan loose_data = vbo_data.take_back(mr.loose_indices_num);
if (mr.extract_type == MR_EXTRACT_MESH) {
if (mr.extract_type == MeshExtractType::Mesh) {
extract_normals_mesh(mr, corners_data);
extract_paint_overlay_flags(mr, corners_data);
}

View File

@@ -70,7 +70,7 @@ static void statvis_calc_overhang(const MeshRenderData &mr, MutableSpan<float> r
mul_transposed_mat3_m4_v3(mr.object_to_world.ptr(), dir);
normalize_v3(dir);
if (mr.extract_type == MR_EXTRACT_BMESH) {
if (mr.extract_type == MeshExtractType::BMesh) {
int l_index = 0;
BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
float fac = angle_normalized_v3v3(bm_face_no_get(mr, f), dir) / float(M_PI);
@@ -143,7 +143,7 @@ static void statvis_calc_thickness(const MeshRenderData &mr, MutableSpan<float>
uv_from_jitter_v2(jit_ofs[j]);
}
if (mr.extract_type == MR_EXTRACT_BMESH) {
if (mr.extract_type == MeshExtractType::BMesh) {
BMesh *bm = em->bm;
BM_mesh_elem_index_ensure(bm, BM_FACE);
@@ -296,7 +296,7 @@ static void statvis_calc_intersect(const MeshRenderData &mr, MutableSpan<float>
r_intersect[l_index] = -1.0f;
}
if (mr.extract_type == MR_EXTRACT_BMESH) {
if (mr.extract_type == MeshExtractType::BMesh) {
uint overlap_len;
BMesh *bm = em->bm;
@@ -380,7 +380,7 @@ static void statvis_calc_distort(const MeshRenderData &mr, MutableSpan<float> r_
const float max = statvis->distort_max;
const float minmax_irange = 1.0f / (max - min);
if (mr.extract_type == MR_EXTRACT_BMESH) {
if (mr.extract_type == MeshExtractType::BMesh) {
BMIter iter;
BMesh *bm = em->bm;
BMFace *f;
@@ -487,7 +487,7 @@ static void statvis_calc_sharp(const MeshRenderData &mr, MutableSpan<float> r_sh
float *vert_angles = (float *)MEM_mallocN(sizeof(float) * mr.verts_num, __func__);
copy_vn_fl(vert_angles, mr.verts_num, -M_PI);
if (mr.extract_type == MR_EXTRACT_BMESH) {
if (mr.extract_type == MeshExtractType::BMesh) {
BMIter iter;
BMesh *bm = em->bm;
BMFace *efa;

View File

@@ -30,7 +30,7 @@ void extract_orco(const MeshRenderData &mr, gpu::VertBuf &vbo)
const int64_t bytes = orco_data.size_in_bytes() + vbo_data.size_in_bytes();
threading::memory_bandwidth_bound_task(bytes, [&]() {
if (mr.extract_type == MR_EXTRACT_BMESH) {
if (mr.extract_type == MeshExtractType::BMesh) {
const BMesh &bm = *mr.bm;
threading::parallel_for(IndexRange(bm.totface), 2048, [&](const IndexRange range) {
for (const int face_index : range) {

View File

@@ -77,7 +77,7 @@ void extract_positions(const MeshRenderData &mr, gpu::VertBuf &vbo)
GPU_vertbuf_data_alloc(vbo, mr.corners_num + mr.loose_indices_num);
MutableSpan vbo_data = vbo.data<float3>();
if (mr.extract_type == MR_EXTRACT_MESH) {
if (mr.extract_type == MeshExtractType::Mesh) {
extract_positions_mesh(mr, vbo_data);
}
else {

View File

@@ -44,7 +44,7 @@ void extract_sculpt_data(const MeshRenderData &mr, gpu::VertBuf &vbo)
const int default_face_set = mr.mesh->face_sets_color_default;
const int face_set_seed = mr.mesh->face_sets_color_seed;
if (mr.extract_type == MR_EXTRACT_BMESH) {
if (mr.extract_type == MeshExtractType::BMesh) {
const BMesh &bm = *mr.bm;
const int mask_offset = CustomData_get_offset_named(
&mr.bm->vdata, CD_PROP_FLOAT, ".sculpt_mask");

View File

@@ -89,7 +89,7 @@ static void extract_vert_index_bm(const MeshRenderData &mr, MutableSpan<int> vbo
void extract_vert_index(const MeshRenderData &mr, gpu::VertBuf &vbo)
{
MutableSpan<int> vbo_data = init_vbo_data(vbo, mr.corners_num + mr.loose_indices_num);
if (mr.extract_type == MR_EXTRACT_MESH) {
if (mr.extract_type == MeshExtractType::Mesh) {
extract_vert_index_mesh(mr, vbo_data);
}
else {
@@ -154,7 +154,7 @@ static void extract_edge_index_bm(const MeshRenderData &mr, MutableSpan<int> vbo
void extract_edge_index(const MeshRenderData &mr, gpu::VertBuf &vbo)
{
MutableSpan<int> vbo_data = init_vbo_data(vbo, mr.corners_num + mr.loose_edges.size() * 2);
if (mr.extract_type == MR_EXTRACT_MESH) {
if (mr.extract_type == MeshExtractType::Mesh) {
extract_edge_index_mesh(mr, vbo_data);
}
else {
@@ -193,7 +193,7 @@ static void extract_face_index_bm(const MeshRenderData &mr, MutableSpan<int> vbo
void extract_face_index(const MeshRenderData &mr, gpu::VertBuf &vbo)
{
MutableSpan<int> vbo_data = init_vbo_data(vbo, mr.corners_num);
if (mr.extract_type == MR_EXTRACT_MESH) {
if (mr.extract_type == MeshExtractType::Mesh) {
extract_face_index_mesh(mr, vbo_data);
}
else {
@@ -314,7 +314,7 @@ void extract_face_index_subdiv(const DRWSubdivCache &subdiv_cache,
void extract_face_dot_index(const MeshRenderData &mr, gpu::VertBuf &vbo)
{
MutableSpan<int> vbo_data = init_vbo_data(vbo, mr.faces_num);
if (mr.extract_type == MR_EXTRACT_MESH) {
if (mr.extract_type == MeshExtractType::Mesh) {
if (mr.orig_index_face) {
const Span<int> orig_index_face(mr.orig_index_face, mr.faces_num);
array_utils::copy(orig_index_face, vbo_data);

View File

@@ -34,10 +34,10 @@ static void extract_tan_init_common(const MeshRenderData &mr,
{
GPU_vertformat_deinterleave(format);
const CustomData *cd_ldata = (mr.extract_type == MR_EXTRACT_BMESH) ? &mr.bm->ldata :
&mr.mesh->corner_data;
const CustomData *cd_vdata = (mr.extract_type == MR_EXTRACT_BMESH) ? &mr.bm->vdata :
&mr.mesh->vert_data;
const CustomData *cd_ldata = (mr.extract_type == MeshExtractType::BMesh) ? &mr.bm->ldata :
&mr.mesh->corner_data;
const CustomData *cd_vdata = (mr.extract_type == MeshExtractType::BMesh) ? &mr.bm->vdata :
&mr.mesh->vert_data;
uint32_t tan_layers = cache.cd_used.tan;
const float3 *orco_ptr = static_cast<const float3 *>(CustomData_get_layer(cd_vdata, CD_ORCO));
Span<float3> orco = orco_ptr ? Span(orco_ptr, mr.verts_num) : Span<float3>();
@@ -83,7 +83,7 @@ static void extract_tan_init_common(const MeshRenderData &mr,
/* If `orco` is not available compute it ourselves */
orco_allocated.reinitialize(mr.verts_num);
if (mr.extract_type == MR_EXTRACT_BMESH) {
if (mr.extract_type == MeshExtractType::BMesh) {
BMesh *bm = mr.bm;
for (int v = 0; v < mr.verts_num; v++) {
const BMVert *eve = BM_vert_at_index(bm, v);
@@ -107,7 +107,7 @@ static void extract_tan_init_common(const MeshRenderData &mr,
if (tan_len != 0 || use_orco_tan) {
short tangent_mask = 0;
bool calc_active_tangent = false;
if (mr.extract_type == MR_EXTRACT_BMESH) {
if (mr.extract_type == MeshExtractType::BMesh) {
BKE_editmesh_loop_tangent_calc(mr.edit_bmesh,
calc_active_tangent,
r_tangent_names,

View File

@@ -22,14 +22,14 @@ namespace blender::draw {
static bool mesh_extract_uv_format_init(GPUVertFormat *format,
const MeshBatchCache &cache,
const CustomData *cd_ldata,
const eMRExtractType extract_type,
const MeshExtractType extract_type,
uint32_t &r_uv_layers)
{
GPU_vertformat_deinterleave(format);
uint32_t uv_layers = cache.cd_used.uv;
/* HACK to fix #68857 */
if (extract_type == MR_EXTRACT_BMESH && cache.cd_used.edit_uv == 1) {
if (extract_type == MeshExtractType::BMesh && cache.cd_used.edit_uv == 1) {
int layer = CustomData_get_active_layer(cd_ldata, CD_PROP_FLOAT2);
if (layer != -1 && !CustomData_layer_is_anonymous(cd_ldata, CD_PROP_FLOAT2, layer)) {
uv_layers |= (1 << layer);
@@ -83,8 +83,8 @@ void extract_uv_maps(const MeshRenderData &mr, const MeshBatchCache &cache, gpu:
{
GPUVertFormat format = {0};
const CustomData *cd_ldata = (mr.extract_type == MR_EXTRACT_BMESH) ? &mr.bm->ldata :
&mr.mesh->corner_data;
const CustomData *cd_ldata = (mr.extract_type == MeshExtractType::BMesh) ? &mr.bm->ldata :
&mr.mesh->corner_data;
int v_len = mr.corners_num;
uint32_t uv_layers = cache.cd_used.uv;
if (!mesh_extract_uv_format_init(&format, cache, cd_ldata, mr.extract_type, uv_layers)) {
@@ -104,7 +104,7 @@ void extract_uv_maps(const MeshRenderData &mr, const MeshBatchCache &cache, gpu:
MutableSpan<float2> uv_data = vbo.data<float2>();
threading::memory_bandwidth_bound_task(uv_data.size_in_bytes() * 2, [&]() {
if (mr.extract_type == MR_EXTRACT_BMESH) {
if (mr.extract_type == MeshExtractType::BMesh) {
const BMesh &bm = *mr.bm;
for (const int i : uv_indices.index_range()) {
MutableSpan<float2> data = uv_data.slice(i * bm.totloop, bm.totloop);
@@ -144,7 +144,7 @@ void extract_uv_maps_subdiv(const DRWSubdivCache &subdiv_cache,
uint v_len = subdiv_cache.num_subdiv_loops;
uint uv_layers;
if (!mesh_extract_uv_format_init(
&format, cache, &coarse_mesh->corner_data, MR_EXTRACT_MESH, uv_layers))
&format, cache, &coarse_mesh->corner_data, MeshExtractType::Mesh, uv_layers))
{
/* TODO(kevindietrich): handle this more gracefully. */
v_len = 1;

View File

@@ -77,7 +77,7 @@ void extract_vert_normals(const MeshRenderData &mr, gpu::VertBuf &vbo)
GPU_vertbuf_data_alloc(vbo, size);
MutableSpan vbo_data = vbo.data<GPUPackedNormal>();
if (mr.extract_type == MR_EXTRACT_MESH) {
if (mr.extract_type == MeshExtractType::Mesh) {
extract_vert_normals_mesh(mr, vbo_data);
}
else {

View File

@@ -130,7 +130,7 @@ void extract_weights(const MeshRenderData &mr, const MeshBatchCache &cache, gpu:
return;
}
if (mr.extract_type == MR_EXTRACT_MESH) {
if (mr.extract_type == MeshExtractType::Mesh) {
extract_weights_mesh(mr, weight_state, vbo_data);
}
else {