Commit: 997ad445baf64cb19c1432c53ab7d98e7d1d79b4 Author: Hans Goudey Date: Mon Feb 6 08:39:42 2023 -0500 Branches: refactor-mesh-face-generic https://developer.blender.org/rB997ad445baf64cb19c1432c53ab7d98e7d1d79b4
Move some PBVH code to use offset indices for polygons =================================================================== M source/blender/blenkernel/BKE_pbvh.h M source/blender/blenkernel/intern/paint.cc M source/blender/blenkernel/intern/pbvh.cc M source/blender/blenkernel/intern/pbvh_intern.hh =================================================================== diff --git a/source/blender/blenkernel/BKE_pbvh.h b/source/blender/blenkernel/BKE_pbvh.h index 9d4f8290dfe..b19fa025b00 100644 --- a/source/blender/blenkernel/BKE_pbvh.h +++ b/source/blender/blenkernel/BKE_pbvh.h @@ -278,6 +278,9 @@ typedef void (*BKE_pbvh_SearchNearestCallback)(PBVHNode *node, void *data, float /* Building */ PBVH *BKE_pbvh_new(PBVHType type); + +#ifdef __cplusplus + /** * Do a full rebuild with on Mesh data structure. * @@ -286,7 +289,7 @@ PBVH *BKE_pbvh_new(PBVHType type); */ void BKE_pbvh_build_mesh(PBVH *pbvh, struct Mesh *mesh, - const int *poly_offsets, + blender::OffsetIndices<int> polys, const int *corner_verts, float (*vert_positions)[3], int totvert, @@ -295,6 +298,9 @@ void BKE_pbvh_build_mesh(PBVH *pbvh, struct CustomData *pdata, const struct MLoopTri *looptri, int looptri_num); + +#endif + /** * Do a full rebuild with on Grids data structure. */ @@ -307,6 +313,7 @@ void BKE_pbvh_build_grids(PBVH *pbvh, unsigned int **grid_hidden, struct Mesh *me, struct SubdivCCG *subdiv_ccg); + /** * Build a PBVH from a BMesh. */ diff --git a/source/blender/blenkernel/intern/paint.cc b/source/blender/blenkernel/intern/paint.cc index f16659ce43e..3b1c24a6e66 100644 --- a/source/blender/blenkernel/intern/paint.cc +++ b/source/blender/blenkernel/intern/paint.cc @@ -2180,7 +2180,7 @@ static PBVH *build_pbvh_from_regular_mesh(Object *ob, Mesh *me_eval_deform, bool BKE_pbvh_respect_hide_set(pbvh, respect_hide); MutableSpan<float3> positions = me->vert_positions_for_write(); - const OffsetIndices polys = me->polys(); + const blender::OffsetIndices polys = me->polys(); const Span<int> corner_verts = me->corner_verts(); MLoopTri *looptri = static_cast<MLoopTri *>( @@ -2195,7 +2195,7 @@ static PBVH *build_pbvh_from_regular_mesh(Object *ob, Mesh *me_eval_deform, bool BKE_pbvh_build_mesh(pbvh, me, - polys.data(), + polys, corner_verts.data(), reinterpret_cast<float(*)[3]>(positions.data()), me->totvert, diff --git a/source/blender/blenkernel/intern/pbvh.cc b/source/blender/blenkernel/intern/pbvh.cc index ca0e5a09d83..5f615127267 100644 --- a/source/blender/blenkernel/intern/pbvh.cc +++ b/source/blender/blenkernel/intern/pbvh.cc @@ -823,7 +823,7 @@ static void pbvh_validate_node_prims(PBVH *pbvh) void BKE_pbvh_build_mesh(PBVH *pbvh, Mesh *mesh, - const int *poly_offsets, + const blender::OffsetIndices<int> polys, const int *corner_verts, float (*vert_positions)[3], int totvert, @@ -838,7 +838,7 @@ void BKE_pbvh_build_mesh(PBVH *pbvh, pbvh->mesh = mesh; pbvh->header.type = PBVH_FACES; - pbvh->poly_offsets = poly_offsets; + pbvh->polys = polys; pbvh->hide_poly = static_cast<bool *>(CustomData_get_layer_named_for_write( &mesh->pdata, CD_PROP_BOOL, ".hide_poly", mesh->totpoly)); pbvh->material_indices = static_cast<const int *>( @@ -938,10 +938,10 @@ void BKE_pbvh_build_grids(PBVH *pbvh, /* Find maximum number of grids per face. */ int max_grids = 1; - const int *poly_offsets = BKE_mesh_poly_offsets(me); + const blender::OffsetIndices polys = me->polys(); for (int i = 0; i < me->totpoly; i++) { - max_grids = max_ii(max_grids, poly_offsets[i].totloop); + max_grids = max_ii(max_grids, polys[i].size()); } /* Ensure leaf limit is at least 4 so there's room @@ -955,7 +955,7 @@ void BKE_pbvh_build_grids(PBVH *pbvh, pbvh->ldata = &me->ldata; pbvh->pdata = &me->pdata; - pbvh->poly_offsets = poly_offsets; + pbvh->polys = polys; pbvh->corner_verts = BKE_mesh_corner_verts(me); /* We also need the base mesh for PBVH draw. */ @@ -1427,9 +1427,9 @@ static void pbvh_update_normals_accum_task_cb(void *__restrict userdata, /* Face normal and mask */ if (lt->poly != mpoly_prev) { - const MPoly *mp = &pbvh->mpoly[lt->poly]; + const blender::IndexRange poly = pbvh->polys[lt->poly]; BKE_mesh_calc_poly_normal( - mp, &pbvh->corner_verts[mp->loopstart], pbvh->vert_positions, fn); + {&pbvh->corner_verts[poly.start()], poly.size()}, pbvh->vert_positions, fn); mpoly_prev = lt->poly; } diff --git a/source/blender/blenkernel/intern/pbvh_intern.hh b/source/blender/blenkernel/intern/pbvh_intern.hh index 882b5592a42..9e4f2c5bff4 100644 --- a/source/blender/blenkernel/intern/pbvh_intern.hh +++ b/source/blender/blenkernel/intern/pbvh_intern.hh @@ -155,7 +155,7 @@ struct PBVH { float (*vert_normals)[3]; bool *hide_vert; float (*vert_positions)[3]; - const int *poly_offsets; + blender::OffsetIndices<int> polys; bool *hide_poly; /** Material indices. Only valid for polygon meshes. */ const int *material_indices; _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs