Cleanup: Remove legacy argument from mesh creation functions

The legacy `tessface_len` argument was only used for the explode
modifier. Remove it and copy the legacy face data manually there.
This commit is contained in:
Hans Goudey 2023-02-27 11:09:26 -05:00
parent 494becdec9
commit 96abaae9ac
52 changed files with 86 additions and 112 deletions

View File

@ -158,18 +158,12 @@ void BKE_mesh_copy_parameters_for_eval(struct Mesh *me_dst, const struct Mesh *m
void BKE_mesh_copy_parameters(struct Mesh *me_dst, const struct Mesh *me_src);
void BKE_mesh_ensure_skin_customdata(struct Mesh *me);
struct Mesh *BKE_mesh_new_nomain(
int verts_len, int edges_len, int tessface_len, int loops_len, int polys_len);
struct Mesh *BKE_mesh_new_nomain_from_template(const struct Mesh *me_src,
int verts_len,
int edges_len,
int tessface_len,
int loops_len,
int polys_len);
struct Mesh *BKE_mesh_new_nomain(int verts_len, int edges_len, int loops_len, int polys_len);
struct Mesh *BKE_mesh_new_nomain_from_template(
const struct Mesh *me_src, int verts_len, int edges_len, int loops_len, int polys_len);
struct Mesh *BKE_mesh_new_nomain_from_template_ex(const struct Mesh *me_src,
int verts_len,
int edges_len,
int tessface_len,
int loops_len,
int polys_len,
struct CustomData_MeshMasks mask);

View File

@ -639,7 +639,7 @@ static Mesh *modifier_modify_mesh_and_geometry_set(ModifierData *md,
/* Return an empty mesh instead of null. */
if (mesh_output == nullptr) {
mesh_output = BKE_mesh_new_nomain(0, 0, 0, 0, 0);
mesh_output = BKE_mesh_new_nomain(0, 0, 0, 0);
BKE_mesh_copy_parameters_for_eval(mesh_output, input_mesh);
}
}

View File

@ -667,7 +667,7 @@ Mesh *curve_to_mesh_sweep(const CurvesGeometry &main,
}
Mesh *mesh = BKE_mesh_new_nomain(
offsets.vert.last(), offsets.edge.last(), 0, offsets.loop.last(), offsets.poly.last());
offsets.vert.last(), offsets.edge.last(), offsets.loop.last(), offsets.poly.last());
mesh->flag |= ME_AUTOSMOOTH;
mesh->smoothresh = DEG2RADF(180.0f);
MutableSpan<float3> positions = mesh->vert_positions_for_write();

View File

