diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h index 5cf0eced72e..fc9769a94a4 100644 --- a/source/blender/blenkernel/BKE_particle.h +++ b/source/blender/blenkernel/BKE_particle.h @@ -584,7 +584,7 @@ void psys_get_texture(struct ParticleSimulationData *sim, void psys_interpolate_face(struct Mesh *mesh, const float (*vert_positions)[3], const float (*vert_normals)[3], - struct MFace *mface, + const struct MFace *mface, struct MTFace *tface, const float (*orcodata)[3], float w[4], diff --git a/source/blender/blenkernel/intern/data_transfer.cc b/source/blender/blenkernel/intern/data_transfer.cc index b3b8d4730bb..48dd0c84a54 100644 --- a/source/blender/blenkernel/intern/data_transfer.cc +++ b/source/blender/blenkernel/intern/data_transfer.cc @@ -512,7 +512,7 @@ static bool data_transfer_layersmapping_cdlayers_multisrc_to_dst(ListBase *r_map const int num_elem_dst, const bool use_create, const bool use_delete, - CustomData *cd_src, + const CustomData *cd_src, CustomData *cd_dst, const bool use_dupref_dst, const int tolayers, diff --git a/source/blender/blenkernel/intern/data_transfer_intern.h b/source/blender/blenkernel/intern/data_transfer_intern.h index defa87e899b..8335f21d0ad 100644 --- a/source/blender/blenkernel/intern/data_transfer_intern.h +++ b/source/blender/blenkernel/intern/data_transfer_intern.h @@ -46,7 +46,7 @@ bool data_transfer_layersmapping_vgroups(struct ListBase *r_map, bool use_delete, struct Object *ob_src, struct Object *ob_dst, - struct CustomData *cd_src, + const struct CustomData *cd_src, struct CustomData *cd_dst, bool use_dupref_dst, int fromlayers, diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c index b5c3147b0f1..c2e5434f0e1 100644 --- a/source/blender/blenkernel/intern/deform.c +++ b/source/blender/blenkernel/intern/deform.c @@ -1217,7 +1217,7 @@ static bool data_transfer_layersmapping_vgroups_multisrc_to_dst(ListBase *r_map, Object *ob_dst, const MDeformVert *data_src, MDeformVert *data_dst, - CustomData *UNUSED(cd_src), + const CustomData *UNUSED(cd_src), CustomData *cd_dst, const bool UNUSED(use_dupref_dst), const int tolayers, @@ -1365,7 +1365,7 @@ bool data_transfer_layersmapping_vgroups(ListBase *r_map, const bool use_delete, Object *ob_src, Object *ob_dst, - CustomData *cd_src, + const CustomData *cd_src, CustomData *cd_dst, const bool use_dupref_dst, const int fromlayers, diff --git a/source/blender/blenkernel/intern/particle.cc b/source/blender/blenkernel/intern/particle.cc index 484cb343a97..f871aa324be 100644 --- a/source/blender/blenkernel/intern/particle.cc +++ b/source/blender/blenkernel/intern/particle.cc @@ -1702,7 +1702,7 @@ static void interpolate_pathcache(ParticleCacheKey *first, float t, ParticleCach void psys_interpolate_face(Mesh *mesh, const float (*vert_positions)[3], const float (*vert_normals)[3], - MFace *mface, + const MFace *mface, MTFace *tface, const float (*orcodata)[3], float w[4], diff --git a/source/blender/draw/DRW_pbvh.h b/source/blender/draw/DRW_pbvh.h index db21f22aeb0..d49e5b6c686 100644 --- a/source/blender/draw/DRW_pbvh.h +++ b/source/blender/draw/DRW_pbvh.h @@ -64,7 +64,7 @@ typedef struct PBVH_GPU_Args { int *prim_indices; int totprim; - bool *hide_poly; + const bool *hide_poly; int node_verts_num; diff --git a/source/blender/draw/intern/draw_cache_impl_particles.c b/source/blender/draw/intern/draw_cache_impl_particles.c index d2f9a634922..5b45fa38704 100644 --- a/source/blender/draw/intern/draw_cache_impl_particles.c +++ b/source/blender/draw/intern/draw_cache_impl_particles.c @@ -310,8 +310,8 @@ static void particle_calculate_parent_uvs(ParticleSystem *psys, } } if (!ELEM(num, DMCACHE_NOTFOUND, DMCACHE_ISCHILD)) { - MFace *mfaces = CustomData_get_layer(&psmd->mesh_final->fdata, CD_MFACE); - MFace *mface = &mfaces[num]; + const MFace *mfaces = CustomData_get_layer(&psmd->mesh_final->fdata, CD_MFACE); + const MFace *mface = &mfaces[num]; for (int j = 0; j < num_uv_layers; j++) { psys_interpolate_uvs(mtfaces[j] + num, mface->v4, particle->fuv, r_uv[j]); } @@ -340,8 +340,8 @@ static void particle_calculate_parent_mcol(ParticleSystem *psys, } } if (!ELEM(num, DMCACHE_NOTFOUND, DMCACHE_ISCHILD)) { - MFace *mfaces = CustomData_get_layer(&psmd->mesh_final->fdata, CD_MFACE); - MFace *mface = &mfaces[num]; + const MFace *mfaces = CustomData_get_layer(&psmd->mesh_final->fdata, CD_MFACE); + const MFace *mface = &mfaces[num]; for (int j = 0; j < num_col_layers; j++) { /* CustomDataLayer CD_MCOL has 4 structs per face. */ psys_interpolate_mcol(mcols[j] + num * 4, mface->v4, particle->fuv, &r_mcol[j]); @@ -367,8 +367,8 @@ static void particle_interpolate_children_uvs(ParticleSystem *psys, ChildParticle *particle = &psys->child[child_index]; int num = particle->num; if (num != DMCACHE_NOTFOUND) { - MFace *mfaces = CustomData_get_layer(&psmd->mesh_final->fdata, CD_MFACE); - MFace *mface = &mfaces[num]; + const MFace *mfaces = CustomData_get_layer(&psmd->mesh_final->fdata, CD_MFACE); + const MFace *mface = &mfaces[num]; for (int j = 0; j < num_uv_layers; j++) { psys_interpolate_uvs(mtfaces[j] + num, mface->v4, particle->fuv, r_uv[j]); } @@ -392,8 +392,8 @@ static void particle_interpolate_children_mcol(ParticleSystem *psys, ChildParticle *particle = &psys->child[child_index]; int num = particle->num; if (num != DMCACHE_NOTFOUND) { - MFace *mfaces = CustomData_get_layer(&psmd->mesh_final->fdata, CD_MFACE); - MFace *mface = &mfaces[num]; + const MFace *mfaces = CustomData_get_layer(&psmd->mesh_final->fdata, CD_MFACE); + const MFace *mface = &mfaces[num]; for (int j = 0; j < num_col_layers; j++) { /* CustomDataLayer CD_MCOL has 4 structs per face. */ psys_interpolate_mcol(mcols[j] + num * 4, mface->v4, particle->fuv, &r_mcol[j]); diff --git a/source/blender/draw/intern/draw_pbvh.cc b/source/blender/draw/intern/draw_pbvh.cc index 964d2190177..68ef6cef8a6 100644 --- a/source/blender/draw/intern/draw_pbvh.cc +++ b/source/blender/draw/intern/draw_pbvh.cc @@ -595,7 +595,8 @@ struct PBVHBatches { fill_vbo_normal_faces(vbo, args, foreach_faces, &access); break; case CD_PBVH_MASK_TYPE: { - float *mask = static_cast(CustomData_get_layer(args->vdata, CD_PAINT_MASK)); + const float *mask = static_cast( + CustomData_get_layer(args->vdata, CD_PAINT_MASK)); if (mask) { foreach_faces( @@ -613,7 +614,7 @@ struct PBVHBatches { break; } case CD_PBVH_FSET_TYPE: { - int *face_sets = static_cast( + const int *face_sets = static_cast( CustomData_get_layer_named(args->pdata, CD_PROP_INT32, ".sculpt_face_set")); if (face_sets) { @@ -653,13 +654,13 @@ struct PBVHBatches { } case CD_PROP_COLOR: if (vbo.domain == ATTR_DOMAIN_POINT) { - MPropCol *mpropcol = static_cast( + const MPropCol *mpropcol = static_cast( CustomData_get_layer_named(args->vdata, CD_PROP_COLOR, vbo.name.c_str())); foreach_faces( [&](int /*buffer_i*/, int /*tri_i*/, int vertex_i, const MLoopTri * /*tri*/) { ushort color[4]; - MPropCol *col = mpropcol + vertex_i; + const MPropCol *col = mpropcol + vertex_i; color[0] = unit_float_to_ushort_clamp(col->color[0]); color[1] = unit_float_to_ushort_clamp(col->color[1]); @@ -670,12 +671,12 @@ struct PBVHBatches { }); } else if (vbo.domain == ATTR_DOMAIN_CORNER) { - MPropCol *mpropcol = static_cast( + const MPropCol *mpropcol = static_cast( CustomData_get_layer_named(args->ldata, CD_PROP_COLOR, vbo.name.c_str())); foreach_faces([&](int /*buffer_i*/, int tri_i, int /*vertex_i*/, const MLoopTri *tri) { ushort color[4]; - MPropCol *col = mpropcol + tri->tri[tri_i]; + const MPropCol *col = mpropcol + tri->tri[tri_i]; color[0] = unit_float_to_ushort_clamp(col->color[0]); color[1] = unit_float_to_ushort_clamp(col->color[1]); @@ -688,13 +689,13 @@ struct PBVHBatches { break; case CD_PROP_BYTE_COLOR: if (vbo.domain == ATTR_DOMAIN_POINT) { - MLoopCol *mbytecol = static_cast( + const MLoopCol *mbytecol = static_cast( CustomData_get_layer_named(args->vdata, CD_PROP_BYTE_COLOR, vbo.name.c_str())); foreach_faces( [&](int /*buffer_i*/, int /*tri_i*/, int vertex_i, const MLoopTri * /*tri*/) { ushort color[4]; - MLoopCol *col = mbytecol + vertex_i; + const MLoopCol *col = mbytecol + vertex_i; color[0] = unit_float_to_ushort_clamp(BLI_color_from_srgb_table[col->r]); color[1] = unit_float_to_ushort_clamp(BLI_color_from_srgb_table[col->g]); @@ -705,12 +706,12 @@ struct PBVHBatches { }); } else if (vbo.domain == ATTR_DOMAIN_CORNER) { - MLoopCol *mbytecol = static_cast( + const MLoopCol *mbytecol = static_cast( CustomData_get_layer_named(args->ldata, CD_PROP_BYTE_COLOR, vbo.name.c_str())); foreach_faces([&](int /*buffer_i*/, int tri_i, int /*vertex_i*/, const MLoopTri *tri) { ushort color[4]; - MLoopCol *col = mbytecol + tri->tri[tri_i]; + const MLoopCol *col = mbytecol + tri->tri[tri_i]; color[0] = unit_float_to_ushort_clamp(BLI_color_from_srgb_table[col->r]); color[1] = unit_float_to_ushort_clamp(BLI_color_from_srgb_table[col->g]); @@ -722,7 +723,7 @@ struct PBVHBatches { } break; case CD_PROP_FLOAT2: { - float2 *mloopuv = static_cast( + const float2 *mloopuv = static_cast( CustomData_get_layer_named(args->ldata, CD_PROP_FLOAT2, vbo.name.c_str())); foreach_faces([&](int /*buffer_i*/, int tri_i, int /*vertex_i*/, const MLoopTri *tri) { @@ -730,7 +731,6 @@ struct PBVHBatches { }); break; } - } } @@ -972,7 +972,7 @@ struct PBVHBatches { void create_index_faces(PBVH_GPU_Args *args) { - int *mat_index = static_cast( + const int *mat_index = static_cast( CustomData_get_layer_named(args->pdata, CD_PROP_INT32, "material_index")); if (mat_index && args->totprim) { @@ -1062,7 +1062,7 @@ struct PBVHBatches { void create_index_grids(PBVH_GPU_Args *args, bool do_coarse) { - int *mat_index = static_cast( + const int *mat_index = static_cast( CustomData_get_layer_named(args->pdata, CD_PROP_INT32, "material_index")); if (mat_index && args->totprim) { diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_tan.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_tan.cc index 0ee95b7dcf6..bd1c98b033f 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_tan.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_tan.cc @@ -40,8 +40,8 @@ static void extract_tan_init_common(const MeshRenderData *mr, CustomData *cd_ldata = (mr->extract_type == MR_EXTRACT_BMESH) ? &mr->bm->ldata : &mr->me->ldata; CustomData *cd_vdata = (mr->extract_type == MR_EXTRACT_BMESH) ? &mr->bm->vdata : &mr->me->vdata; uint32_t tan_layers = cache->cd_used.tan; - float(*orco)[3] = (float(*)[3])CustomData_get_layer(cd_vdata, CD_ORCO); - bool orco_allocated = false; + const float(*orco)[3] = (const float(*)[3])CustomData_get_layer(cd_vdata, CD_ORCO); + float(*orco_allocated)[3] = nullptr; bool use_orco_tan = cache->cd_used.tan_orco != 0; int tan_len = 0; @@ -76,8 +76,7 @@ static void extract_tan_init_common(const MeshRenderData *mr, } if (use_orco_tan && orco == nullptr) { /* If `orco` is not available compute it ourselves */ - orco_allocated = true; - orco = (float(*)[3])MEM_mallocN(sizeof(*orco) * mr->vert_len, __func__); + orco_allocated = (float(*)[3])MEM_mallocN(sizeof(*orco) * mr->vert_len, __func__); if (mr->extract_type == MR_EXTRACT_BMESH) { BMesh *bm = mr->bm; @@ -85,15 +84,16 @@ static void extract_tan_init_common(const MeshRenderData *mr, const BMVert *eve = BM_vert_at_index(bm, v); /* Exceptional case where #bm_vert_co_get can be avoided, as we want the original coords. * not the distorted ones. */ - copy_v3_v3(orco[v], eve->co); + copy_v3_v3(orco_allocated[v], eve->co); } } else { for (int v = 0; v < mr->vert_len; v++) { - copy_v3_v3(orco[v], mr->vert_positions[v]); + copy_v3_v3(orco_allocated[v], mr->vert_positions[v]); } } - BKE_mesh_orco_verts_transform(mr->me, orco, mr->vert_len, 0); + BKE_mesh_orco_verts_transform(mr->me, orco_allocated, mr->vert_len, 0); + orco = orco_allocated; } /* Start Fresh */ @@ -144,9 +144,7 @@ static void extract_tan_init_common(const MeshRenderData *mr, GPU_vertformat_alias_add(format, "at"); } - if (orco_allocated) { - MEM_SAFE_FREE(orco); - } + MEM_SAFE_FREE(orco_allocated); int v_len = mr->loop_len; if (format->attr_len == 0) { @@ -192,7 +190,7 @@ static void extract_tan_ex_init(const MeshRenderData *mr, short(*tan_data)[4] = (short(*)[4])GPU_vertbuf_get_data(vbo); for (int i = 0; i < tan_len; i++) { const char *name = tangent_names[i]; - float(*layer_data)[4] = (float(*)[4])CustomData_get_layer_named( + const float(*layer_data)[4] = (const float(*)[4])CustomData_get_layer_named( &loop_data, CD_TANGENT, name); for (int ml_index = 0; ml_index < mr->loop_len; ml_index++) { normal_float_to_short_v3(*tan_data, layer_data[ml_index]); @@ -201,7 +199,8 @@ static void extract_tan_ex_init(const MeshRenderData *mr, } } if (use_orco_tan) { - float(*layer_data)[4] = (float(*)[4])CustomData_get_layer_n(&loop_data, CD_TANGENT, 0); + const float(*layer_data)[4] = (const float(*)[4])CustomData_get_layer_n( + &loop_data, CD_TANGENT, 0); for (int ml_index = 0; ml_index < mr->loop_len; ml_index++) { normal_float_to_short_v3(*tan_data, layer_data[ml_index]); (*tan_data)[3] = (layer_data[ml_index][3] > 0.0f) ? SHRT_MAX : SHRT_MIN; @@ -213,7 +212,7 @@ static void extract_tan_ex_init(const MeshRenderData *mr, GPUPackedNormal *tan_data = (GPUPackedNormal *)GPU_vertbuf_get_data(vbo); for (int i = 0; i < tan_len; i++) { const char *name = tangent_names[i]; - float(*layer_data)[4] = (float(*)[4])CustomData_get_layer_named( + const float(*layer_data)[4] = (const float(*)[4])CustomData_get_layer_named( &loop_data, CD_TANGENT, name); for (int ml_index = 0; ml_index < mr->loop_len; ml_index++) { *tan_data = GPU_normal_convert_i10_v3(layer_data[ml_index]); @@ -222,7 +221,8 @@ static void extract_tan_ex_init(const MeshRenderData *mr, } } if (use_orco_tan) { - float(*layer_data)[4] = (float(*)[4])CustomData_get_layer_n(&loop_data, CD_TANGENT, 0); + const float(*layer_data)[4] = (const float(*)[4])CustomData_get_layer_n( + &loop_data, CD_TANGENT, 0); for (int ml_index = 0; ml_index < mr->loop_len; ml_index++) { *tan_data = GPU_normal_convert_i10_v3(layer_data[ml_index]); tan_data->w = (layer_data[ml_index][3] > 0.0f) ? 1 : -2; @@ -291,7 +291,7 @@ static void extract_tan_init_subdiv(const DRWSubdivCache *subdiv_cache, for (int i = 0; i < tan_len; i++) { float(*tan_data)[4] = (float(*)[4])GPU_vertbuf_get_data(coarse_vbo); const char *name = tangent_names[i]; - const float(*layer_data)[4] = (float(*)[4])CustomData_get_layer_named( + const float(*layer_data)[4] = (const float(*)[4])CustomData_get_layer_named( &loop_data, CD_TANGENT, name); for (int ml_index = 0; ml_index < mr->loop_len; ml_index++) { copy_v3_v3(*tan_data, layer_data[ml_index]); @@ -308,7 +308,8 @@ static void extract_tan_init_subdiv(const DRWSubdivCache *subdiv_cache, } if (use_orco_tan) { float(*tan_data)[4] = (float(*)[4])GPU_vertbuf_get_data(coarse_vbo); - const float(*layer_data)[4] = (float(*)[4])CustomData_get_layer_n(&loop_data, CD_TANGENT, 0); + const float(*layer_data)[4] = (const float(*)[4])CustomData_get_layer_n( + &loop_data, CD_TANGENT, 0); for (int ml_index = 0; ml_index < mr->loop_len; ml_index++) { copy_v3_v3(*tan_data, layer_data[ml_index]); (*tan_data)[3] = (layer_data[ml_index][3] > 0.0f) ? 1.0f : -1.0f; diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_uv.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_uv.cc index 54dbfa4fbe1..2af8fa40844 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_uv.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_uv.cc @@ -109,7 +109,7 @@ static void extract_uv_init(const MeshRenderData *mr, } } else { - const float2 *layer_data = static_cast( + const float2 *layer_data = static_cast( CustomData_get_layer_n(cd_ldata, CD_PROP_FLOAT2, i)); for (int ml_index = 0; ml_index < mr->loop_len; ml_index++, uv_data++, layer_data++) { memcpy(uv_data, layer_data, sizeof(*uv_data)); diff --git a/source/blender/editors/mesh/meshtools.cc b/source/blender/editors/mesh/meshtools.cc index bf10d51f2e1..a5e61cb8b33 100644 --- a/source/blender/editors/mesh/meshtools.cc +++ b/source/blender/editors/mesh/meshtools.cc @@ -1081,7 +1081,7 @@ static uint mirror_facehash(const void *ptr) return ((v0 * 39) ^ (v1 * 31)); } -static int mirror_facerotation(MFace *a, MFace *b) +static int mirror_facerotation(const MFace *a, const MFace *b) { if (b->v4) { if (a->v1 == b->v1 && a->v2 == b->v2 && a->v3 == b->v3 && a->v4 == b->v4) { @@ -1120,7 +1120,8 @@ static bool mirror_facecmp(const void *a, const void *b) int *mesh_get_x_mirror_faces(Object *ob, BMEditMesh *em, Mesh *me_eval) { Mesh *me = static_cast(ob->data); - MFace mirrormf, *mf, *hashmf; + MFace mirrormf; + const MFace *mf, *hashmf; GHash *fhash; int *mirrorverts, *mirrorfaces; @@ -1135,7 +1136,8 @@ int *mesh_get_x_mirror_faces(Object *ob, BMEditMesh *em, Mesh *me_eval) mirrorfaces = static_cast(MEM_callocN(sizeof(int[2]) * totface, "MirrorFaces")); const Span vert_positions = me_eval ? me_eval->vert_positions() : me->vert_positions(); - MFace *mface = (MFace *)CustomData_get_layer(&(me_eval ? me_eval : me)->fdata, CD_MFACE); + const MFace *mface = (const MFace *)CustomData_get_layer(&(me_eval ? me_eval : me)->fdata, + CD_MFACE); ED_mesh_mirror_spatial_table_begin(ob, em, me_eval); @@ -1147,7 +1149,7 @@ int *mesh_get_x_mirror_faces(Object *ob, BMEditMesh *em, Mesh *me_eval) fhash = BLI_ghash_new_ex(mirror_facehash, mirror_facecmp, "mirror_facehash gh", me->totface); for (a = 0, mf = mface; a < totface; a++, mf++) { - BLI_ghash_insert(fhash, mf, mf); + BLI_ghash_insert(fhash, (void *)mf, (void *)mf); } for (a = 0, mf = mface; a < totface; a++, mf++) { @@ -1162,7 +1164,7 @@ int *mesh_get_x_mirror_faces(Object *ob, BMEditMesh *em, Mesh *me_eval) std::swap(mirrormf.v2, mirrormf.v4); } - hashmf = static_cast(BLI_ghash_lookup(fhash, &mirrormf)); + hashmf = static_cast(BLI_ghash_lookup(fhash, &mirrormf)); if (hashmf) { mirrorfaces[a * 2] = hashmf - mface; mirrorfaces[a * 2 + 1] = mirror_facerotation(&mirrormf, hashmf); diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index 02569184541..8d804eeaa8e 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -1454,9 +1454,9 @@ void recalc_emitter_field(Depsgraph *UNUSED(depsgraph), Object *UNUSED(ob), Part const float(*positions)[3] = BKE_mesh_vert_positions(mesh); const float(*vert_normals)[3] = BKE_mesh_vertex_normals_ensure(mesh); - MFace *mfaces = (MFace *)CustomData_get_layer(&mesh->fdata, CD_MFACE); + const MFace *mfaces = (const MFace *)CustomData_get_layer(&mesh->fdata, CD_MFACE); for (i = 0; i < totface; i++, vec += 6, nor += 6) { - MFace *mface = &mfaces[i]; + const MFace *mface = &mfaces[i]; copy_v3_v3(vec, positions[mface->v1]); copy_v3_v3(nor, vert_normals[mface->v1]); @@ -3564,9 +3564,10 @@ static void PE_mirror_x(Depsgraph *depsgraph, Scene *scene, Object *ob, int tagg } if (newtotpart != psys->totpart) { - MFace *mtessface = use_dm_final_indices ? - (MFace *)CustomData_get_layer(&psmd_eval->mesh_final->fdata, CD_MFACE) : - (MFace *)CustomData_get_layer(&me->fdata, CD_MFACE); + const MFace *mtessface = use_dm_final_indices ? + (const MFace *)CustomData_get_layer(&psmd_eval->mesh_final->fdata, + CD_MFACE) : + (const MFace *)CustomData_get_layer(&me->fdata, CD_MFACE); /* allocate new arrays and copy existing */ new_pars = MEM_callocN(newtotpart * sizeof(ParticleData), "ParticleData new"); @@ -4136,7 +4137,7 @@ static int particle_intersect_mesh(Depsgraph *depsgraph, float radius, float *ipoint) { - MFace *mface = NULL; + const MFace *mface = NULL; int i, totface, intersect = 0; float cur_d, cur_uv[2], v1[3], v2[3], v3[3], v4[3], min[3], max[3], p_min[3], p_max[3]; float cur_ipoint[3]; @@ -4173,7 +4174,7 @@ static int particle_intersect_mesh(Depsgraph *depsgraph, } totface = mesh->totface; - mface = (MFace *)CustomData_get_layer(&mesh->fdata, CD_MFACE); + mface = (const MFace *)CustomData_get_layer(&mesh->fdata, CD_MFACE); float(*positions)[3] = BKE_mesh_vert_positions_for_write(mesh); /* lets intersect the faces */ diff --git a/source/blender/editors/physics/particle_object.c b/source/blender/editors/physics/particle_object.c index ebf030bad71..58ed94fdbb8 100644 --- a/source/blender/editors/physics/particle_object.c +++ b/source/blender/editors/physics/particle_object.c @@ -705,7 +705,7 @@ static bool remap_hair_emitter(Depsgraph *depsgraph, PTCacheEditPoint *edit_point; PTCacheEditKey *ekey; BVHTreeFromMesh bvhtree = {NULL}; - MFace *mface = NULL, *mf; + const MFace *mface = NULL, *mf; const MEdge *medge = NULL, *me; Mesh *mesh, *target_mesh; int numverts; diff --git a/source/blender/editors/sculpt_paint/sculpt_face_set.cc b/source/blender/editors/sculpt_paint/sculpt_face_set.cc index d5e8e1cdf98..d2e20b33f6c 100644 --- a/source/blender/editors/sculpt_paint/sculpt_face_set.cc +++ b/source/blender/editors/sculpt_paint/sculpt_face_set.cc @@ -613,7 +613,8 @@ static void sculpt_face_sets_init_loop(Object *ob, const int mode) } } else if (mode == SCULPT_FACE_SETS_FROM_FACE_MAPS) { - const int *face_maps = static_cast(CustomData_get_layer(&mesh->pdata, CD_FACEMAP)); + const int *face_maps = static_cast( + CustomData_get_layer(&mesh->pdata, CD_FACEMAP)); for (const int i : IndexRange(mesh->totpoly)) { ss->face_sets[i] = face_maps ? face_maps[i] : 1; } diff --git a/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc b/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc index 9d7f2222d3d..136fb4bfe0e 100644 --- a/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc +++ b/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc @@ -294,7 +294,7 @@ IndexMask GeometryDataSource::apply_selection_filter(Vector &indices) c BMesh *bm = mesh_orig->edit_mesh->bm; BM_mesh_elem_table_ensure(bm, BM_VERT); - const int *orig_indices = (int *)CustomData_get_layer(&mesh_eval->vdata, CD_ORIGINDEX); + const int *orig_indices = (const int *)CustomData_get_layer(&mesh_eval->vdata, CD_ORIGINDEX); if (orig_indices != nullptr) { /* Use CD_ORIGINDEX layer if it exists. */ VArray selection = attributes_eval.adapt_domain( diff --git a/source/blender/io/alembic/exporter/abc_writer_mesh.cc b/source/blender/io/alembic/exporter/abc_writer_mesh.cc index dfe744a1197..fb7cef96cc5 100644 --- a/source/blender/io/alembic/exporter/abc_writer_mesh.cc +++ b/source/blender/io/alembic/exporter/abc_writer_mesh.cc @@ -537,7 +537,7 @@ static void get_loop_normals(struct Mesh *mesh, } BKE_mesh_calc_normals_split(mesh); - const float(*lnors)[3] = static_cast(CustomData_get_layer(&mesh->ldata, CD_NORMAL)); + const float(*lnors)[3] = static_cast(CustomData_get_layer(&mesh->ldata, CD_NORMAL)); BLI_assert_msg(lnors != nullptr, "BKE_mesh_calc_normals_split() should have computed CD_NORMAL"); normals.resize(mesh->totloop); diff --git a/source/blender/io/usd/intern/usd_writer_mesh.cc b/source/blender/io/usd/intern/usd_writer_mesh.cc index 45fa0d48d80..3d08f9ac2a9 100644 --- a/source/blender/io/usd/intern/usd_writer_mesh.cc +++ b/source/blender/io/usd/intern/usd_writer_mesh.cc @@ -400,7 +400,7 @@ void USDGenericMeshWriter::assign_materials(const HierarchyContext &context, void USDGenericMeshWriter::write_normals(const Mesh *mesh, pxr::UsdGeomMesh usd_mesh) { pxr::UsdTimeCode timecode = get_export_time_code(); - const float(*lnors)[3] = static_cast(CustomData_get_layer(&mesh->ldata, CD_NORMAL)); + const float(*lnors)[3] = static_cast(CustomData_get_layer(&mesh->ldata, CD_NORMAL)); const Span polys = mesh->polys(); const Span loops = mesh->loops(); diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c index 1d80123b5d9..fa8fe5cde00 100644 --- a/source/blender/makesrna/intern/rna_particle.c +++ b/source/blender/makesrna/intern/rna_particle.c @@ -397,11 +397,9 @@ static void rna_Particle_uv_on_emitter(ParticleData *particle, /* get uvco */ if (r_uv && ELEM(from, PART_FROM_FACE, PART_FROM_VOLUME) && !ELEM(num, DMCACHE_NOTFOUND, DMCACHE_ISCHILD)) { - MFace *mface; - MTFace *mtface; - mface = CustomData_get_layer(&modifier->mesh_final->fdata, CD_MFACE); - mtface = CustomData_get_layer(&modifier->mesh_final->fdata, CD_MTFACE); + const MFace *mface = CustomData_get_layer(&modifier->mesh_final->fdata, CD_MFACE); + const MTFace *mtface = CustomData_get_layer(&modifier->mesh_final->fdata, CD_MTFACE); if (mface && mtface) { mtface += num; @@ -565,7 +563,7 @@ static int rna_ParticleSystem_tessfaceidx_on_emitter(ParticleSystem *particlesys } else if (part->from == PART_FROM_VERT) { if (num != DMCACHE_NOTFOUND && num < totvert) { - MFace *mface = CustomData_get_layer(&modifier->mesh_final->fdata, CD_MFACE); + const MFace *mface = CustomData_get_layer(&modifier->mesh_final->fdata, CD_MFACE); *r_fuv = &particle->fuv; @@ -608,7 +606,7 @@ static int rna_ParticleSystem_tessfaceidx_on_emitter(ParticleSystem *particlesys } else if (part->from == PART_FROM_VERT) { if (num != DMCACHE_NOTFOUND && num < totvert) { - MFace *mface = CustomData_get_layer(&modifier->mesh_final->fdata, CD_MFACE); + const MFace *mface = CustomData_get_layer(&modifier->mesh_final->fdata, CD_MFACE); *r_fuv = &parent->fuv; @@ -658,8 +656,8 @@ static void rna_ParticleSystem_uv_on_emitter(ParticleSystem *particlesystem, zero_v2(r_uv); } else { - MFace *mfaces = CustomData_get_layer(&modifier->mesh_final->fdata, CD_MFACE); - MFace *mface = &mfaces[num]; + const MFace *mfaces = CustomData_get_layer(&modifier->mesh_final->fdata, CD_MFACE); + const MFace *mface = &mfaces[num]; const MTFace *mtface = (const MTFace *)CustomData_get_layer_n( &modifier->mesh_final->fdata, CD_MTFACE, uv_no); @@ -693,8 +691,8 @@ static void rna_ParticleSystem_mcol_on_emitter(ParticleSystem *particlesystem, zero_v3(r_mcol); } else { - MFace *mfaces = CustomData_get_layer(&modifier->mesh_final->fdata, CD_MFACE); - MFace *mface = &mfaces[num]; + const MFace *mfaces = CustomData_get_layer(&modifier->mesh_final->fdata, CD_MFACE); + const MFace *mface = &mfaces[num]; const MCol *mc = (const MCol *)CustomData_get_layer_n( &modifier->mesh_final->fdata, CD_MCOL, vcol_no); MCol mcol; diff --git a/source/blender/render/intern/bake.cc b/source/blender/render/intern/bake.cc index e1fc33a4b9d..b9c1680f421 100644 --- a/source/blender/render/intern/bake.cc +++ b/source/blender/render/intern/bake.cc @@ -716,11 +716,12 @@ void RE_bake_pixels_populate(Mesh *me, { const float(*mloopuv)[2]; if ((uv_layer == nullptr) || (uv_layer[0] == '\0')) { - mloopuv = static_cast(CustomData_get_layer(&me->ldata, CD_PROP_FLOAT2)); + mloopuv = static_cast(CustomData_get_layer(&me->ldata, CD_PROP_FLOAT2)); } else { int uv_id = CustomData_get_named_layer(&me->ldata, CD_PROP_FLOAT2, uv_layer); - mloopuv = static_cast(CustomData_get_layer_n(&me->ldata, CD_PROP_FLOAT2, uv_id)); + mloopuv = static_cast( + CustomData_get_layer_n(&me->ldata, CD_PROP_FLOAT2, uv_id)); } if (mloopuv == nullptr) {