[Bf-blender-cvs] [44f8056fdf6] refactor-mesh-remove-pointers: Cleanup, fixes
Hans Goudey
noreply at git.blender.org
Wed Aug 31 20:32:42 CEST 2022
Commit: 44f8056fdf69ee499b22f36e30c0533339eb4c4c
Author: Hans Goudey
Date: Wed Aug 31 13:32:33 2022 -0500
Branches: refactor-mesh-remove-pointers
https://developer.blender.org/rB44f8056fdf69ee499b22f36e30c0533339eb4c4c
Cleanup, fixes
===================================================================
M source/blender/blenkernel/intern/DerivedMesh.cc
M source/blender/blenkernel/intern/dynamicpaint.c
M source/blender/blenkernel/intern/mesh_legacy_convert.cc
M source/blender/editors/curves/intern/curves_ops.cc
M source/blender/editors/object/object_modifier.cc
M source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp
M source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
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.h
M source/blender/io/wavefront_obj/exporter/obj_export_mesh.cc
M source/blender/makesdna/DNA_mesh_types.h
M source/blender/makesrna/intern/rna_mesh.c
M source/blender/modifiers/intern/MOD_meshsequencecache.cc
M source/blender/modifiers/intern/MOD_ocean.c
M source/blender/nodes/geometry/nodes/node_geo_edge_paths_to_curves.cc
M source/blender/nodes/geometry/nodes/node_geo_input_mesh_edge_neighbors.cc
M source/blender/nodes/geometry/nodes/node_geo_material_selection.cc
===================================================================
diff --git a/source/blender/blenkernel/intern/DerivedMesh.cc b/source/blender/blenkernel/intern/DerivedMesh.cc
index c70e6d72e54..cb3f9113747 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.cc
+++ b/source/blender/blenkernel/intern/DerivedMesh.cc
@@ -586,7 +586,7 @@ static void add_orco_mesh(Object *ob, BMEditMesh *em, Mesh *mesh, Mesh *mesh_orc
}
if (!(layerorco = (float(*)[3])CustomData_get_layer(&mesh->vdata, layer))) {
- CustomData_add_layer(&mesh->vdata, layer, CD_CALLOC, nullptr, mesh->totvert);
+ CustomData_add_layer(&mesh->vdata, layer, CD_SET_DEFAULT, nullptr, mesh->totvert);
layerorco = (float(*)[3])CustomData_get_layer(&mesh->vdata, layer);
}
diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c
index c157fb3036b..9c09ebb6973 100644
--- a/source/blender/blenkernel/intern/dynamicpaint.c
+++ b/source/blender/blenkernel/intern/dynamicpaint.c
@@ -1988,7 +1988,7 @@ static Mesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData *pmd, Object *
/* apply weights into a vertex group, if doesn't exists add a new layer */
if (defgrp_index != -1 && !dvert && (surface->output_name[0] != '\0')) {
dvert = CustomData_add_layer(
- &result->vdata, CD_MDEFORMVERT, CD_CALLOC, NULL, sData->total_points);
+ &result->vdata, CD_MDEFORMVERT, CD_SET_DEFAULT, NULL, sData->total_points);
}
if (defgrp_index != -1 && dvert) {
for (int i = 0; i < sData->total_points; i++) {
diff --git a/source/blender/blenkernel/intern/mesh_legacy_convert.cc b/source/blender/blenkernel/intern/mesh_legacy_convert.cc
index db234f78f04..d06c7acfefa 100644
--- a/source/blender/blenkernel/intern/mesh_legacy_convert.cc
+++ b/source/blender/blenkernel/intern/mesh_legacy_convert.cc
@@ -184,7 +184,7 @@ static void convert_mfaces_to_mpolys(ID *id,
CustomData_free(pdata, totpoly_i);
totpoly = totface_i;
- mpoly = (MPoly *)CustomData_add_layer(pdata, CD_MPOLY, CD_CALLOC, nullptr, totpoly);
+ mpoly = (MPoly *)CustomData_add_layer(pdata, CD_MPOLY, CD_SET_DEFAULT, nullptr, totpoly);
numTex = CustomData_number_of_layers(fdata, CD_MTFACE);
numCol = CustomData_number_of_layers(fdata, CD_MCOL);
@@ -195,7 +195,7 @@ static void convert_mfaces_to_mpolys(ID *id,
totloop += mf->v4 ? 4 : 3;
}
- mloop = (MLoop *)CustomData_add_layer(ldata, CD_MLOOP, CD_CALLOC, nullptr, totloop);
+ mloop = (MLoop *)CustomData_add_layer(ldata, CD_MLOOP, CD_SET_DEFAULT, nullptr, totloop);
CustomData_to_bmeshpoly(fdata, ldata, totloop);
@@ -1003,7 +1003,7 @@ void BKE_mesh_legacy_convert_material_indices_to_mpoly(Mesh *mesh)
using namespace blender;
using namespace blender::bke;
const AttributeAccessor attributes = mesh_attributes(*mesh);
- MutableSpan<MPoly> polys(mesh->mpoly, mesh->totpoly);
+ MutableSpan<MPoly> polys = mesh_polygons_for_write(*mesh);
const VArray<int> material_indices = attributes.lookup_or_default<int>(
"material_index", ATTR_DOMAIN_FACE, 0);
threading::parallel_for(polys.index_range(), 4096, [&](IndexRange range) {
@@ -1018,7 +1018,7 @@ void BKE_mesh_legacy_convert_mpoly_to_material_indices(Mesh *mesh)
using namespace blender;
using namespace blender::bke;
MutableAttributeAccessor attributes = mesh_attributes_for_write(*mesh);
- const Span<MPoly> polys(mesh->mpoly, mesh->totpoly);
+ const Span<MPoly> polys = mesh_polygons(*mesh);
if (std::any_of(
polys.begin(), polys.end(), [](const MPoly &poly) { return poly.mat_nr != 0; })) {
SpanAttributeWriter<int> material_indices = attributes.lookup_or_add_for_write_only_span<int>(
diff --git a/source/blender/editors/curves/intern/curves_ops.cc b/source/blender/editors/curves/intern/curves_ops.cc
index e4d0f93ec38..a383d9768d2 100644
--- a/source/blender/editors/curves/intern/curves_ops.cc
+++ b/source/blender/editors/curves/intern/curves_ops.cc
@@ -148,7 +148,6 @@ static int find_mface_for_root_position(const Span<MVert> verts,
if (possible_mface_indices.size() == 1) {
return possible_mface_indices.first();
}
-
/* Find the closest #MFace to #root_pos. */
int mface_i;
float best_distance_sq = FLT_MAX;
diff --git a/source/blender/editors/object/object_modifier.cc b/source/blender/editors/object/object_modifier.cc
index f8d24ad2373..b1cdddb22be 100644
--- a/source/blender/editors/object/object_modifier.cc
+++ b/source/blender/editors/object/object_modifier.cc
@@ -588,9 +588,9 @@ bool ED_object_modifier_convert_psys_to_mesh(ReportList *UNUSED(reports),
me->totvert = verts_num;
me->totedge = edges_num;
- CustomData_add_layer(&me->vdata, CD_MVERT, CD_CALLOC, nullptr, verts_num);
- CustomData_add_layer(&me->edata, CD_MEDGE, CD_CALLOC, nullptr, edges_num);
- CustomData_add_layer(&me->fdata, CD_MFACE, CD_CALLOC, nullptr, 0);
+ CustomData_add_layer(&me->vdata, CD_MVERT, CD_SET_DEFAULT, nullptr, verts_num);
+ CustomData_add_layer(&me->edata, CD_MEDGE, CD_SET_DEFAULT, nullptr, edges_num);
+ CustomData_add_layer(&me->fdata, CD_MFACE, CD_SET_DEFAULT, nullptr, 0);
blender::MutableSpan<MVert> verts = blender::bke::mesh_vertices_for_write(*me);
blender::MutableSpan<MEdge> edges = blender::bke::mesh_edges_for_write(*me);
diff --git a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp
index dcc91e9c0c1..fb51bdab172 100644
--- a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp
+++ b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp
@@ -577,27 +577,26 @@ void BlenderStrokeRenderer::GenerateStrokeMesh(StrokeGroup *group, bool hasTex)
mesh->totcol = group->materials.size();
MVert *vertices = (MVert *)CustomData_add_layer(
- &mesh->vdata, CD_MVERT, CD_CALLOC, nullptr, mesh->totvert);
+ &mesh->vdata, CD_MVERT, CD_SET_DEFAULT, nullptr, mesh->totvert);
MEdge *edges = (MEdge *)CustomData_add_layer(
- &mesh->edata, CD_MEDGE, CD_CALLOC, nullptr, mesh->totedge);
+ &mesh->edata, CD_MEDGE, CD_SET_DEFAULT, nullptr, mesh->totedge);
MPoly *polys = (MPoly *)CustomData_add_layer(
- &mesh->pdata, CD_MPOLY, CD_CALLOC, nullptr, mesh->totpoly);
+ &mesh->pdata, CD_MPOLY, CD_SET_DEFAULT, nullptr, mesh->totpoly);
MLoop *loops = (MLoop *)CustomData_add_layer(
- &mesh->ldata, CD_MLOOP, CD_CALLOC, nullptr, mesh->totloop);
+ &mesh->ldata, CD_MLOOP, CD_SET_DEFAULT, nullptr, mesh->totloop);
int *material_indices = (int *)CustomData_add_layer_named(
&mesh->pdata, CD_PROP_INT32, CD_SET_DEFAULT, nullptr, mesh->totpoly, "material_index");
-
MLoopUV *loopsuv[2] = {nullptr};
if (hasTex) {
// First UV layer
loopsuv[0] = static_cast<MLoopUV *>(CustomData_add_layer_named(
- &mesh->ldata, CD_MLOOPUV, CD_CALLOC, nullptr, mesh->totloop, uvNames[0]));
+ &mesh->ldata, CD_MLOOPUV, CD_SET_DEFAULT, nullptr, mesh->totloop, uvNames[0]));
CustomData_set_layer_active(&mesh->ldata, CD_MLOOPUV, 0);
// Second UV layer
loopsuv[1] = static_cast<MLoopUV *>(CustomData_add_layer_named(
- &mesh->ldata, CD_MLOOPUV, CD_CALLOC, nullptr, mesh->totloop, uvNames[1]));
+ &mesh->ldata, CD_MLOOPUV, CD_SET_DEFAULT, nullptr, mesh->totloop, uvNames[1]));
CustomData_set_layer_active(&mesh->ldata, CD_MLOOPUV, 1);
}
@@ -605,7 +604,7 @@ void BlenderStrokeRenderer::GenerateStrokeMesh(StrokeGroup *group, bool hasTex)
MLoopCol *colors = (MLoopCol *)CustomData_add_layer_named(
&mesh->ldata, CD_PROP_BYTE_COLOR, CD_SET_DEFAULT, nullptr, mesh->totloop, "Color");
MLoopCol *transp = (MLoopCol *)CustomData_add_layer_named(
- &mesh->ldata, CD_PROP_BYTE_COLOR, CD_CALLOC, nullptr, mesh->totloop, "Alpha");
+ &mesh->ldata, CD_PROP_BYTE_COLOR, CD_SET_DEFAULT, nullptr, mesh->totloop, "Alpha");
CustomData_set_layer_active(&mesh->ldata, CD_PROP_BYTE_COLOR, 0);
mesh->mat = (Material **)MEM_mallocN(sizeof(Material *) * mesh->totcol, "MaterialList");
diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
index 6055433562a..a9cd6c89fc5 100644
--- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
+++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
@@ -1641,7 +1641,6 @@ static void lineart_identify_mlooptri_feature_edges(void *__restrict userdata,
const MPoly *polys = BKE_mesh_polygons(me);
if (ld->conf.use_crease) {
-
bool do_crease = true;
if (!ld->conf.force_crease && !e_feat_data->use_auto_smooth &&
(polys[mlooptri[f1].poly].flag & ME_SMOOTH) &&
diff --git a/source/blender/io/collada/MeshImporter.cpp b/source/blender/io/collada/MeshImporter.cpp
index 984cf50de2e..b2852199157 100644
--- a/source/blender/io/collada/MeshImporter.cpp
+++ b/source/blender/io/collada/MeshImporter.cpp
@@ -343,7 +343,7 @@ void MeshImporter::read_vertices(COLLADAFW::Mesh *mesh, Mesh *me)
}
me->totvert = pos.getFloatValues()->getCount() / stride;
- CustomData_add_layer(&me->vdata, CD_MVERT, CD_CALLOC, nullptr, me->totvert);
+ CustomData_add_layer(&me->vdata, CD_MVERT, CD_SET_DEFAULT, nullptr, me->totvert);
MutableSpan<MVert> verts = blender::bke::mesh_vertices_for_write(*me);
for (const int i : verts.index_range()) {
get_vector(verts[i].co, pos, i, stride);
@@ -447,10 +447,8 @@ void MeshImporter::allocate_poly_data(COLLADAFW::Mesh *collada_mesh, Mesh *me)
if (total_poly_count > 0) {
me->totpoly = total_poly_count;
me->totloop = total_loop_count;
- me->mpoly = (MPoly *)CustomData_add_layer(
- &me->pdata, CD_MPOLY, CD_CALLOC, nullptr, me->totpoly);
- me->mloop = (MLoop *)CustomData_add_layer(
- &me->ldata, CD_MLOOP, CD_CALLOC, nullptr, me->totloop);
+ CustomData_add_layer(&me->pdata, CD_MPOLY, CD_SET_DEFAULT, nullptr, me->totpoly);
+ CustomData_add_layer(&me->ldata, CD_MLOOP, CD_SET_DEFAULT, nullptr, me->totloop);
unsigned int totuvset = collada_mesh->getUVCoords().getInputInfosArray().getCount();
for (int i = 0; i < totuvs
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list