@ -738,7 +738,7 @@ static GeometrySet curve_calc_modifiers_post(Depsgraph *depsgraph,
blender::bke::ScopedModifierTimer modifier_timer{*md};
if (!geometry_set.has_mesh()) {
geometry_set.replace_mesh(BKE_mesh_new_nomain(0, 0, 0, 0, 0));
geometry_set.replace_mesh(BKE_mesh_new_nomain(0, 0, 0, 0));
}
Mesh *mesh = geometry_set.get_mesh_for_write();
@ -885,7 +885,7 @@ static GeometrySet evaluate_surface_object(Depsgraph *depsgraph,
GeometrySet geometry_set = curve_calc_modifiers_post(
depsgraph, scene, ob, r_dispbase, for_render);
if (!geometry_set.has_mesh()) {
geometry_set.replace_mesh(BKE_mesh_new_nomain(0, 0, 0, 0, 0));
geometry_set.replace_mesh(BKE_mesh_new_nomain(0, 0, 0, 0));
}
return geometry_set;
}

View File

@ -3248,7 +3248,7 @@ static Mesh *create_liquid_geometry(FluidDomainSettings *fds,
return nullptr;
}
me = BKE_mesh_new_nomain(num_verts, 0, 0, num_faces * 3, num_faces);
me = BKE_mesh_new_nomain(num_verts, 0, num_faces * 3, num_faces);
if (!me) {
return nullptr;
}
@ -3386,7 +3386,7 @@ static Mesh *create_smoke_geometry(FluidDomainSettings *fds, Mesh *orgmesh, Obje
return BKE_mesh_copy_for_eval(orgmesh, false);
}
result = BKE_mesh_new_nomain(num_verts, 0, 0, num_faces * 4, num_faces);
result = BKE_mesh_new_nomain(num_verts, 0, num_faces * 4, num_faces);
float(*positions)[3] = BKE_mesh_vert_positions_for_write(result);
mpolys = BKE_mesh_polys_for_write(result);
mloops = BKE_mesh_loops_for_write(result);

View File

@ -956,7 +956,7 @@ Mesh *BKE_mesh_add(Main *bmain, const char *name)
}
/* Custom data layer functions; those assume that totXXX are set correctly. */
static void mesh_ensure_cdlayers_primary(Mesh *mesh, bool do_tessface)
static void mesh_ensure_cdlayers_primary(Mesh *mesh)
{
if (!CustomData_get_layer_named(&mesh->vdata, CD_PROP_FLOAT3, "position")) {
CustomData_add_layer_named(
@ -971,14 +971,9 @@ static void mesh_ensure_cdlayers_primary(Mesh *mesh, bool do_tessface)
if (!CustomData_get_layer(&mesh->pdata, CD_MPOLY)) {
CustomData_add_layer(&mesh->pdata, CD_MPOLY, CD_SET_DEFAULT, nullptr, mesh->totpoly);
}
if (do_tessface && !CustomData_get_layer(&mesh->fdata, CD_MFACE)) {
CustomData_add_layer(&mesh->fdata, CD_MFACE, CD_SET_DEFAULT, nullptr, mesh->totface);
}
}
Mesh *BKE_mesh_new_nomain(
int verts_len, int edges_len, int tessface_len, int loops_len, int polys_len)
Mesh *BKE_mesh_new_nomain(int verts_len, int edges_len, int loops_len, int polys_len)
{
Mesh *mesh = (Mesh *)BKE_libblock_alloc(
nullptr, ID_ME, BKE_idtype_idcode_to_name(ID_ME), LIB_ID_CREATE_LOCALIZE);
@ -993,11 +988,10 @@ Mesh *BKE_mesh_new_nomain(
mesh->totvert = verts_len;
mesh->totedge = edges_len;
mesh->totface = tessface_len;
mesh->totloop = loops_len;
mesh->totpoly = polys_len;
mesh_ensure_cdlayers_primary(mesh, true);
mesh_ensure_cdlayers_primary(mesh);
return mesh;
}
@ -1060,21 +1054,17 @@ void BKE_mesh_copy_parameters_for_eval(Mesh *me_dst, const Mesh *me_src)
Mesh *BKE_mesh_new_nomain_from_template_ex(const Mesh *me_src,
int verts_len,
int edges_len,
int tessface_len,
int loops_len,
int polys_len,
CustomData_MeshMasks mask)
{
/* Only do tessface if we are creating tessfaces or copying from mesh with only tessfaces. */
const bool do_tessface = (tessface_len || ((me_src->totface != 0) && (me_src->totpoly == 0)));
Mesh *me_dst = (Mesh *)BKE_id_new_nomain(ID_ME, nullptr);
me_dst->mselect = (MSelect *)MEM_dupallocN(me_src->mselect);
me_dst->totvert = verts_len;
me_dst->totedge = edges_len;
me_dst->totface = tessface_len;
me_dst->totface = 0;
me_dst->totloop = loops_len;
me_dst->totpoly = polys_len;
@ -1084,16 +1074,11 @@ Mesh *BKE_mesh_new_nomain_from_template_ex(const Mesh *me_src,
CustomData_copy(&me_src->edata, &me_dst->edata, mask.emask, CD_SET_DEFAULT, edges_len);
CustomData_copy(&me_src->ldata, &me_dst->ldata, mask.lmask, CD_SET_DEFAULT, loops_len);
CustomData_copy(&me_src->pdata, &me_dst->pdata, mask.pmask, CD_SET_DEFAULT, polys_len);
if (do_tessface) {
CustomData_copy(&me_src->fdata, &me_dst->fdata, mask.fmask, CD_SET_DEFAULT, tessface_len);
}
else {
mesh_tessface_clear_intern(me_dst, false);
}
mesh_tessface_clear_intern(me_dst, false);
/* The destination mesh should at least have valid primary CD layers,
* even in cases where the source mesh does not. */
mesh_ensure_cdlayers_primary(me_dst, do_tessface);
mesh_ensure_cdlayers_primary(me_dst);
/* Expect that normals aren't copied at all, since the destination mesh is new. */
BLI_assert(BKE_mesh_vertex_normals_are_dirty(me_dst));
@ -1101,15 +1086,11 @@ Mesh *BKE_mesh_new_nomain_from_template_ex(const Mesh *me_src,
return me_dst;
}
Mesh *BKE_mesh_new_nomain_from_template(const Mesh *me_src,
int verts_len,
int edges_len,
int tessface_len,
int loops_len,
int polys_len)
Mesh *BKE_mesh_new_nomain_from_template(
const Mesh *me_src, int verts_len, int edges_len, int loops_len, int polys_len)
{
return BKE_mesh_new_nomain_from_template_ex(
me_src, verts_len, edges_len, tessface_len, loops_len, polys_len, CD_MASK_EVERYTHING);
me_src, verts_len, edges_len, loops_len, polys_len, CD_MASK_EVERYTHING);
}
void BKE_mesh_eval_delete(struct Mesh *mesh_eval)

View File

@ -713,7 +713,7 @@ static Mesh *imesh_to_mesh(IMesh *im, MeshesToIMeshInfo &mim)
}
/* Will calculate edges later. */
Mesh *result = BKE_mesh_new_nomain_from_template(
mim.meshes[0], out_totvert, 0, 0, out_totloop, out_totpoly);
mim.meshes[0], out_totvert, 0, out_totloop, out_totpoly);
merge_vertex_loop_poly_customdata_layers(result, mim);
/* Set the vertex coordinate values and other data. */

View File

@ -186,10 +186,10 @@ static Mesh *mesh_nurbs_displist_to_mesh(const Curve *cu, const ListBase *dispba
}
if (totvert == 0) {
return BKE_mesh_new_nomain(0, 0, 0, 0, 0);
return BKE_mesh_new_nomain(0, 0, 0, 0);
}
Mesh *mesh = BKE_mesh_new_nomain(totvert, totedge, 0, totloop, totpoly);
Mesh *mesh = BKE_mesh_new_nomain(totvert, totedge, totloop, totpoly);
MutableSpan<float3> positions = mesh->vert_positions_for_write();
MutableSpan<MEdge> edges = mesh->edges_for_write();
MutableSpan<MPoly> polys = mesh->polys_for_write();

View File

@ -195,7 +195,7 @@ Mesh *BKE_mesh_mirror_apply_mirror_on_axis_for_modifier(MirrorModifierData *mmd,
const int maxPolys = mesh->totpoly;
result = BKE_mesh_new_nomain_from_template(
mesh, maxVerts * 2, maxEdges * 2, 0, maxLoops * 2, maxPolys * 2);
mesh, maxVerts * 2, maxEdges * 2, maxLoops * 2, maxPolys * 2);
/* Copy custom-data to original geometry. */
CustomData_copy_data(&mesh->vdata, &result->vdata, 0, 0, maxVerts);

View File

@ -120,7 +120,7 @@ static Mesh *remesh_quadriflow(const Mesh *input_mesh,
}
/* Construct the new output mesh */
Mesh *mesh = BKE_mesh_new_nomain(qrd.out_totverts, 0, 0, qrd.out_totfaces * 4, qrd.out_totfaces);
Mesh *mesh = BKE_mesh_new_nomain(qrd.out_totverts, 0, qrd.out_totfaces * 4, qrd.out_totfaces);
BKE_mesh_copy_parameters(mesh, input_mesh);
MutableSpan<MPoly> polys = mesh->polys_for_write();
MutableSpan<MLoop> loops = mesh->loops_for_write();
@ -224,7 +224,7 @@ static Mesh *remesh_voxel_volume_to_mesh(const openvdb::FloatGrid::Ptr level_set
*level_set_grid, vertices, tris, quads, isovalue, adaptivity, relax_disoriented_triangles);
Mesh *mesh = BKE_mesh_new_nomain(
vertices.size(), 0, 0, quads.size() * 4 + tris.size() * 3, quads.size() + tris.size());
vertices.size(), 0, quads.size() * 4 + tris.size() * 3, quads.size() + tris.size());
MutableSpan<float3> vert_positions = mesh->vert_positions_for_write();
MutableSpan<MPoly> mesh_polys = mesh->polys_for_write();
MutableSpan<MLoop> mesh_loops = mesh->loops_for_write();

View File

@ -1149,7 +1149,7 @@ bool multires_unsubdivide_to_basemesh(MultiresUnsubdivideContext *context)
context->num_total_levels = context->num_new_levels + context->num_original_levels;
/* Store the new base-mesh as a mesh in context, free bmesh. */
context->base_mesh = BKE_mesh_new_nomain(0, 0, 0, 0, 0);
context->base_mesh = BKE_mesh_new_nomain(0, 0, 0, 0);
BMeshToMeshParams bm_to_me_params{};
bm_to_me_params.calc_object_remap = true;

View File

@ -3320,7 +3320,7 @@ static void hair_create_input_mesh(ParticleSimulationData *sim,
mesh = *r_mesh;
if (!mesh) {
*r_mesh = mesh = BKE_mesh_new_nomain(totpoint, totedge, 0, 0, 0);
*r_mesh = mesh = BKE_mesh_new_nomain(totpoint, totedge, 0, 0);
}
float(*positions)[3] = BKE_mesh_vert_positions_for_write(mesh);
medge = BKE_mesh_edges_for_write(mesh);

View File

@ -614,7 +614,7 @@ Mesh *BKE_subdiv_to_ccg_mesh(Subdiv *subdiv,
if (subdiv_ccg == nullptr) {
return nullptr;
}
Mesh *result = BKE_mesh_new_nomain_from_template(coarse_mesh, 0, 0, 0, 0, 0);
Mesh *result = BKE_mesh_new_nomain_from_template(coarse_mesh, 0, 0, 0, 0);
result->runtime->subdiv_ccg = subdiv_ccg;
return result;
}

View File

@ -535,7 +535,7 @@ static bool subdiv_mesh_topology_info(const SubdivForeachContext *foreach_contex
SubdivMeshContext *subdiv_context = static_cast<SubdivMeshContext *>(foreach_context->user_data);
subdiv_context->subdiv_mesh = BKE_mesh_new_nomain_from_template_ex(
subdiv_context->coarse_mesh, num_vertices, num_edges, 0, num_loops, num_polygons, mask);
subdiv_context->coarse_mesh, num_vertices, num_edges, num_loops, num_polygons, mask);
subdiv_mesh_ctx_cache_custom_data_layers(subdiv_context);
subdiv_mesh_prepare_accumulator(subdiv_context, num_vertices);
subdiv_context->subdiv_mesh->runtime->subsurf_face_dot_tags.clear();

View File

@ -167,7 +167,7 @@ Mesh *volume_to_mesh(const openvdb::GridBase &grid,
const int tot_loops = 3 * mesh_data.tris.size() + 4 * mesh_data.quads.size();
const int tot_polys = mesh_data.tris.size() + mesh_data.quads.size();
Mesh *mesh = BKE_mesh_new_nomain(mesh_data.verts.size(), 0, 0, tot_loops, tot_polys);
Mesh *mesh = BKE_mesh_new_nomain(mesh_data.verts.size(), 0, tot_loops, tot_polys);
fill_mesh_from_openvdb_data(mesh_data.verts,
mesh_data.tris,

View File

@ -819,8 +819,8 @@ static int delete_soft(const char *file, const char **error_message)
Class NSStringClass = objc_getClass("NSString");
SEL stringWithUTF8StringSel = sel_registerName("stringWithUTF8String:");
id pathString = ((id(*)(Class, SEL, const char *))objc_msgSend)(
NSStringClass, stringWithUTF8StringSel, file);
id pathString = ((
id(*)(Class, SEL, const char *))objc_msgSend)(NSStringClass, stringWithUTF8StringSel, file);
Class NSFileManagerClass = objc_getClass("NSFileManager");
SEL defaultManagerSel = sel_registerName("defaultManager");
@ -831,8 +831,8 @@ static int delete_soft(const char *file, const char **error_message)
id nsurl = ((id(*)(Class, SEL, id))objc_msgSend)(NSURLClass, fileURLWithPathSel, pathString);
SEL trashItemAtURLSel = sel_registerName("trashItemAtURL:resultingItemURL:error:");
BOOL deleteSuccessful = ((BOOL(*)(id, SEL, id, id, id))objc_msgSend)(
fileManager, trashItemAtURLSel, nsurl, nil, nil);
BOOL deleteSuccessful = ((
BOOL(*)(id, SEL, id, id, id))objc_msgSend)(fileManager, trashItemAtURLSel, nsurl, nil, nil);
if (deleteSuccessful) {
ret = 0;

View File

@ -1143,8 +1143,7 @@ static void sculpt_gesture_trim_geometry_generate(SculptGestureContext *sgcontex
const int trim_totverts = tot_screen_points * 2;
const int trim_totpolys = (2 * (tot_screen_points - 2)) + (2 * tot_screen_points);
trim_operation->mesh = BKE_mesh_new_nomain(
trim_totverts, 0, 0, trim_totpolys * 3, trim_totpolys);
trim_operation->mesh = BKE_mesh_new_nomain(trim_totverts, 0, trim_totpolys * 3, trim_totpolys);
trim_operation->true_mesh_co = static_cast<float(*)[3]>(
MEM_malloc_arrayN(trim_totverts, sizeof(float[3]), "mesh orco"));

View File

@ -1521,7 +1521,7 @@ static Mesh *create_merged_mesh(const Mesh &mesh,
const int result_npolys = src_polys.size() - weld_mesh.poly_kill_len + weld_mesh.wpoly_new_len;
Mesh *result = BKE_mesh_new_nomain_from_template(
&mesh, result_nverts, result_nedges, 0, result_nloops, result_npolys);
&mesh, result_nverts, result_nedges, result_nloops, result_npolys);
MutableSpan<MEdge> dst_edges = result->edges_for_write();
MutableSpan<MPoly> dst_polys = result->polys_for_write();
MutableSpan<MLoop> dst_loops = result->loops_for_write();

View File

@ -403,8 +403,7 @@ Mesh *create_cuboid_mesh(const float3 &size,
{
const CuboidConfig config(size, verts_x, verts_y, verts_z);
Mesh *mesh = BKE_mesh_new_nomain(
config.vertex_count, 0, 0, config.loop_count, config.poly_count);
Mesh *mesh = BKE_mesh_new_nomain(config.vertex_count, 0, config.loop_count, config.poly_count);
MutableSpan<float3> positions = mesh->vert_positions_for_write();
MutableSpan<MPoly> polys = mesh->polys_for_write();
MutableSpan<MLoop> loops = mesh->loops_for_write();

View File

@ -1073,7 +1073,7 @@ static void execute_realize_mesh_tasks(const RealizeInstancesOptions &options,
const int tot_loops = last_task.start_indices.loop + last_mesh.totloop;
const int tot_poly = last_task.start_indices.poly + last_mesh.totpoly;
Mesh *dst_mesh = BKE_mesh_new_nomain(tot_vertices, tot_edges, 0, tot_loops, tot_poly);
Mesh *dst_mesh = BKE_mesh_new_nomain(tot_vertices, tot_edges, tot_loops, tot_poly);
MeshComponent &dst_component = r_realized_geometry.get_component_for_write<MeshComponent>();
dst_component.replace(dst_mesh);
bke::MutableAttributeAccessor dst_attributes = dst_mesh->attributes_for_write();

View File

@ -726,7 +726,7 @@ Mesh *AbcMeshReader::read_mesh(Mesh *existing_mesh,
if (topology_changed(existing_mesh, sample_sel)) {
new_mesh = BKE_mesh_new_nomain_from_template(
existing_mesh, positions->size(), 0, 0, face_indices->size(), face_counts->size());
existing_mesh, positions->size(), 0, face_indices->size(), face_counts->size());
settings.read_flag |= MOD_MESHSEQ_READ_ALL;
}
@ -1059,7 +1059,7 @@ Mesh *AbcSubDReader::read_mesh(Mesh *existing_mesh,
if (existing_mesh->totvert != positions->size()) {
new_mesh = BKE_mesh_new_nomain_from_template(
existing_mesh, positions->size(), 0, 0, face_indices->size(), face_counts->size());
existing_mesh, positions->size(), 0, face_indices->size(), face_counts->size());
settings.read_flag |= MOD_MESHSEQ_READ_ALL;
}

View File

@ -134,7 +134,7 @@ struct Mesh *AbcPointsReader::read_mesh(struct Mesh *existing_mesh,
Mesh *new_mesh = nullptr;
if (existing_mesh->totvert != positions->size()) {
new_mesh = BKE_mesh_new_nomain(positions->size(), 0, 0, 0, 0);
new_mesh = BKE_mesh_new_nomain(positions->size(), 0, 0, 0);
}
Mesh *mesh_to_export = new_mesh ? new_mesh : existing_mesh;

View File

@ -844,7 +844,7 @@ Mesh *USDMeshReader::read_mesh(Mesh *existing_mesh,
if (topology_changed(existing_mesh, params.motion_sample_time)) {
new_mesh = true;
active_mesh = BKE_mesh_new_nomain_from_template(
existing_mesh, positions_.size(), 0, 0, face_indices_.size(), face_counts_.size());
existing_mesh, positions_.size(), 0, face_indices_.size(), face_counts_.size());
for (pxr::TfToken token : uv_tokens) {
add_customdata_cb(active_mesh, token.GetText(), CD_PROP_FLOAT2);

View File

@ -186,7 +186,7 @@ Mesh *USDShapeReader::mesh_from_prim(Mesh *existing_mesh,
Mesh *active_mesh = nullptr;
if (!position_counts_match || !poly_counts_match) {
active_mesh = BKE_mesh_new_nomain_from_template(
existing_mesh, positions.size(), 0, 0, face_indices.size(), face_counts.size());
existing_mesh, positions.size(), 0, face_indices.size(), face_counts.size());
}
else {
active_mesh = existing_mesh;

View File

@ -48,7 +48,7 @@ Object *MeshFromGeometry::create_mesh(Main *bmain,
const int64_t tot_face_elems{mesh_geometry_.face_elements_.size()};
const int64_t tot_loops{mesh_geometry_.total_loops_};
Mesh *mesh = BKE_mesh_new_nomain(tot_verts_object, tot_edges, 0, tot_loops, tot_face_elems);
Mesh *mesh = BKE_mesh_new_nomain(tot_verts_object, tot_edges, tot_loops, tot_face_elems);
Object *obj = BKE_object_add_only_object(bmain, OB_MESH, ob_name.c_str());
obj->data = BKE_object_obdata_add_from_type(bmain, OB_MESH, ob_name.c_str());

View File

@ -539,7 +539,7 @@ static Mesh *arrayModifier_doArray(ArrayModifierData *amd,
/* Initialize a result dm */
result = BKE_mesh_new_nomain_from_template(
mesh, result_nverts, result_nedges, 0, result_nloops, result_npolys);
mesh, result_nverts, result_nedges, result_nloops, result_npolys);
float(*result_positions)[3] = BKE_mesh_vert_positions_for_write(result);
blender::MutableSpan<MEdge> result_edges = result->edges_for_write();
blender::MutableSpan<MPoly> result_polys = result->polys_for_write();

View File

@ -127,7 +127,7 @@ static Mesh *get_quick_mesh(
if (mesh_self->totpoly == 0 || mesh_operand_ob->totpoly == 0) {
switch (operation) {
case eBooleanModifierOp_Intersect:
result = BKE_mesh_new_nomain(0, 0, 0, 0, 0);
result = BKE_mesh_new_nomain(0, 0, 0, 0);
break;
case eBooleanModifierOp_Union:

View File

@ -197,7 +197,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
/* now we know the number of verts, edges and faces, we can create the mesh. */
result = BKE_mesh_new_nomain_from_template(
mesh, BLI_ghash_len(vertHash), BLI_ghash_len(edgeHash), 0, loops_dst_num, faces_dst_num);
mesh, BLI_ghash_len(vertHash), BLI_ghash_len(edgeHash), loops_dst_num, faces_dst_num);
blender::MutableSpan<MEdge> result_edges = result->edges_for_write();
blender::MutableSpan<MPoly> result_polys = result->polys_for_write();
blender::MutableSpan<MLoop> result_loops = result->loops_for_write();

View File

@ -739,7 +739,13 @@ static Mesh *cutEdges(ExplodeModifierData *emd, Mesh *mesh)
totfsplit += add_faces[*fs];
}
split_m = BKE_mesh_new_nomain_from_template(mesh, totesplit, 0, totface + totfsplit, 0, 0);
split_m = BKE_mesh_new_nomain_from_template(mesh, totesplit, 0, 0, 0);
split_m->totface = totface + totfsplit;
CustomData_copy(
&split_m->fdata, &mesh->fdata, CD_MASK_EVERYTHING.fmask, CD_SET_DEFAULT, split_m->totface);
if (!CustomData_get_layer(&split_m->fdata, CD_MFACE)) {
CustomData_add_layer(&split_m->fdata, CD_MFACE, CD_SET_DEFAULT, nullptr, split_m->totface);
}
layers_num = CustomData_number_of_layers(&split_m->fdata, CD_MTFACE);
@ -986,7 +992,13 @@ static Mesh *explodeMesh(ExplodeModifierData *emd,
BLI_edgehashIterator_free(ehi);
/* the final duplicated vertices */
explode = BKE_mesh_new_nomain_from_template(mesh, totdup, 0, totface - delface, 0, 0);
explode = BKE_mesh_new_nomain_from_template(mesh, totdup, 0, 0, 0);
explode->totface = totface - delface;
CustomData_copy(
&explode->fdata, &mesh->fdata, CD_MASK_EVERYTHING.fmask, CD_SET_DEFAULT, explode->totface);
if (!CustomData_get_layer(&explode->fdata, CD_MFACE)) {
CustomData_add_layer(&explode->fdata, CD_MFACE, CD_SET_DEFAULT, nullptr, explode->totface);
}
MTFace *mtface = static_cast<MTFace *>(CustomData_get_layer_named_for_write(
&explode->fdata, CD_MTFACE, emd->uvname, explode->totface));

View File

@ -627,7 +627,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext * /*ctx*/, M
/* Return empty or input mesh when there are no vertex groups. */
const Span<MDeformVert> dverts = mesh->deform_verts();
if (dverts.is_empty()) {
return invert_mask ? mesh : BKE_mesh_new_nomain_from_template(mesh, 0, 0, 0, 0, 0);
return invert_mask ? mesh : BKE_mesh_new_nomain_from_template(mesh, 0, 0, 0, 0);
}
/* Quick test to see if we can return early. */
@ -713,7 +713,6 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext * /*ctx*/, M
Mesh *result = BKE_mesh_new_nomain_from_template(mesh,
verts_masked_num + verts_add_num,
edges_masked_num + edges_add_num,
0,
loops_masked_num + loops_add_num,
polys_masked_num + polys_add_num);

View File

@ -1378,7 +1378,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
Mesh *new_mesh = geometry_set.get_component_for_write<MeshComponent>().release();
if (new_mesh == nullptr) {
return BKE_mesh_new_nomain(0, 0, 0, 0, 0);
return BKE_mesh_new_nomain(0, 0, 0, 0);
}
return new_mesh;
}

View File

@ -266,7 +266,7 @@ static Mesh *generate_ocean_geometry(OceanModifierData *omd, Mesh *mesh_orig, co
gogd.sx /= gogd.rx;
gogd.sy /= gogd.ry;
result = BKE_mesh_new_nomain(verts_num, 0, 0, polys_num * 4, polys_num);
result = BKE_mesh_new_nomain(verts_num, 0, polys_num * 4, polys_num);
BKE_mesh_copy_parameters_for_eval(result, mesh_orig);
gogd.vert_positions = BKE_mesh_vert_positions_for_write(result);

View File

@ -312,7 +312,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
max_co = max[track];
}
result = BKE_mesh_new_nomain_from_template(mesh, maxvert, maxedge, 0, maxloop, maxpoly);
result = BKE_mesh_new_nomain_from_template(mesh, maxvert, maxedge, maxloop, maxpoly);
const blender::Span<MPoly> orig_polys = mesh->polys();
const blender::Span<MLoop> orig_loops = mesh->loops();

View File

@ -93,7 +93,7 @@ static void *dualcon_alloc_output(int totvert, int totquad)
return nullptr;
}
output->mesh = BKE_mesh_new_nomain(totvert, 0, 0, 4 * totquad, totquad);
output->mesh = BKE_mesh_new_nomain(totvert, 0, 4 * totquad, totquad);
output->vert_positions = BKE_mesh_vert_positions_for_write(output->mesh);
output->polys = output->mesh->polys_for_write().data();
output->loops = output->mesh->loops_for_write().data();

View File

@ -261,7 +261,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
/* don't do anything? */
if (!totvert) {
return BKE_mesh_new_nomain_from_template(mesh, 0, 0, 0, 0, 0);
return BKE_mesh_new_nomain_from_template(mesh, 0, 0, 0, 0);
}
switch (ltmd->axis) {
@ -390,7 +390,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
const bool do_remove_doubles = (ltmd->flag & MOD_SCREW_MERGE) && (screw_ofs == 0.0f);
result = BKE_mesh_new_nomain_from_template(
mesh, int(maxVerts), int(maxEdges), 0, int(maxPolys) * 4, int(maxPolys));
mesh, int(maxVerts), int(maxEdges), int(maxPolys) * 4, int(maxPolys));
/* The modifier doesn't support original index mapping on the edge or face domains. Remove
* original index layers, since otherwise edges aren't displayed at all in wireframe view. */
CustomData_free_layers(&result->edata, CD_ORIGINDEX, result->totedge);

View File

@ -918,7 +918,7 @@ static Mesh *subdivide_base(const Mesh *orig)
/* Allocate output mesh */
Mesh *result = BKE_mesh_new_nomain_from_template(
orig, orig_vert_num + subd_num, orig_edge_num + subd_num, 0, 0, 0);
orig, orig_vert_num + subd_num, orig_edge_num + subd_num, 0, 0);
float(*out_vert_positions)[3] = BKE_mesh_vert_positions_for_write(result);
MEdge *outedge = BKE_mesh_edges_for_write(result);

View File

@ -327,7 +327,6 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex
result = BKE_mesh_new_nomain_from_template(mesh,
int((verts_num * stride) + newVerts),
int((edges_num * stride) + newEdges + rimVerts),
0,
int((loops_num * stride) + newLoops),
int((polys_num * stride) + newPolys));

View File

@ -1988,7 +1988,7 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData *md,
/* Create Mesh *result with proper capacity. */
result = BKE_mesh_new_nomain_from_template(
mesh, int(new_verts_num), int(new_edges_num), 0, int(new_loops_num), int(new_polys_num));
mesh, int(new_verts_num), int(new_edges_num), int(new_loops_num), int(new_polys_num));
float(*vert_positions)[3] = BKE_mesh_vert_positions_for_write(result);
blender::MutableSpan<MEdge> edges = result->edges_for_write();

View File

@ -120,7 +120,7 @@ static void panelRegister(ARegionType *region_type)
static Mesh *create_empty_mesh(const Mesh *input_mesh)
{
Mesh *new_mesh = BKE_mesh_new_nomain(0, 0, 0, 0, 0);
Mesh *new_mesh = BKE_mesh_new_nomain(0, 0, 0, 0);
BKE_mesh_copy_parameters_for_eval(new_mesh, input_mesh);
return new_mesh;
}

View File

@ -37,11 +37,10 @@ static Mesh *hull_from_bullet(const Mesh *mesh, Span<float3> coords)
/* Create Mesh *result with proper capacity. */
Mesh *result;
if (mesh) {
result = BKE_mesh_new_nomain_from_template(
mesh, verts_num, edges_num, 0, loops_num, faces_num);
result = BKE_mesh_new_nomain_from_template(mesh, verts_num, edges_num, loops_num, faces_num);
}
else {
result = BKE_mesh_new_nomain(verts_num, edges_num, 0, loops_num, faces_num);
result = BKE_mesh_new_nomain(verts_num, edges_num, loops_num, faces_num);
BKE_id_material_eval_ensure_default_slot(&result->id);
}

View File

@ -79,7 +79,7 @@ static Mesh *cdt_to_mesh(const meshintersect::CDT_result<double> &result)
loop_len += face.size();
}
Mesh *mesh = BKE_mesh_new_nomain(vert_len, edge_len, 0, loop_len, poly_len);
Mesh *mesh = BKE_mesh_new_nomain(vert_len, edge_len, loop_len, poly_len);
MutableSpan<float3> positions = mesh->vert_positions_for_write();
MutableSpan<MEdge> edges = mesh->edges_for_write();
MutableSpan<MPoly> polys = mesh->polys_for_write();

View File

@ -915,7 +915,6 @@ static void do_mesh_separation(GeometrySet &geometry_set,
mesh_out = BKE_mesh_new_nomain_from_template(&mesh_in,
selected_verts_num,
selected_edges_num,
0,
selected_loops_num,
selected_polys_num);
@ -988,12 +987,8 @@ static void do_mesh_separation(GeometrySet &geometry_set,
BLI_assert_unreachable();
break;
}
mesh_out = BKE_mesh_new_nomain_from_template(&mesh_in,
mesh_in.totvert,
selected_edges_num,
0,
selected_loops_num,
selected_polys_num);
mesh_out = BKE_mesh_new_nomain_from_template(
&mesh_in, mesh_in.totvert, selected_edges_num, selected_loops_num, selected_polys_num);
/* Copy the selected parts of the mesh over to the new mesh. */
copy_masked_edges_to_new_mesh(mesh_in, *mesh_out, edge_map);
@ -1053,7 +1048,7 @@ static void do_mesh_separation(GeometrySet &geometry_set,
break;
}
mesh_out = BKE_mesh_new_nomain_from_template(
&mesh_in, mesh_in.totvert, mesh_in.totedge, 0, selected_loops_num, selected_polys_num);
&mesh_in, mesh_in.totvert, mesh_in.totedge, selected_loops_num, selected_polys_num);
/* Copy the selected parts of the mesh over to the new mesh. */
mesh_out->edges_for_write().copy_from(mesh_in.edges());

View File

@ -886,7 +886,7 @@ static Mesh *calc_dual_mesh(const Mesh &src_mesh,
}
}
Mesh *mesh_out = BKE_mesh_new_nomain(
vertex_positions.size(), new_edges.size(), 0, loops.size(), loop_lengths.size());
vertex_positions.size(), new_edges.size(), loops.size(), loop_lengths.size());
transfer_attributes(vertex_types,
keep_boundaries,

View File

@ -507,7 +507,7 @@ static void duplicate_faces(GeometrySet &geometry_set,
const OffsetIndices<int> duplicates(offset_data);
Mesh *new_mesh = BKE_mesh_new_nomain(total_loops, total_loops, 0, total_loops, total_polys);
Mesh *new_mesh = BKE_mesh_new_nomain(total_loops, total_loops, total_loops, total_polys);
MutableSpan<MEdge> new_edges = new_mesh->edges_for_write();
MutableSpan<MPoly> new_polys = new_mesh->polys_for_write();
MutableSpan<MLoop> new_loops = new_mesh->loops_for_write();
@ -690,7 +690,7 @@ static void duplicate_edges(GeometrySet &geometry_set,
selection, counts, offset_data);
const int output_edges_num = duplicates.total_size();
Mesh *new_mesh = BKE_mesh_new_nomain(output_edges_num * 2, output_edges_num, 0, 0, 0);
Mesh *new_mesh = BKE_mesh_new_nomain(output_edges_num * 2, output_edges_num, 0, 0);
MutableSpan<MEdge> new_edges = new_mesh->edges_for_write();
Array<int> vert_orig_indices(output_edges_num * 2);
@ -850,7 +850,7 @@ static void duplicate_points_mesh(GeometrySet &geometry_set,
const OffsetIndices<int> duplicates = accumulate_counts_to_offsets(
selection, counts, offset_data);
Mesh *new_mesh = BKE_mesh_new_nomain(duplicates.total_size(), 0, 0, 0, 0);
Mesh *new_mesh = BKE_mesh_new_nomain(duplicates.total_size(), 0, 0, 0);
copy_attributes_without_id(duplicates,
selection,

View File

@ -105,7 +105,6 @@ static Mesh *create_circle_mesh(const float radius,
{
Mesh *mesh = BKE_mesh_new_nomain(circle_vert_total(fill_type, verts_num),
circle_edge_total(fill_type, verts_num),
0,
circle_corner_total(fill_type, verts_num),
circle_face_total(fill_type, verts_num));
BKE_id_material_eval_ensure_default_slot(&mesh->id);

View File

@ -655,7 +655,7 @@ static void calculate_cone_uvs(const ConeConfig &config,
static Mesh *create_vertex_mesh()
{
/* Returns a mesh with a single vertex at the origin. */
Mesh *mesh = BKE_mesh_new_nomain(1, 0, 0, 0, 0);
Mesh *mesh = BKE_mesh_new_nomain(1, 0, 0, 0);
mesh->vert_positions_for_write().first() = float3(0);
return mesh;
}
@ -685,7 +685,7 @@ Mesh *create_cylinder_or_cone_mesh(const float radius_top,
}
Mesh *mesh = BKE_mesh_new_nomain(
config.tot_verts, config.tot_edges, 0, config.tot_corners, config.tot_faces);
config.tot_verts, config.tot_edges, config.tot_corners, config.tot_faces);
BKE_id_material_eval_ensure_default_slot(&mesh->id);
MutableSpan<float3> positions = mesh->vert_positions_for_write();

View File

@ -51,7 +51,6 @@ Mesh *create_grid_mesh(const int verts_x,
const int edges_y = verts_y - 1;
Mesh *mesh = BKE_mesh_new_nomain(verts_x * verts_y,
edges_x * verts_y + edges_y * verts_x,
0,
edges_x * edges_y * 4,
edges_x * edges_y);
MutableSpan<float3> positions = mesh->vert_positions_for_write();

View File

@ -178,7 +178,7 @@ Mesh *create_line_mesh(const float3 start, const float3 delta, const int count)
return nullptr;
}
Mesh *mesh = BKE_mesh_new_nomain(count, count - 1, 0, 0, 0);
Mesh *mesh = BKE_mesh_new_nomain(count, count - 1, 0, 0);
BKE_id_material_eval_ensure_default_slot(&mesh->id);
MutableSpan<float3> positions = mesh->vert_positions_for_write();
MutableSpan<MEdge> edges = mesh->edges_for_write();

View File

@ -308,7 +308,6 @@ static Mesh *create_uv_sphere_mesh(const float radius,
{
Mesh *mesh = BKE_mesh_new_nomain(sphere_vert_total(segments, rings),
sphere_edge_total(segments, rings),
0,
sphere_corner_total(segments, rings),
sphere_face_total(segments, rings));
BKE_id_material_eval_ensure_default_slot(&mesh->id);

View File

@ -49,7 +49,7 @@ static void geometry_set_points_to_vertices(
propagation_info,
attributes);
Mesh *mesh = BKE_mesh_new_nomain(selection.size(), 0, 0, 0, 0);
Mesh *mesh = BKE_mesh_new_nomain(selection.size(), 0, 0, 0);
geometry_set.replace_mesh(mesh);
const AttributeAccessor src_attributes = points->attributes();

View File

@ -121,7 +121,7 @@ static Mesh *create_mesh_from_volume_grids(Span<openvdb::GridBase::ConstPtr> gri
loop_offset += (3 * data.tris.size() + 4 * data.quads.size());
}
Mesh *mesh = BKE_mesh_new_nomain(vert_offset, 0, 0, loop_offset, poly_offset);
Mesh *mesh = BKE_mesh_new_nomain(vert_offset, 0, loop_offset, poly_offset);
BKE_id_material_eval_ensure_default_slot(&mesh->id);
MutableSpan<float3> positions = mesh->vert_positions_for_write();
MutableSpan<MPoly> polys = mesh->polys_for_write();

View File

@ -484,7 +484,7 @@ static void do_multires_bake(MultiresBakeRender *bkr,
void *bake_data = nullptr;
Mesh *temp_mesh = BKE_mesh_new_nomain(
dm->getNumVerts(dm), dm->getNumEdges(dm), 0, dm->getNumLoops(dm), dm->getNumPolys(dm));
dm->getNumVerts(dm), dm->getNumEdges(dm), dm->getNumLoops(dm), dm->getNumPolys(dm));
memcpy(temp_mesh->vert_positions_for_write().data(),
positions,
temp_mesh->totvert * sizeof(float[3]));