Subdiv: Simplify final vertex counting #105159

Merged
Hans Goudey merged 1 commits from HooglyBoogly/blender:subdiv-vert-count-simplify into main 2023-02-26 23:58:00 +01:00
1 changed files with 4 additions and 17 deletions

View File

@ -167,15 +167,6 @@ static void subdiv_foreach_ctx_count(SubdivForeachTaskContext *ctx)
for (int poly_index = 0; poly_index < coarse_mesh->totpoly; poly_index++) {
const MPoly *coarse_poly = &ctx->coarse_polys[poly_index];
const int num_ptex_faces_per_poly = num_ptex_faces_per_poly_get(coarse_poly);
for (int corner = 0; corner < coarse_poly->totloop; corner++) {
const MLoop *loop = &ctx->coarse_loops[coarse_poly->loopstart + corner];
const bool is_edge_used = BLI_BITMAP_TEST_BOOL(ctx->coarse_edges_used_map, loop->e);
/* Edges which aren't counted yet. */
if (!is_edge_used) {
BLI_BITMAP_ENABLE(ctx->coarse_edges_used_map, loop->e);
ctx->num_subdiv_vertices += num_subdiv_vertices_per_coarse_edge;
}
}
/* Inner vertices of polygon. */
if (num_ptex_faces_per_poly == 1) {
ctx->num_subdiv_vertices += num_inner_vertices_per_quad;
@ -197,12 +188,10 @@ static void subdiv_foreach_ctx_count(SubdivForeachTaskContext *ctx)
num_polys_per_ptex_get(no_quad_patch_resolution);
}
}
/* Calculate extra vertices created by loose edges. */
for (int edge_index = 0; edge_index < coarse_mesh->totedge; edge_index++) {
if (!BLI_BITMAP_TEST_BOOL(ctx->coarse_edges_used_map, edge_index)) {
ctx->num_subdiv_vertices += num_subdiv_vertices_per_coarse_edge;
}
}
/* Add vertices used by outer edges on subdvided faces and loose edges. */
ctx->num_subdiv_vertices += num_subdiv_vertices_per_coarse_edge * coarse_mesh->totedge;
ctx->num_subdiv_loops = ctx->num_subdiv_polygons * 4;
}
@ -270,8 +259,6 @@ static void subdiv_foreach_ctx_init(Subdiv *subdiv, SubdivForeachTaskContext *ct
subdiv_foreach_ctx_init_offsets(ctx);
/* Calculate number of geometry in the result subdivision mesh. */
subdiv_foreach_ctx_count(ctx);
/* Re-set maps which were used at this step. */
BLI_bitmap_set_all(ctx->coarse_edges_used_map, false, coarse_mesh->totedge);
ctx->face_ptex_offset = BKE_subdiv_face_ptex_offset_get(subdiv);
}