Cleanup: Use const when accessing custom data layers
This commit is contained in:
parent
a5c3f5b0bc
commit
dc99c09daa
@ -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],
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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],
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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]);
|
||||
|
@ -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<float *>(CustomData_get_layer(args->vdata, CD_PAINT_MASK));
|
||||
const float *mask = static_cast<const float *>(
|
||||
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<int *>(
|
||||
const int *face_sets = static_cast<const int *>(
|
||||
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<MPropCol *>(
|
||||
const MPropCol *mpropcol = static_cast<const MPropCol *>(
|
||||
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<MPropCol *>(
|
||||
const MPropCol *mpropcol = static_cast<const MPropCol *>(
|
||||
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<MLoopCol *>(
|
||||
const MLoopCol *mbytecol = static_cast<const MLoopCol *>(
|
||||
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<MLoopCol *>(
|
||||
const MLoopCol *mbytecol = static_cast<const MLoopCol *>(
|
||||
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<float2 *>(
|
||||
const float2 *mloopuv = static_cast<const float2 *>(
|
||||
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<int *>(
|
||||
const int *mat_index = static_cast<const int *>(
|
||||
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<int *>(
|
||||
const int *mat_index = static_cast<const int *>(
|
||||
CustomData_get_layer_named(args->pdata, CD_PROP_INT32, "material_index"));
|
||||
|
||||
if (mat_index && args->totprim) {
|
||||
|
@ -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;
|
||||
|
@ -109,7 +109,7 @@ static void extract_uv_init(const MeshRenderData *mr,
|
||||
}
|
||||
}
|
||||
else {
|
||||
const float2 *layer_data = static_cast<float2 *>(
|
||||
const float2 *layer_data = static_cast<const float2 *>(
|
||||
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));
|
||||
|
@ -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<Mesh *>(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<int *>(MEM_callocN(sizeof(int[2]) * totface, "MirrorFaces"));
|
||||
|
||||
const Span<float3> 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<MFace *>(BLI_ghash_lookup(fhash, &mirrormf));
|
||||
hashmf = static_cast<const MFace *>(BLI_ghash_lookup(fhash, &mirrormf));
|
||||
if (hashmf) {
|
||||
mirrorfaces[a * 2] = hashmf - mface;
|
||||
mirrorfaces[a * 2 + 1] = mirror_facerotation(&mirrormf, hashmf);
|
||||
|
@ -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 */
|
||||
|
@ -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;
|
||||
|
@ -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<int *>(CustomData_get_layer(&mesh->pdata, CD_FACEMAP));
|
||||
const int *face_maps = static_cast<const int *>(
|
||||
CustomData_get_layer(&mesh->pdata, CD_FACEMAP));
|
||||
for (const int i : IndexRange(mesh->totpoly)) {
|
||||
ss->face_sets[i] = face_maps ? face_maps[i] : 1;
|
||||
}
|
||||
|
@ -294,7 +294,7 @@ IndexMask GeometryDataSource::apply_selection_filter(Vector<int64_t> &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<bool> selection = attributes_eval.adapt_domain<bool>(
|
||||
|
@ -537,7 +537,7 @@ static void get_loop_normals(struct Mesh *mesh,
|
||||
}
|
||||
|
||||
BKE_mesh_calc_normals_split(mesh);
|
||||
const float(*lnors)[3] = static_cast<float(*)[3]>(CustomData_get_layer(&mesh->ldata, CD_NORMAL));
|
||||
const float(*lnors)[3] = static_cast<const float(*)[3]>(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);
|
||||
|
@ -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<float(*)[3]>(CustomData_get_layer(&mesh->ldata, CD_NORMAL));
|
||||
const float(*lnors)[3] = static_cast<const float(*)[3]>(CustomData_get_layer(&mesh->ldata, CD_NORMAL));
|
||||
const Span<MPoly> polys = mesh->polys();
|
||||
const Span<MLoop> loops = mesh->loops();
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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<float(*)[2]>(CustomData_get_layer(&me->ldata, CD_PROP_FLOAT2));
|
||||
mloopuv = static_cast<const float(*)[2]>(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<float(*)[2]>(CustomData_get_layer_n(&me->ldata, CD_PROP_FLOAT2, uv_id));
|
||||
mloopuv = static_cast<const float(*)[2]>(
|
||||
CustomData_get_layer_n(&me->ldata, CD_PROP_FLOAT2, uv_id));
|
||||
}
|
||||
|
||||
if (mloopuv == nullptr) {
|
||||
|
Loading…
Reference in New Issue
Block a user