Commit: f07380d01f9b8f2118301a4e4766bea62d2e3edc Author: Hans Goudey Date: Sun Jul 17 12:07:58 2022 -0400 Branches: refactor-mesh-remove-pointers https://developer.blender.org/rBf07380d01f9b8f2118301a4e4766bea62d2e3edc
More progress =================================================================== M source/blender/blenkernel/intern/fluid.c M source/blender/blenkernel/intern/mesh_boolean_convert.cc M source/blender/blenkernel/intern/multires.c M source/blender/blenkernel/intern/object.cc M source/blender/blenkernel/intern/object_deform.c M source/blender/blenkernel/intern/particle.c M source/blender/blenkernel/intern/particle_distribute.c M source/blender/blenkernel/intern/particle_system.c M source/blender/blenkernel/intern/pbvh_pixels.cc M source/blender/blenkernel/intern/rigidbody.c M source/blender/blenkernel/intern/subdiv_ccg_mask.c M source/blender/blenkernel/intern/subdiv_ccg_material.c M source/blender/blenkernel/intern/subdiv_displacement_multires.c M source/blender/blenkernel/intern/volume_to_mesh.cc M source/blender/draw/intern/draw_cache_impl_subdivision.cc M source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_weights.cc M source/blender/editors/armature/armature_skinning.c M source/blender/editors/mesh/mesh_data.cc M source/blender/editors/mesh/mesh_mirror.c M source/blender/editors/mesh/meshtools.cc M source/blender/editors/object/object_bake.c M source/blender/editors/object/object_remesh.cc M source/blender/editors/object/object_vgroup.c M source/blender/editors/physics/particle_edit.c M source/blender/editors/physics/particle_object.c M source/blender/editors/sculpt_paint/paint_image_proj.c M source/blender/editors/sculpt_paint/paint_utils.c M source/blender/editors/sculpt_paint/paint_vertex.cc M source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c M source/blender/editors/sculpt_paint/sculpt_expand.c M source/blender/editors/sculpt_paint/sculpt_face_set.c M source/blender/editors/space_view3d/drawobject.c M source/blender/editors/space_view3d/view3d_iterators.c M source/blender/editors/space_view3d/view3d_select.c M source/blender/geometry/intern/mesh_primitive_cuboid.cc M source/blender/io/alembic/exporter/abc_writer_hair.cc M source/blender/io/alembic/exporter/abc_writer_mesh.cc M source/blender/io/alembic/intern/abc_reader_mesh.cc M source/blender/io/collada/GeometryExporter.cpp M source/blender/io/collada/MeshImporter.cpp M source/blender/io/stl/importer/stl_import_mesh.cc M source/blender/io/usd/intern/usd_reader_mesh.cc M source/blender/io/usd/intern/usd_writer_mesh.cc M source/blender/io/wavefront_obj/exporter/obj_export_mesh.cc M source/blender/io/wavefront_obj/importer/obj_import_mesh.cc M source/blender/io/wavefront_obj/tests/obj_importer_tests.cc M source/blender/makesrna/intern/rna_mesh.c M source/blender/makesrna/intern/rna_mesh_api.c M source/blender/makesrna/intern/rna_particle.c M source/blender/modifiers/intern/MOD_boolean.cc M source/blender/modifiers/intern/MOD_datatransfer.c M source/blender/modifiers/intern/MOD_explode.c M source/blender/modifiers/intern/MOD_meshcache.c M source/blender/modifiers/intern/MOD_meshsequencecache.cc M source/blender/modifiers/intern/MOD_ocean.c M source/blender/modifiers/intern/MOD_surface.c =================================================================== diff --git a/source/blender/blenkernel/intern/fluid.c b/source/blender/blenkernel/intern/fluid.c index fd73e29b197..609e4551bb4 100644 --- a/source/blender/blenkernel/intern/fluid.c +++ b/source/blender/blenkernel/intern/fluid.c @@ -3248,7 +3248,7 @@ static Mesh *create_liquid_geometry(FluidDomainSettings *fds, * If there are no faces in original mesh, keep materials and flags unchanged. */ MPoly *mpoly; MPoly mp_example = {0}; - mpoly = orgmesh->mpoly; + mpoly = BKE_mesh_polygons_for_write(orgmesh); if (mpoly) { mp_example = *mpoly; } diff --git a/source/blender/blenkernel/intern/mesh_boolean_convert.cc b/source/blender/blenkernel/intern/mesh_boolean_convert.cc index 742d3ca8324..31311e173ee 100644 --- a/source/blender/blenkernel/intern/mesh_boolean_convert.cc +++ b/source/blender/blenkernel/intern/mesh_boolean_convert.cc @@ -160,9 +160,10 @@ const MPoly *MeshesToIMeshInfo::input_mpoly_for_orig_index(int orig_index, int orig_mesh_index = input_mesh_for_imesh_face(orig_index); BLI_assert(0 <= orig_mesh_index && orig_mesh_index < meshes.size()); const Mesh *me = meshes[orig_mesh_index]; + MutableSpan<MPoly> polygons = bke::mesh_polygons_for_write(*me); int index_in_mesh = orig_index - mesh_poly_offset[orig_mesh_index]; BLI_assert(0 <= index_in_mesh && index_in_mesh < me->totpoly); - const MPoly *mp = &me->mpoly[index_in_mesh]; + const MPoly *mp = &polygons[index_in_mesh]; if (r_orig_mesh) { *r_orig_mesh = me; } diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index 63945f9ed42..06c9bca8aea 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -183,6 +183,7 @@ static BLI_bitmap *multires_mdisps_downsample_hidden(const BLI_bitmap *old_hidde static void multires_output_hidden_to_ccgdm(CCGDerivedMesh *ccgdm, Mesh *me, int level) { + const MPoly *polygons = BKE_mesh_polygons(me); const MDisps *mdisps = CustomData_get_layer(&me->ldata, CD_MDISPS); BLI_bitmap **grid_hidden = ccgdm->gridHidden; int *gridOffset; @@ -191,7 +192,7 @@ static void multires_output_hidden_to_ccgdm(CCGDerivedMesh *ccgdm, Mesh *me, int gridOffset = ccgdm->dm.getGridOffset(&ccgdm->dm); for (i = 0; i < me->totpoly; i++) { - for (j = 0; j < me->mpoly[i].totloop; j++) { + for (j = 0; j < polygons[i].totloop; j++) { int g = gridOffset[i] + j; const MDisps *md = &mdisps[g]; BLI_bitmap *gh = md->hidden; @@ -466,15 +467,16 @@ void multires_force_external_reload(Object *object) static int get_levels_from_disps(Object *ob) { Mesh *me = ob->data; + const MPoly *polygons = BKE_mesh_polygons(me); MDisps *mdisp, *md; int i, j, totlvl = 0; mdisp = CustomData_get_layer(&me->ldata, CD_MDISPS); for (i = 0; i < me->totpoly; i++) { - md = mdisp + me->mpoly[i].loopstart; + md = mdisp + polygons[i].loopstart; - for (j = 0; j < me->mpoly[i].totloop; j++, md++) { + for (j = 0; j < polygons[i].totloop; j++, md++) { if (md->totdisp == 0) { continue; } @@ -633,6 +635,7 @@ static void multires_grid_paint_mask_downsample(GridPaintMask *gpm, int level) static void multires_del_higher(MultiresModifierData *mmd, Object *ob, int lvl) { Mesh *me = (Mesh *)ob->data; + const MPoly *polygons = BKE_mesh_polygons(me); int levels = mmd->totlvl - lvl; MDisps *mdisps; GridPaintMask *gpm; @@ -652,8 +655,8 @@ static void multires_del_higher(MultiresModifierData *mmd, Object *ob, int lvl) int i, j; for (i = 0; i < me->totpoly; i++) { - for (j = 0; j < me->mpoly[i].totloop; j++) { - int g = me->mpoly[i].loopstart + j; + for (j = 0; j < polygons[i].totloop; j++) { + int g = polygons[i].loopstart + j; MDisps *mdisp = &mdisps[g]; float(*disps)[3], (*ndisps)[3], (*hdisps)[3]; int totdisp = multires_grid_tot[lvl]; @@ -828,7 +831,7 @@ typedef struct MultiresThreadedData { CCGElem **gridData, **subGridData; CCGKey *key; CCGKey *sub_key; - MPoly *mpoly; + const MPoly *mpoly; MDisps *mdisps; GridPaintMask *grid_paint_mask; int *gridOffset; @@ -846,7 +849,7 @@ static void multires_disp_run_cb(void *__restrict userdata, CCGElem **gridData = tdata->gridData; CCGElem **subGridData = tdata->subGridData; CCGKey *key = tdata->key; - MPoly *mpoly = tdata->mpoly; + const MPoly *mpoly = tdata->mpoly; MDisps *mdisps = tdata->mdisps; GridPaintMask *grid_paint_mask = tdata->grid_paint_mask; int *gridOffset = tdata->gridOffset; @@ -939,7 +942,7 @@ static void multiresModifier_disp_run( CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm; CCGElem **gridData, **subGridData; CCGKey key; - MPoly *mpoly = me->mpoly; + const MPoly *mpoly = BKE_mesh_polygons(me); MDisps *mdisps = CustomData_get_layer(&me->ldata, CD_MDISPS); GridPaintMask *grid_paint_mask = NULL; int *gridOffset; diff --git a/source/blender/blenkernel/intern/object.cc b/source/blender/blenkernel/intern/object.cc index f7436b6112c..8848a13a55f 100644 --- a/source/blender/blenkernel/intern/object.cc +++ b/source/blender/blenkernel/intern/object.cc @@ -145,6 +145,8 @@ #include "atomic_ops.h" using blender::float3; +using blender::MutableSpan; +using blender::Span; static CLG_LogRef LOG = {"bke.object"}; @@ -3188,6 +3190,7 @@ static void give_parvert(Object *par, int nr, float vec[3]) BKE_object_get_evaluated_mesh(par); if (me_eval) { + const MVert *vertices = BKE_mesh_vertices(me_eval); int count = 0; int numVerts = me_eval->totvert; @@ -3221,14 +3224,14 @@ static void give_parvert(Object *par, int nr, float vec[3]) /* Get the average of all verts with (original index == nr). */ for (int i = 0; i < numVerts; i++) { if (index[i] == nr) { - add_v3_v3(vec, me_eval->mvert[i].co); + add_v3_v3(vec, vertices[i].co); count++; } } } else { if (nr < numVerts) { - add_v3_v3(vec, me_eval->mvert[nr].co); + add_v3_v3(vec, vertices[nr].co); count++; } } @@ -3242,7 +3245,7 @@ static void give_parvert(Object *par, int nr, float vec[3]) else { /* use first index if its out of range */ if (me_eval->totvert) { - copy_v3_v3(vec, me_eval->mvert[0].co); + copy_v3_v3(vec, vertices[0].co); } } } @@ -4126,10 +4129,10 @@ void BKE_object_foreach_display_point(Object *ob, float3 co; if (mesh_eval != nullptr) { - const MVert *mv = mesh_eval->mvert; + const MVert *vertices = BKE_mesh_vertices(mesh_eval); const int totvert = mesh_eval->totvert; - for (int i = 0; i < totvert; i++, mv++) { - mul_v3_m4v3(co, obmat, mv->co); + for (int i = 0; i < totvert; i++) { + mul_v3_m4v3(co, obmat, vertices[i].co); func_cb(co, user_data); } } @@ -4753,7 +4756,8 @@ bool BKE_object_shapekey_remove(Main *bmain, Object *ob, KeyBlock *kb) switch (ob->type) { case OB_MESH: { Mesh *mesh = (Mesh *)ob->data; - BKE_keyblock_convert_to_mesh(key->refkey, mesh->mvert, mesh->totvert); + MutableSpan<MVert> vertices = blender::bke::mesh_vertices_for_write(*mesh); + BKE_keyblock_convert_to_mesh(key->refkey, vertices.data(), mesh->totvert); break; } case OB_CURVES_LEGACY: @@ -5249,32 +5253,31 @@ KDTree_3d *BKE_object_as_kdtree(Object *ob, int *r_tot) const int *index; if (me_eval && (index = (const int *)CustomData_get_layer(&me_eval->vdata, CD_ORIGINDEX))) { - MVert *mvert = me_eval->mvert; - uint totvert = me_eval->totvert; + const Span<MVert> vertices = blender::bke::mesh_vertices(*me); /* Tree over-allocates in case where some verts have #ORIGINDEX_NONE. */ tot = 0; - tree = BLI_kdtree_3d_new(totvert); + tree = BLI_kdtree_3d_new(vertices.size()); /* We don't how many verts from the DM we can use. */ - for (i = 0; i < totvert; i++) { + for (i = 0; i < vertices.size(); i++) { if (index[i] != ORIGINDEX_NONE) { float co[3]; - mul_v3_m4v3(co, ob->obmat, mvert[i].co); + mul_v3_m4v3(co, ob->obmat, vertices[i].co); BLI_kdtree_3d_insert(tree, index[i], co); tot++; } } } else { - MVert *mvert = me->mvert; + const Span<MVert> vertices = blender::bke::mesh_vertices(*me); - tot = me->totvert; + tot = vertices.size(); tree = BLI_kdtree_3d_new(tot); for (i = 0; i < tot; i++) { float co[3]; - mul_v3_m4v3(co, ob->obmat, mvert[i].co); + mul_v3_m4v3(co, ob->obmat, vertices[i].co); BLI_kdtree_3d_insert(tree, i, co); } } diff --git a/source/blender/blenkernel/intern/object_deform.c b/source/blender/blenkernel/intern/object_deform.c index 04a13493da9..e3eeae706e8 100644 --- a/source/blender/blenkernel/intern/object_deform.c +++ b/source/blender/blenkernel/intern/object_deform.c @@ -162,12 +162,12 @@ bool BKE_object_defgroup_clear(Object *ob, bDeformGroup *dg, const bool use_sele } } else { - if (me->dvert) { + if (CustomData_has_layer(&me->vdata, CD_MDEFORMVERT)) { MVert *mv; int i; - mv = me->mvert; - dv = me->dvert; + mv = BKE_mesh_vertices(me); + dv = BKE_mesh_deform_verts_for_write(me); for (i = 0; i < me->totvert; i++, mv++, dv++) { if (dv->dw && (!use_selection || (mv->flag & SELECT))) { diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 2471d3baa59..1d61a57610c 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -14,7 +14,7 @@ #include "MEM_guardedalloc.h" -#include "DNA_defaults.h" +// #include "DNA_defaults.h" #include "DNA_cloth_types.h" #include "DNA_collection_types.h" @@ -72,7 +72,7 @@ #include "RE_texture.h" -#include @@ Diff output truncated at 10240 characters. @@ _______________________________________________ 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