Cleanup: avoid error prone struct declarations in C++
Reference struct members by name instead relying on their order. This also simplifies moving back to named members when all compilers we use support them.
This commit is contained in:
parent
de581a2302
commit
c3f5fca8a2
|
@ -1138,8 +1138,12 @@ BMesh *BKE_mesh_to_bmesh(Mesh *me,
|
|||
const bool add_key_index,
|
||||
const struct BMeshCreateParams *params)
|
||||
{
|
||||
struct BMeshFromMeshParams bmfmp = {false, add_key_index, true, ob->shapenr};
|
||||
return BKE_mesh_to_bmesh_ex(me, params, &bmfmp);
|
||||
BMeshFromMeshParams bmesh_from_mesh_params{};
|
||||
bmesh_from_mesh_params.calc_face_normal = false;
|
||||
bmesh_from_mesh_params.add_key_index = add_key_index;
|
||||
bmesh_from_mesh_params.use_shapekey = true;
|
||||
bmesh_from_mesh_params.active_shapekey = ob->shapenr;
|
||||
return BKE_mesh_to_bmesh_ex(me, params, &bmesh_from_mesh_params);
|
||||
}
|
||||
|
||||
Mesh *BKE_mesh_from_bmesh_nomain(BMesh *bm,
|
||||
|
|
|
@ -410,7 +410,8 @@ struct Mesh *BKE_mesh_remesh_voxel_fix_poles(const Mesh *mesh)
|
|||
{
|
||||
const BMAllocTemplate allocsize = BMALLOC_TEMPLATE_FROM_ME(mesh);
|
||||
|
||||
const BMeshCreateParams bmesh_create_params = {true};
|
||||
BMeshCreateParams bmesh_create_params{};
|
||||
bmesh_create_params.use_toolflags = true;
|
||||
BMesh *bm = BM_mesh_create(&allocsize, &bmesh_create_params);
|
||||
|
||||
BMeshFromMeshParams bmesh_from_mesh_params{};
|
||||
|
|
|
@ -10,9 +10,9 @@ TEST(bmesh_core, BMVertCreate)
|
|||
BMVert *bv1, *bv2, *bv3;
|
||||
const float co1[3] = {1.0f, 2.0f, 0.0f};
|
||||
|
||||
BMeshCreateParams bm_params;
|
||||
bm_params.use_toolflags = true;
|
||||
bm = BM_mesh_create(&bm_mesh_allocsize_default, &bm_params);
|
||||
BMeshCreateParams bmesh_create_params{};
|
||||
bmesh_create_params.use_toolflags = true;
|
||||
bm = BM_mesh_create(&bm_mesh_allocsize_default, &bmesh_create_params);
|
||||
EXPECT_EQ(bm->totvert, 0);
|
||||
/* make a custom layer so we can see if it is copied properly */
|
||||
BM_data_layer_add(bm, &bm->vdata, CD_PROP_FLOAT);
|
||||
|
|
|
@ -166,9 +166,10 @@ void ABCGenericMeshWriter::do_write(HierarchyContext &context)
|
|||
const int quad_method = args_.export_params->quad_method;
|
||||
const int ngon_method = args_.export_params->ngon_method;
|
||||
|
||||
struct BMeshCreateParams bmcp = {false};
|
||||
struct BMeshFromMeshParams bmfmp = {true, false, false, 0};
|
||||
BMesh *bm = BKE_mesh_to_bmesh_ex(mesh, &bmcp, &bmfmp);
|
||||
BMeshCreateParams bmesh_create_params{};
|
||||
BMeshFromMeshParams bmesh_from_mesh_params{};
|
||||
bmesh_from_mesh_params.calc_face_normal = true;
|
||||
BMesh *bm = BKE_mesh_to_bmesh_ex(mesh, &bmesh_create_params, &bmesh_from_mesh_params);
|
||||
|
||||
BM_mesh_triangulate(bm, quad_method, ngon_method, 4, tag_only, nullptr, nullptr, nullptr);
|
||||
|
||||
|
|
|
@ -444,14 +444,14 @@ void bc_triangulate_mesh(Mesh *me)
|
|||
/* XXX: The triangulation method selection could be offered in the UI. */
|
||||
int quad_method = MOD_TRIANGULATE_QUAD_SHORTEDGE;
|
||||
|
||||
const struct BMeshCreateParams bm_create_params = {0};
|
||||
const BMeshCreateParams bm_create_params{};
|
||||
BMesh *bm = BM_mesh_create(&bm_mesh_allocsize_default, &bm_create_params);
|
||||
BMeshFromMeshParams bm_from_me_params = {0};
|
||||
BMeshFromMeshParams bm_from_me_params{};
|
||||
bm_from_me_params.calc_face_normal = true;
|
||||
BM_mesh_bm_from_me(bm, me, &bm_from_me_params);
|
||||
BM_mesh_triangulate(bm, quad_method, use_beauty, 4, tag_only, nullptr, nullptr, nullptr);
|
||||
|
||||
BMeshToMeshParams bm_to_me_params = {0};
|
||||
BMeshToMeshParams bm_to_me_params{};
|
||||
bm_to_me_params.calc_object_remap = false;
|
||||
BM_mesh_bm_to_me(nullptr, bm, me, &bm_to_me_params);
|
||||
BM_mesh_free(bm);
|
||||
|
|
|
@ -245,12 +245,12 @@ static BMesh *BMD_mesh_bm_create(
|
|||
|
||||
const BMAllocTemplate allocsize = BMALLOC_TEMPLATE_FROM_ME(mesh, mesh_operand_ob);
|
||||
|
||||
BMeshCreateParams bmcp = {false};
|
||||
BMesh *bm = BM_mesh_create(&allocsize, &bmcp);
|
||||
BMeshCreateParams bmesh_create_params{};
|
||||
BMesh *bm = BM_mesh_create(&allocsize, &bmesh_create_params);
|
||||
|
||||
BMeshFromMeshParams params{};
|
||||
params.calc_face_normal = true;
|
||||
BM_mesh_bm_from_me(bm, mesh_operand_ob, ¶ms);
|
||||
BMeshFromMeshParams bmesh_from_mesh_params{};
|
||||
bmesh_from_mesh_params.calc_face_normal = true;
|
||||
BM_mesh_bm_from_me(bm, mesh_operand_ob, &bmesh_from_mesh_params);
|
||||
|
||||
if (UNLIKELY(*r_is_flip)) {
|
||||
const int cd_loop_mdisp_offset = CustomData_get_offset(&bm->ldata, CD_MDISPS);
|
||||
|
@ -261,7 +261,7 @@ static BMesh *BMD_mesh_bm_create(
|
|||
}
|
||||
}
|
||||
|
||||
BM_mesh_bm_from_me(bm, mesh, ¶ms);
|
||||
BM_mesh_bm_from_me(bm, mesh, &bmesh_from_mesh_params);
|
||||
|
||||
return bm;
|
||||
}
|
||||
|
@ -535,9 +535,9 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
|
|||
BMD_mesh_intersection(bm, md, ctx, mesh_operand_ob, object, operand_ob, is_flip);
|
||||
|
||||
/* Needed for multiple objects to work. */
|
||||
BMeshToMeshParams params{};
|
||||
params.calc_object_remap = false;
|
||||
BM_mesh_bm_to_me(nullptr, bm, mesh, ¶ms);
|
||||
BMeshToMeshParams bmesh_to_mesh_params{};
|
||||
bmesh_to_mesh_params.calc_object_remap = false;
|
||||
BM_mesh_bm_to_me(nullptr, bm, mesh, &bmesh_to_mesh_params);
|
||||
|
||||
result = BKE_mesh_from_bmesh_for_eval_nomain(bm, nullptr, mesh);
|
||||
BM_mesh_free(bm);
|
||||
|
|
|
@ -33,12 +33,13 @@ static void geo_node_edge_split_declare(NodeDeclarationBuilder &b)
|
|||
|
||||
static Mesh *mesh_edge_split(const Mesh &mesh, const IndexMask selection)
|
||||
{
|
||||
const BMeshCreateParams bmcp = {true};
|
||||
BMeshCreateParams bmesh_create_params{};
|
||||
bmesh_create_params.use_toolflags = true;
|
||||
const BMAllocTemplate allocsize = {0, 0, 0, 0};
|
||||
BMesh *bm = BM_mesh_create(&allocsize, &bmcp);
|
||||
BMesh *bm = BM_mesh_create(&allocsize, &bmesh_create_params);
|
||||
|
||||
BMeshFromMeshParams params{};
|
||||
BM_mesh_bm_from_me(bm, &mesh, ¶ms);
|
||||
BMeshFromMeshParams bmesh_from_mesh_params{};
|
||||
BM_mesh_bm_from_me(bm, &mesh, &bmesh_from_mesh_params);
|
||||
|
||||
BM_mesh_elem_table_ensure(bm, BM_EDGE);
|
||||
for (const int i : selection) {
|
||||
|
|
|
@ -45,9 +45,10 @@ static Mesh *create_ico_sphere_mesh(const int subdivisions, const float radius)
|
|||
{
|
||||
const float4x4 transform = float4x4::identity();
|
||||
|
||||
const BMeshCreateParams bmcp = {true};
|
||||
BMeshCreateParams bmesh_create_params{};
|
||||
bmesh_create_params.use_toolflags = true;
|
||||
const BMAllocTemplate allocsize = {0, 0, 0, 0};
|
||||
BMesh *bm = BM_mesh_create(&allocsize, &bmcp);
|
||||
BMesh *bm = BM_mesh_create(&allocsize, &bmesh_create_params);
|
||||
BM_data_layer_add_named(bm, &bm->ldata, CD_MLOOPUV, nullptr);
|
||||
|
||||
BMO_op_callf(bm,
|
||||
|
|
Loading…
Reference in New Issue