Cleanup: Further use of const for retrieved custom data layers
Similar to cf69652618
.
This commit is contained in:
parent
e1c8ef551f
commit
ea5bfedb49
|
@ -21,7 +21,7 @@ void BKE_mesh_calc_loop_tangent_single_ex(const struct MVert *mverts,
|
|||
int numVerts,
|
||||
const struct MLoop *mloops,
|
||||
float (*r_looptangent)[4],
|
||||
float (*loopnors)[3],
|
||||
const float (*loopnors)[3],
|
||||
const struct MLoopUV *loopuv,
|
||||
int numLoops,
|
||||
const struct MPoly *mpolys,
|
||||
|
|
|
@ -130,7 +130,7 @@ void multiresModifier_prepare_join(struct Depsgraph *depsgraph,
|
|||
struct Object *ob,
|
||||
struct Object *to_ob);
|
||||
|
||||
int multires_mdisp_corners(struct MDisps *s);
|
||||
int multires_mdisp_corners(const struct MDisps *s);
|
||||
|
||||
/**
|
||||
* Update multi-res data after topology changing.
|
||||
|
|
|
@ -632,7 +632,7 @@ static void cloth_apply_vgroup(ClothModifierData *clmd, Mesh *mesh)
|
|||
verts->flags &= ~(CLOTH_VERT_FLAG_PINNED | CLOTH_VERT_FLAG_NOSELFCOLL |
|
||||
CLOTH_VERT_FLAG_NOOBJCOLL);
|
||||
|
||||
MDeformVert *dvert = CustomData_get(&mesh->vdata, i, CD_MDEFORMVERT);
|
||||
const MDeformVert *dvert = CustomData_get(&mesh->vdata, i, CD_MDEFORMVERT);
|
||||
if (dvert) {
|
||||
for (int j = 0; j < dvert->totweight; j++) {
|
||||
if (dvert->dw[j].def_nr == (clmd->sim_parms->vgroup_mass - 1)) {
|
||||
|
|
|
@ -1607,7 +1607,6 @@ static void dynamicPaint_setInitialColor(const Scene *scene, DynamicPaintSurface
|
|||
const MLoop *mloop = mesh->mloop;
|
||||
const MLoopTri *mlooptri = BKE_mesh_runtime_looptri_ensure(mesh);
|
||||
const int tottri = BKE_mesh_runtime_looptri_len(mesh);
|
||||
const MLoopUV *mloopuv = NULL;
|
||||
|
||||
char uvname[MAX_CUSTOMDATA_LAYER_NAME];
|
||||
|
||||
|
@ -1617,7 +1616,7 @@ static void dynamicPaint_setInitialColor(const Scene *scene, DynamicPaintSurface
|
|||
|
||||
/* get uv map */
|
||||
CustomData_validate_layer_name(&mesh->ldata, CD_MLOOPUV, surface->init_layername, uvname);
|
||||
mloopuv = CustomData_get_layer_named(&mesh->ldata, CD_MLOOPUV, uvname);
|
||||
const MLoopUV *mloopuv = CustomData_get_layer_named(&mesh->ldata, CD_MLOOPUV, uvname);
|
||||
if (!mloopuv) {
|
||||
return;
|
||||
}
|
||||
|
@ -1675,7 +1674,7 @@ static void dynamicPaint_setInitialColor(const Scene *scene, DynamicPaintSurface
|
|||
}
|
||||
else if (surface->format == MOD_DPAINT_SURFACE_F_IMAGESEQ) {
|
||||
const MLoopTri *mlooptri = BKE_mesh_runtime_looptri_ensure(mesh);
|
||||
MLoopCol *col = CustomData_get_layer_named(
|
||||
const MLoopCol *col = CustomData_get_layer_named(
|
||||
&mesh->ldata, CD_PROP_BYTE_COLOR, surface->init_layername);
|
||||
if (!col) {
|
||||
return;
|
||||
|
|
|
@ -2074,14 +2074,8 @@ static void emit_from_mesh(
|
|||
Object *flow_ob, FluidDomainSettings *fds, FluidFlowSettings *ffs, FluidObjectBB *bb, float dt)
|
||||
{
|
||||
if (ffs->mesh) {
|
||||
Mesh *me = NULL;
|
||||
MVert *mvert = NULL;
|
||||
const MLoopTri *mlooptri = NULL;
|
||||
const MLoop *mloop = NULL;
|
||||
const MLoopUV *mloopuv = NULL;
|
||||
const MDeformVert *dvert = NULL;
|
||||
BVHTreeFromMesh tree_data = {NULL};
|
||||
int numverts, i;
|
||||
int i;
|
||||
|
||||
float *vert_vel = NULL;
|
||||
bool has_velocity = false;
|
||||
|
@ -2092,7 +2086,7 @@ static void emit_from_mesh(
|
|||
|
||||
/* Copy mesh for thread safety as we modify it.
|
||||
* Main issue is its VertArray being modified, then replaced and freed. */
|
||||
me = BKE_mesh_copy_for_eval(ffs->mesh, true);
|
||||
Mesh *me = BKE_mesh_copy_for_eval(ffs->mesh, true);
|
||||
|
||||
/* Duplicate vertices to modify. */
|
||||
if (me->mvert) {
|
||||
|
@ -2100,12 +2094,12 @@ static void emit_from_mesh(
|
|||
CustomData_set_layer(&me->vdata, CD_MVERT, me->mvert);
|
||||
}
|
||||
|
||||
mvert = me->mvert;
|
||||
mloop = me->mloop;
|
||||
mlooptri = BKE_mesh_runtime_looptri_ensure(me);
|
||||
numverts = me->totvert;
|
||||
dvert = CustomData_get_layer(&me->vdata, CD_MDEFORMVERT);
|
||||
mloopuv = CustomData_get_layer_named(&me->ldata, CD_MLOOPUV, ffs->uvlayer_name);
|
||||
MVert *mvert = me->mvert;
|
||||
const MLoop *mloop = me->mloop;
|
||||
const MLoopTri *mlooptri = BKE_mesh_runtime_looptri_ensure(me);
|
||||
const int numverts = me->totvert;
|
||||
const MDeformVert *dvert = CustomData_get_layer(&me->vdata, CD_MDEFORMVERT);
|
||||
const MLoopUV *mloopuv = CustomData_get_layer_named(&me->ldata, CD_MLOOPUV, ffs->uvlayer_name);
|
||||
|
||||
if (ffs->flags & FLUID_FLOW_INITVELOCITY) {
|
||||
vert_vel = MEM_callocN(sizeof(float[3]) * numverts, "manta_flow_velocity");
|
||||
|
|
|
@ -1385,7 +1385,7 @@ static void shapekey_layers_to_keyblocks(Mesh *mesh_src, Mesh *mesh_dst, int act
|
|||
for (i = 0; i < tot; i++) {
|
||||
CustomDataLayer *layer =
|
||||
&mesh_src->vdata.layers[CustomData_get_layer_index_n(&mesh_src->vdata, CD_SHAPEKEY, i)];
|
||||
float(*cos)[3], (*kbcos)[3];
|
||||
float(*kbcos)[3];
|
||||
|
||||
for (kb = (KeyBlock *)mesh_dst->key->block.first; kb; kb = kb->next) {
|
||||
if (kb->uid == layer->uid) {
|
||||
|
@ -1402,7 +1402,8 @@ static void shapekey_layers_to_keyblocks(Mesh *mesh_src, Mesh *mesh_dst, int act
|
|||
MEM_freeN(kb->data);
|
||||
}
|
||||
|
||||
cos = (float(*)[3])CustomData_get_layer_n(&mesh_src->vdata, CD_SHAPEKEY, i);
|
||||
const float(*cos)[3] = (const float(*)[3])CustomData_get_layer_n(
|
||||
&mesh_src->vdata, CD_SHAPEKEY, i);
|
||||
kb->totelem = mesh_src->totvert;
|
||||
|
||||
kb->data = kbcos = (float(*)[3])MEM_malloc_arrayN(kb->totelem, sizeof(float[3]), __func__);
|
||||
|
|
|
@ -644,7 +644,7 @@ static void bm_corners_to_loops_ex(ID *id,
|
|||
MFace *mf = mface + findex;
|
||||
|
||||
for (int i = 0; i < numTex; i++) {
|
||||
MTFace *texface = (MTFace *)CustomData_get_n(fdata, CD_MTFACE, findex, i);
|
||||
const MTFace *texface = (const MTFace *)CustomData_get_n(fdata, CD_MTFACE, findex, i);
|
||||
|
||||
MLoopUV *mloopuv = (MLoopUV *)CustomData_get_n(ldata, CD_MLOOPUV, loopstart, i);
|
||||
copy_v2_v2(mloopuv->uv, texface->uv[0]);
|
||||
|
@ -662,7 +662,7 @@ static void bm_corners_to_loops_ex(ID *id,
|
|||
|
||||
for (int i = 0; i < numCol; i++) {
|
||||
MLoopCol *mloopcol = (MLoopCol *)CustomData_get_n(ldata, CD_PROP_BYTE_COLOR, loopstart, i);
|
||||
MCol *mcol = (MCol *)CustomData_get_n(fdata, CD_MCOL, findex, i);
|
||||
const MCol *mcol = (const MCol *)CustomData_get_n(fdata, CD_MCOL, findex, i);
|
||||
|
||||
MESH_MLOOPCOL_FROM_MCOL(mloopcol, &mcol[0]);
|
||||
mloopcol++;
|
||||
|
@ -678,7 +678,7 @@ static void bm_corners_to_loops_ex(ID *id,
|
|||
|
||||
if (CustomData_has_layer(fdata, CD_TESSLOOPNORMAL)) {
|
||||
float(*lnors)[3] = (float(*)[3])CustomData_get(ldata, loopstart, CD_NORMAL);
|
||||
short(*tlnors)[3] = (short(*)[3])CustomData_get(fdata, findex, CD_TESSLOOPNORMAL);
|
||||
const short(*tlnors)[3] = (short(*)[3])CustomData_get(fdata, findex, CD_TESSLOOPNORMAL);
|
||||
const int max = mf->v4 ? 4 : 3;
|
||||
|
||||
for (int i = 0; i < max; i++, lnors++, tlnors++) {
|
||||
|
@ -688,8 +688,8 @@ static void bm_corners_to_loops_ex(ID *id,
|
|||
|
||||
if (CustomData_has_layer(fdata, CD_MDISPS)) {
|
||||
MDisps *ld = (MDisps *)CustomData_get(ldata, loopstart, CD_MDISPS);
|
||||
MDisps *fd = (MDisps *)CustomData_get(fdata, findex, CD_MDISPS);
|
||||
float(*disps)[3] = fd->disps;
|
||||
const MDisps *fd = (const MDisps *)CustomData_get(fdata, findex, CD_MDISPS);
|
||||
const float(*disps)[3] = fd->disps;
|
||||
int tot = mf->v4 ? 4 : 3;
|
||||
int corners;
|
||||
|
||||
|
|
|
@ -297,7 +297,7 @@ Mesh *BKE_mesh_mirror_apply_mirror_on_axis_for_modifier(MirrorModifierData *mmd,
|
|||
/* handle shape keys */
|
||||
totshape = CustomData_number_of_layers(&result->vdata, CD_SHAPEKEY);
|
||||
for (a = 0; a < totshape; a++) {
|
||||
float(*cos)[3] = CustomData_get_layer_n(&result->vdata, CD_SHAPEKEY, a);
|
||||
const float(*cos)[3] = CustomData_get_layer_n(&result->vdata, CD_SHAPEKEY, a);
|
||||
for (i = maxVerts; i < result->totvert; i++) {
|
||||
mul_m4_v3(mtx, cos[i]);
|
||||
}
|
||||
|
|
|
@ -37,13 +37,13 @@
|
|||
|
||||
/* User data. */
|
||||
typedef struct {
|
||||
const MPoly *mpolys; /* faces */
|
||||
const MLoop *mloops; /* faces's vertices */
|
||||
const MVert *mverts; /* vertices */
|
||||
const MLoopUV *luvs; /* texture coordinates */
|
||||
float (*lnors)[3]; /* loops' normals */
|
||||
float (*tangents)[4]; /* output tangents */
|
||||
int num_polys; /* number of polygons */
|
||||
const MPoly *mpolys; /* faces */
|
||||
const MLoop *mloops; /* faces's vertices */
|
||||
const MVert *mverts; /* vertices */
|
||||
const MLoopUV *luvs; /* texture coordinates */
|
||||
const float (*lnors)[3]; /* loops' normals */
|
||||
float (*tangents)[4]; /* output tangents */
|
||||
int num_polys; /* number of polygons */
|
||||
} BKEMeshToTangent;
|
||||
|
||||
/* Mikktspace's API */
|
||||
|
@ -103,7 +103,7 @@ void BKE_mesh_calc_loop_tangent_single_ex(const MVert *mverts,
|
|||
const int UNUSED(numVerts),
|
||||
const MLoop *mloops,
|
||||
float (*r_looptangent)[4],
|
||||
float (*loopnors)[3],
|
||||
const float (*loopnors)[3],
|
||||
const MLoopUV *loopuvs,
|
||||
const int UNUSED(numLoops),
|
||||
const MPoly *mpolys,
|
||||
|
@ -156,7 +156,6 @@ void BKE_mesh_calc_loop_tangent_single(Mesh *mesh,
|
|||
ReportList *reports)
|
||||
{
|
||||
const MLoopUV *loopuvs;
|
||||
float(*loopnors)[3];
|
||||
|
||||
/* Check we have valid texture coordinates first! */
|
||||
if (uvmap) {
|
||||
|
@ -173,7 +172,7 @@ void BKE_mesh_calc_loop_tangent_single(Mesh *mesh,
|
|||
return;
|
||||
}
|
||||
|
||||
loopnors = CustomData_get_layer(&mesh->ldata, CD_NORMAL);
|
||||
const float(*loopnors)[3] = CustomData_get_layer(&mesh->ldata, CD_NORMAL);
|
||||
if (!loopnors) {
|
||||
BKE_report(
|
||||
reports, RPT_ERROR, "Tangent space computation needs loop normals, none found, aborting");
|
||||
|
|
|
@ -1403,7 +1403,7 @@ static void multires_apply_smat(struct Depsgraph *UNUSED(depsgraph),
|
|||
}
|
||||
}
|
||||
|
||||
int multires_mdisp_corners(MDisps *s)
|
||||
int multires_mdisp_corners(const MDisps *s)
|
||||
{
|
||||
int lvl = 13;
|
||||
|
||||
|
|
|
@ -3793,7 +3793,7 @@ void psys_get_from_key(ParticleKey *key, float loc[3], float vel[3], float rot[4
|
|||
}
|
||||
}
|
||||
|
||||
static void triatomat(float *v1, float *v2, float *v3, float (*uv)[2], float mat[4][4])
|
||||
static void triatomat(float *v1, float *v2, float *v3, const float (*uv)[2], float mat[4][4])
|
||||
{
|
||||
float det, w1, w2, d1[2], d2[2];
|
||||
|
||||
|
@ -3839,7 +3839,6 @@ static void psys_face_mat(Object *ob, Mesh *mesh, ParticleData *pa, float mat[4]
|
|||
{
|
||||
float v[3][3];
|
||||
MFace *mface;
|
||||
OrigSpaceFace *osface;
|
||||
const float(*orcodata)[3];
|
||||
|
||||
int i = (ELEM(pa->num_dmcache, DMCACHE_ISCHILD, DMCACHE_NOTFOUND)) ? pa->num : pa->num_dmcache;
|
||||
|
@ -3849,7 +3848,7 @@ static void psys_face_mat(Object *ob, Mesh *mesh, ParticleData *pa, float mat[4]
|
|||
}
|
||||
|
||||
mface = &mesh->mface[i];
|
||||
osface = CustomData_get(&mesh->fdata, i, CD_ORIGSPACE);
|
||||
const OrigSpaceFace *osface = CustomData_get(&mesh->fdata, i, CD_ORIGSPACE);
|
||||
|
||||
if (orco && (orcodata = CustomData_get_layer(&mesh->vdata, CD_ORCO))) {
|
||||
copy_v3_v3(v[0], orcodata[mface->v1]);
|
||||
|
@ -5036,7 +5035,6 @@ void psys_get_dupli_texture(ParticleSystem *psys,
|
|||
float uv[2],
|
||||
float orco[3])
|
||||
{
|
||||
MFace *mface;
|
||||
float loc[3];
|
||||
int num;
|
||||
|
||||
|
@ -5060,9 +5058,9 @@ void psys_get_dupli_texture(ParticleSystem *psys,
|
|||
const int uv_idx = CustomData_get_render_layer(mtf_data, CD_MTFACE);
|
||||
|
||||
if (uv_idx >= 0) {
|
||||
MTFace *mtface = CustomData_get_layer_n(mtf_data, CD_MTFACE, uv_idx);
|
||||
const MTFace *mtface = CustomData_get_layer_n(mtf_data, CD_MTFACE, uv_idx);
|
||||
if (mtface != NULL) {
|
||||
mface = CustomData_get(&psmd->mesh_final->fdata, cpa->num, CD_MFACE);
|
||||
const MFace *mface = CustomData_get(&psmd->mesh_final->fdata, cpa->num, CD_MFACE);
|
||||
mtface += cpa->num;
|
||||
psys_interpolate_uvs(mtface, mface->v4, cpa->fuv, uv);
|
||||
}
|
||||
|
@ -5104,8 +5102,8 @@ void psys_get_dupli_texture(ParticleSystem *psys,
|
|||
const int uv_idx = CustomData_get_render_layer(mtf_data, CD_MTFACE);
|
||||
|
||||
if (uv_idx >= 0) {
|
||||
MTFace *mtface = CustomData_get_layer_n(mtf_data, CD_MTFACE, uv_idx);
|
||||
mface = CustomData_get(&psmd->mesh_final->fdata, num, CD_MFACE);
|
||||
const MTFace *mtface = CustomData_get_layer_n(mtf_data, CD_MTFACE, uv_idx);
|
||||
const MFace *mface = CustomData_get(&psmd->mesh_final->fdata, num, CD_MFACE);
|
||||
mtface += num;
|
||||
psys_interpolate_uvs(mtface, mface->v4, pa->fuv, uv);
|
||||
}
|
||||
|
|
|
@ -259,7 +259,10 @@ static void get_face_uv_map_vert(
|
|||
}
|
||||
}
|
||||
|
||||
static int ss_sync_from_uv(CCGSubSurf *ss, CCGSubSurf *origss, DerivedMesh *dm, MLoopUV *mloopuv)
|
||||
static int ss_sync_from_uv(CCGSubSurf *ss,
|
||||
CCGSubSurf *origss,
|
||||
DerivedMesh *dm,
|
||||
const MLoopUV *mloopuv)
|
||||
{
|
||||
MPoly *mpoly = dm->getPolyArray(dm);
|
||||
MLoop *mloop = dm->getLoopArray(dm);
|
||||
|
@ -381,13 +384,9 @@ static int ss_sync_from_uv(CCGSubSurf *ss, CCGSubSurf *origss, DerivedMesh *dm,
|
|||
|
||||
static void set_subsurf_legacy_uv(CCGSubSurf *ss, DerivedMesh *dm, DerivedMesh *result, int n)
|
||||
{
|
||||
CCGSubSurf *uvss;
|
||||
CCGFace **faceMap;
|
||||
MTFace *tf;
|
||||
MLoopUV *mluv;
|
||||
CCGFaceIterator fi;
|
||||
int index, gridSize, gridFaces, /*edgeSize,*/ totface, x, y, S;
|
||||
MLoopUV *dmloopuv = CustomData_get_layer_n(&dm->loopData, CD_MLOOPUV, n);
|
||||
const MLoopUV *dmloopuv = CustomData_get_layer_n(&dm->loopData, CD_MLOOPUV, n);
|
||||
/* need to update both CD_MTFACE & CD_MLOOPUV, hrmf, we could get away with
|
||||
* just tface except applying the modifier then looses subsurf UV */
|
||||
MTFace *tface = CustomData_get_layer_n(&result->faceData, CD_MTFACE, n);
|
||||
|
@ -398,7 +397,7 @@ static void set_subsurf_legacy_uv(CCGSubSurf *ss, DerivedMesh *dm, DerivedMesh *
|
|||
}
|
||||
|
||||
/* create a CCGSubSurf from uv's */
|
||||
uvss = _getSubSurf(NULL, ccgSubSurf_getSubdivisionLevels(ss), 2, CCG_USE_ARENA);
|
||||
CCGSubSurf *uvss = _getSubSurf(NULL, ccgSubSurf_getSubdivisionLevels(ss), 2, CCG_USE_ARENA);
|
||||
|
||||
if (!ss_sync_from_uv(uvss, ss, dm, dmloopuv)) {
|
||||
ccgSubSurf_free(uvss);
|
||||
|
@ -412,7 +411,7 @@ static void set_subsurf_legacy_uv(CCGSubSurf *ss, DerivedMesh *dm, DerivedMesh *
|
|||
gridFaces = gridSize - 1;
|
||||
|
||||
/* make a map from original faces to CCGFaces */
|
||||
faceMap = MEM_mallocN(totface * sizeof(*faceMap), "facemapuv");
|
||||
CCGFace **faceMap = MEM_mallocN(totface * sizeof(*faceMap), "facemapuv");
|
||||
for (ccgSubSurf_initFaceIterator(uvss, &fi); !ccgFaceIterator_isStopped(&fi);
|
||||
ccgFaceIterator_next(&fi)) {
|
||||
CCGFace *f = ccgFaceIterator_getCurrent(&fi);
|
||||
|
@ -420,8 +419,8 @@ static void set_subsurf_legacy_uv(CCGSubSurf *ss, DerivedMesh *dm, DerivedMesh *
|
|||
}
|
||||
|
||||
/* load coordinates from uvss into tface */
|
||||
tf = tface;
|
||||
mluv = mloopuv;
|
||||
MTFace *tf = tface;
|
||||
MLoopUV *mluv = mloopuv;
|
||||
|
||||
for (index = 0; index < totface; index++) {
|
||||
CCGFace *f = faceMap[index];
|
||||
|
|
|
@ -277,7 +277,7 @@ static void particle_calculate_parent_uvs(ParticleSystem *psys,
|
|||
ParticleSystemModifierData *psmd,
|
||||
const int num_uv_layers,
|
||||
const int parent_index,
|
||||
/*const*/ MTFace **mtfaces,
|
||||
const MTFace **mtfaces,
|
||||
float (*r_uv)[2])
|
||||
{
|
||||
if (psmd == NULL) {
|
||||
|
@ -306,7 +306,7 @@ static void particle_calculate_parent_mcol(ParticleSystem *psys,
|
|||
ParticleSystemModifierData *psmd,
|
||||
const int num_col_layers,
|
||||
const int parent_index,
|
||||
/*const*/ MCol **mcols,
|
||||
const MCol **mcols,
|
||||
MCol *r_mcol)
|
||||
{
|
||||
if (psmd == NULL) {
|
||||
|
@ -337,7 +337,7 @@ static void particle_interpolate_children_uvs(ParticleSystem *psys,
|
|||
ParticleSystemModifierData *psmd,
|
||||
const int num_uv_layers,
|
||||
const int child_index,
|
||||
/*const*/ MTFace **mtfaces,
|
||||
const MTFace **mtfaces,
|
||||
float (*r_uv)[2])
|
||||
{
|
||||
if (psmd == NULL) {
|
||||
|
@ -361,7 +361,7 @@ static void particle_interpolate_children_mcol(ParticleSystem *psys,
|
|||
ParticleSystemModifierData *psmd,
|
||||
const int num_col_layers,
|
||||
const int child_index,
|
||||
/*const*/ MCol **mcols,
|
||||
const MCol **mcols,
|
||||
MCol *r_mcol)
|
||||
{
|
||||
if (psmd == NULL) {
|
||||
|
@ -388,7 +388,7 @@ static void particle_calculate_uvs(ParticleSystem *psys,
|
|||
const int num_uv_layers,
|
||||
const int parent_index,
|
||||
const int child_index,
|
||||
/*const*/ MTFace **mtfaces,
|
||||
const MTFace **mtfaces,
|
||||
float (**r_parent_uvs)[2],
|
||||
float (**r_uv)[2])
|
||||
{
|
||||
|
@ -431,7 +431,7 @@ static void particle_calculate_mcol(ParticleSystem *psys,
|
|||
const int num_col_layers,
|
||||
const int parent_index,
|
||||
const int child_index,
|
||||
/*const*/ MCol **mcols,
|
||||
const MCol **mcols,
|
||||
MCol **r_parent_mcol,
|
||||
MCol **r_mcol)
|
||||
{
|
||||
|
@ -482,8 +482,8 @@ static int particle_batch_cache_fill_segments(ParticleSystem *psys,
|
|||
const int num_path_keys,
|
||||
const int num_uv_layers,
|
||||
const int num_col_layers,
|
||||
/*const*/ MTFace **mtfaces,
|
||||
/*const*/ MCol **mcols,
|
||||
const MTFace **mtfaces,
|
||||
const MCol **mcols,
|
||||
uint *uv_id,
|
||||
uint *col_id,
|
||||
float (***r_parent_uvs)[2],
|
||||
|
@ -713,11 +713,11 @@ static int particle_batch_cache_fill_strands_data(ParticleSystem *psys,
|
|||
GPUVertBufRaw *seg_step,
|
||||
float (***r_parent_uvs)[2],
|
||||
GPUVertBufRaw *uv_step,
|
||||
MTFace **mtfaces,
|
||||
const MTFace **mtfaces,
|
||||
int num_uv_layers,
|
||||
MCol ***r_parent_mcol,
|
||||
GPUVertBufRaw *col_step,
|
||||
MCol **mcols,
|
||||
const MCol **mcols,
|
||||
int num_col_layers)
|
||||
{
|
||||
const bool is_simple = (psys->part->childtype == PART_CHILD_PARTICLES);
|
||||
|
@ -834,8 +834,8 @@ static void particle_batch_cache_ensure_procedural_strand_data(PTCacheEdit *edit
|
|||
GPUVertBufRaw uv_step[MAX_MTFACE];
|
||||
GPUVertBufRaw col_step[MAX_MCOL];
|
||||
|
||||
MTFace *mtfaces[MAX_MTFACE] = {NULL};
|
||||
MCol *mcols[MAX_MCOL] = {NULL};
|
||||
const MTFace *mtfaces[MAX_MTFACE] = {NULL};
|
||||
const MCol *mcols[MAX_MCOL] = {NULL};
|
||||
float(**parent_uvs)[2] = NULL;
|
||||
MCol **parent_mcol = NULL;
|
||||
|
||||
|
@ -909,12 +909,13 @@ static void particle_batch_cache_ensure_procedural_strand_data(PTCacheEdit *edit
|
|||
BKE_mesh_tessface_ensure(psmd->mesh_final);
|
||||
if (cache->num_uv_layers) {
|
||||
for (int j = 0; j < cache->num_uv_layers; j++) {
|
||||
mtfaces[j] = (MTFace *)CustomData_get_layer_n(&psmd->mesh_final->fdata, CD_MTFACE, j);
|
||||
mtfaces[j] = (const MTFace *)CustomData_get_layer_n(
|
||||
&psmd->mesh_final->fdata, CD_MTFACE, j);
|
||||
}
|
||||
}
|
||||
if (cache->num_col_layers) {
|
||||
for (int j = 0; j < cache->num_col_layers; j++) {
|
||||
mcols[j] = (MCol *)CustomData_get_layer_n(&psmd->mesh_final->fdata, CD_MCOL, j);
|
||||
mcols[j] = (const MCol *)CustomData_get_layer_n(&psmd->mesh_final->fdata, CD_MCOL, j);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -930,11 +931,11 @@ static void particle_batch_cache_ensure_procedural_strand_data(PTCacheEdit *edit
|
|||
&seg_step,
|
||||
&parent_uvs,
|
||||
uv_step,
|
||||
(MTFace **)mtfaces,
|
||||
mtfaces,
|
||||
cache->num_uv_layers,
|
||||
&parent_mcol,
|
||||
col_step,
|
||||
(MCol **)mcols,
|
||||
mcols,
|
||||
cache->num_col_layers);
|
||||
}
|
||||
else {
|
||||
|
@ -951,11 +952,11 @@ static void particle_batch_cache_ensure_procedural_strand_data(PTCacheEdit *edit
|
|||
&seg_step,
|
||||
&parent_uvs,
|
||||
uv_step,
|
||||
(MTFace **)mtfaces,
|
||||
mtfaces,
|
||||
cache->num_uv_layers,
|
||||
&parent_mcol,
|
||||
col_step,
|
||||
(MCol **)mcols,
|
||||
mcols,
|
||||
cache->num_col_layers);
|
||||
}
|
||||
if (psys->childcache) {
|
||||
|
@ -970,11 +971,11 @@ static void particle_batch_cache_ensure_procedural_strand_data(PTCacheEdit *edit
|
|||
&seg_step,
|
||||
&parent_uvs,
|
||||
uv_step,
|
||||
(MTFace **)mtfaces,
|
||||
mtfaces,
|
||||
cache->num_uv_layers,
|
||||
&parent_mcol,
|
||||
col_step,
|
||||
(MCol **)mcols,
|
||||
mcols,
|
||||
cache->num_col_layers);
|
||||
}
|
||||
}
|
||||
|
@ -1147,8 +1148,8 @@ static void particle_batch_cache_ensure_pos_and_seg(PTCacheEdit *edit,
|
|||
int num_col_layers = 0;
|
||||
int active_uv = 0;
|
||||
int active_col = 0;
|
||||
MTFace **mtfaces = NULL;
|
||||
MCol **mcols = NULL;
|
||||
const MTFace **mtfaces = NULL;
|
||||
const MCol **mcols = NULL;
|
||||
float(**parent_uvs)[2] = NULL;
|
||||
MCol **parent_mcol = NULL;
|
||||
|
||||
|
@ -1214,13 +1215,14 @@ static void particle_batch_cache_ensure_pos_and_seg(PTCacheEdit *edit,
|
|||
if (num_uv_layers) {
|
||||
mtfaces = MEM_mallocN(sizeof(*mtfaces) * num_uv_layers, "Faces UV layers");
|
||||
for (int i = 0; i < num_uv_layers; i++) {
|
||||
mtfaces[i] = (MTFace *)CustomData_get_layer_n(&psmd->mesh_final->fdata, CD_MTFACE, i);
|
||||
mtfaces[i] = (const MTFace *)CustomData_get_layer_n(
|
||||
&psmd->mesh_final->fdata, CD_MTFACE, i);
|
||||
}
|
||||
}
|
||||
if (num_col_layers) {
|
||||
mcols = MEM_mallocN(sizeof(*mcols) * num_col_layers, "Color layers");
|
||||
for (int i = 0; i < num_col_layers; i++) {
|
||||
mcols[i] = (MCol *)CustomData_get_layer_n(&psmd->mesh_final->fdata, CD_MCOL, i);
|
||||
mcols[i] = (const MCol *)CustomData_get_layer_n(&psmd->mesh_final->fdata, CD_MCOL, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -180,7 +180,7 @@ static void fill_vertbuf_with_attribute(const MeshRenderData *mr,
|
|||
const MPoly *mpoly = mr->mpoly;
|
||||
const MLoop *mloop = mr->mloop;
|
||||
|
||||
const AttributeType *attr_data = static_cast<AttributeType *>(
|
||||
const AttributeType *attr_data = static_cast<const AttributeType *>(
|
||||
CustomData_get_layer_n(custom_data, request.cd_type, layer_index));
|
||||
|
||||
using converter = attribute_type_converter<AttributeType, VBOType>;
|
||||
|
|
|
@ -108,7 +108,8 @@ static void extract_uv_init(const MeshRenderData *mr,
|
|||
}
|
||||
}
|
||||
else {
|
||||
MLoopUV *layer_data = (MLoopUV *)CustomData_get_layer_n(cd_ldata, CD_MLOOPUV, i);
|
||||
const MLoopUV *layer_data = (const MLoopUV *)CustomData_get_layer_n(
|
||||
cd_ldata, CD_MLOOPUV, i);
|
||||
for (int ml_index = 0; ml_index < mr->loop_len; ml_index++, uv_data++, layer_data++) {
|
||||
memcpy(uv_data, layer_data->uv, sizeof(*uv_data));
|
||||
}
|
||||
|
|
|
@ -107,7 +107,7 @@ static void join_mesh_single(Depsgraph *depsgraph,
|
|||
|
||||
/* vertex groups */
|
||||
MDeformVert *dvert = CustomData_get(vdata, *vertofs, CD_MDEFORMVERT);
|
||||
MDeformVert *dvert_src = CustomData_get(&me->vdata, 0, CD_MDEFORMVERT);
|
||||
const MDeformVert *dvert_src = CustomData_get(&me->vdata, 0, CD_MDEFORMVERT);
|
||||
|
||||
/* Remap to correct new vgroup indices, if needed. */
|
||||
if (dvert_src) {
|
||||
|
@ -255,7 +255,7 @@ static void join_mesh_single(Depsgraph *depsgraph,
|
|||
|
||||
/* Face maps. */
|
||||
int *fmap = CustomData_get(pdata, *polyofs, CD_FACEMAP);
|
||||
int *fmap_src = CustomData_get(&me->pdata, 0, CD_FACEMAP);
|
||||
const int *fmap_src = CustomData_get(&me->pdata, 0, CD_FACEMAP);
|
||||
|
||||
/* Remap to correct new face-map indices, if needed. */
|
||||
if (fmap_src) {
|
||||
|
|
|
@ -4084,7 +4084,7 @@ typedef struct {
|
|||
|
||||
static void proj_paint_layer_clone_init(ProjPaintState *ps, ProjPaintLayerClone *layer_clone)
|
||||
{
|
||||
MLoopUV *mloopuv_clone_base = NULL;
|
||||
const MLoopUV *mloopuv_clone_base = NULL;
|
||||
|
||||
/* use clone mtface? */
|
||||
if (ps->do_layer_clone) {
|
||||
|
|
|
@ -637,7 +637,7 @@ static int vertex_to_loop_colors_exec(bContext *C, wmOperator *UNUSED(op))
|
|||
if (MPropCol_layer_n == -1) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
MPropCol *vertcols = CustomData_get_layer_n(&mesh->vdata, CD_PROP_COLOR, MPropCol_layer_n);
|
||||
const MPropCol *vertcols = CustomData_get_layer_n(&mesh->vdata, CD_PROP_COLOR, MPropCol_layer_n);
|
||||
|
||||
const MLoop *loops = CustomData_get_layer(&mesh->ldata, CD_MLOOP);
|
||||
const MPoly *polys = CustomData_get_layer(&mesh->pdata, CD_MPOLY);
|
||||
|
@ -711,7 +711,8 @@ static int loop_to_vertex_colors_exec(bContext *C, wmOperator *UNUSED(op))
|
|||
if (mloopcol_layer_n == -1) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
MLoopCol *loopcols = CustomData_get_layer_n(&mesh->ldata, CD_PROP_BYTE_COLOR, mloopcol_layer_n);
|
||||
const MLoopCol *loopcols = CustomData_get_layer_n(
|
||||
&mesh->ldata, CD_PROP_BYTE_COLOR, mloopcol_layer_n);
|
||||
|
||||
const int MPropCol_layer_n = CustomData_get_active_layer(&mesh->vdata, CD_PROP_COLOR);
|
||||
if (MPropCol_layer_n == -1) {
|
||||
|
|
|
@ -48,9 +48,9 @@ static const std::string propNameOriginalCoordinates("Pref");
|
|||
static void get_uvs(const CDStreamConfig &config,
|
||||
std::vector<Imath::V2f> &uvs,
|
||||
std::vector<uint32_t> &uvidx,
|
||||
void *cd_data)
|
||||
const void *cd_data)
|
||||
{
|
||||
MLoopUV *mloopuv_array = static_cast<MLoopUV *>(cd_data);
|
||||
const MLoopUV *mloopuv_array = static_cast<const MLoopUV *>(cd_data);
|
||||
|
||||
if (!mloopuv_array) {
|
||||
return;
|
||||
|
@ -68,7 +68,7 @@ static void get_uvs(const CDStreamConfig &config,
|
|||
/* Iterate in reverse order to match exported polygons. */
|
||||
for (int i = 0; i < num_poly; i++) {
|
||||
MPoly ¤t_poly = polygons[i];
|
||||
MLoopUV *loopuv = mloopuv_array + current_poly.loopstart + current_poly.totloop;
|
||||
const MLoopUV *loopuv = mloopuv_array + current_poly.loopstart + current_poly.totloop;
|
||||
|
||||
for (int j = 0; j < current_poly.totloop; j++, count++) {
|
||||
loopuv--;
|
||||
|
@ -87,7 +87,7 @@ static void get_uvs(const CDStreamConfig &config,
|
|||
for (int i = 0; i < num_poly; i++) {
|
||||
MPoly ¤t_poly = polygons[i];
|
||||
MLoop *looppoly = mloop + current_poly.loopstart + current_poly.totloop;
|
||||
MLoopUV *loopuv = mloopuv_array + current_poly.loopstart + current_poly.totloop;
|
||||
const MLoopUV *loopuv = mloopuv_array + current_poly.loopstart + current_poly.totloop;
|
||||
|
||||
for (int j = 0; j < current_poly.totloop; j++) {
|
||||
looppoly--;
|
||||
|
@ -125,7 +125,7 @@ const char *get_uv_sample(UVSample &sample, const CDStreamConfig &config, Custom
|
|||
return "";
|
||||
}
|
||||
|
||||
void *cd_data = CustomData_get_layer_n(data, CD_MLOOPUV, active_uvlayer);
|
||||
const void *cd_data = CustomData_get_layer_n(data, CD_MLOOPUV, active_uvlayer);
|
||||
|
||||
get_uvs(config, sample.uvs, sample.indices, cd_data);
|
||||
|
||||
|
@ -283,7 +283,7 @@ void write_custom_data(const OCompoundProperty &prop,
|
|||
const int tot_layers = CustomData_number_of_layers(data, cd_data_type);
|
||||
|
||||
for (int i = 0; i < tot_layers; i++) {
|
||||
void *cd_data = CustomData_get_layer_n(data, cd_data_type, i);
|
||||
const void *cd_data = CustomData_get_layer_n(data, cd_data_type, i);
|
||||
const char *name = CustomData_get_layer_name(data, cd_data_type, i);
|
||||
|
||||
if (cd_data_type == CD_MLOOPUV) {
|
||||
|
|
|
@ -377,25 +377,22 @@ BLI_INLINE void read_uvs_params(CDStreamConfig &config,
|
|||
static void *add_customdata_cb(Mesh *mesh, const char *name, int data_type)
|
||||
{
|
||||
CustomDataType cd_data_type = static_cast<CustomDataType>(data_type);
|
||||
void *cd_ptr;
|
||||
CustomData *loopdata;
|
||||
int numloops;
|
||||
|
||||
/* unsupported custom data type -- don't do anything. */
|
||||
if (!ELEM(cd_data_type, CD_MLOOPUV, CD_PROP_BYTE_COLOR)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
loopdata = &mesh->ldata;
|
||||
cd_ptr = CustomData_get_layer_named(loopdata, cd_data_type, name);
|
||||
void *cd_ptr = CustomData_get_layer_named(&mesh->ldata, cd_data_type, name);
|
||||
if (cd_ptr != nullptr) {
|
||||
/* layer already exists, so just return it. */
|
||||
return cd_ptr;
|
||||
}
|
||||
|
||||
/* Create a new layer. */
|
||||
numloops = mesh->totloop;
|
||||
cd_ptr = CustomData_add_layer_named(loopdata, cd_data_type, CD_DEFAULT, nullptr, numloops, name);
|
||||
int numloops = mesh->totloop;
|
||||
cd_ptr = CustomData_add_layer_named(
|
||||
&mesh->ldata, cd_data_type, CD_DEFAULT, nullptr, numloops, name);
|
||||
return cd_ptr;
|
||||
}
|
||||
|
||||
|
|
|
@ -477,7 +477,8 @@ void GeometryExporter::createVertexColorSource(std::string geom_id, Mesh *me)
|
|||
for (int a = 0; a < totlayer_mcol; a++) {
|
||||
|
||||
map_index++;
|
||||
MLoopCol *mloopcol = (MLoopCol *)CustomData_get_layer_n(&me->ldata, CD_PROP_BYTE_COLOR, a);
|
||||
const MLoopCol *mloopcol = (const MLoopCol *)CustomData_get_layer_n(
|
||||
&me->ldata, CD_PROP_BYTE_COLOR, a);
|
||||
|
||||
COLLADASW::FloatSourceF source(mSW);
|
||||
|
||||
|
@ -502,7 +503,7 @@ void GeometryExporter::createVertexColorSource(std::string geom_id, Mesh *me)
|
|||
MPoly *mpoly;
|
||||
int i;
|
||||
for (i = 0, mpoly = me->mpoly; i < me->totpoly; i++, mpoly++) {
|
||||
MLoopCol *mlc = mloopcol + mpoly->loopstart;
|
||||
const MLoopCol *mlc = mloopcol + mpoly->loopstart;
|
||||
for (int j = 0; j < mpoly->totloop; j++, mlc++) {
|
||||
source.appendValues(mlc->r / 255.0f, mlc->g / 255.0f, mlc->b / 255.0f, mlc->a / 255.0f);
|
||||
}
|
||||
|
|
|
@ -626,9 +626,10 @@ static void rna_CustomDataLayer_clone_set(PointerRNA *ptr, CustomData *data, int
|
|||
|
||||
static bool rna_MEdge_freestyle_edge_mark_get(PointerRNA *ptr)
|
||||
{
|
||||
Mesh *me = rna_mesh(ptr);
|
||||
MEdge *medge = (MEdge *)ptr->data;
|
||||
FreestyleEdge *fed = CustomData_get(&me->edata, (int)(medge - me->medge), CD_FREESTYLE_EDGE);
|
||||
const Mesh *me = rna_mesh(ptr);
|
||||
const MEdge *medge = (MEdge *)ptr->data;
|
||||
const FreestyleEdge *fed = CustomData_get(
|
||||
&me->edata, (int)(medge - me->medge), CD_FREESTYLE_EDGE);
|
||||
|
||||
return fed && (fed->flag & FREESTYLE_EDGE_MARK) != 0;
|
||||
}
|
||||
|
@ -652,9 +653,10 @@ static void rna_MEdge_freestyle_edge_mark_set(PointerRNA *ptr, bool value)
|
|||
|
||||
static bool rna_MPoly_freestyle_face_mark_get(PointerRNA *ptr)
|
||||
{
|
||||
Mesh *me = rna_mesh(ptr);
|
||||
MPoly *mpoly = (MPoly *)ptr->data;
|
||||
FreestyleFace *ffa = CustomData_get(&me->pdata, (int)(mpoly - me->mpoly), CD_FREESTYLE_FACE);
|
||||
const Mesh *me = rna_mesh(ptr);
|
||||
const MPoly *mpoly = (MPoly *)ptr->data;
|
||||
const FreestyleFace *ffa = CustomData_get(
|
||||
&me->pdata, (int)(mpoly - me->mpoly), CD_FREESTYLE_FACE);
|
||||
|
||||
return ffa && (ffa->flag & FREESTYLE_FACE_MARK) != 0;
|
||||
}
|
||||
|
|
|
@ -660,7 +660,7 @@ static void rna_ParticleSystem_uv_on_emitter(ParticleSystem *particlesystem,
|
|||
}
|
||||
else {
|
||||
MFace *mface = &modifier->mesh_final->mface[num];
|
||||
MTFace *mtface = (MTFace *)CustomData_get_layer_n(
|
||||
const MTFace *mtface = (const MTFace *)CustomData_get_layer_n(
|
||||
&modifier->mesh_final->fdata, CD_MTFACE, uv_no);
|
||||
|
||||
psys_interpolate_uvs(&mtface[num], mface->v4, *fuv, r_uv);
|
||||
|
@ -694,7 +694,8 @@ static void rna_ParticleSystem_mcol_on_emitter(ParticleSystem *particlesystem,
|
|||
}
|
||||
else {
|
||||
MFace *mface = &modifier->mesh_final->mface[num];
|
||||
MCol *mc = (MCol *)CustomData_get_layer_n(&modifier->mesh_final->fdata, CD_MCOL, vcol_no);
|
||||
const MCol *mc = (const MCol *)CustomData_get_layer_n(
|
||||
&modifier->mesh_final->fdata, CD_MCOL, vcol_no);
|
||||
MCol mcol;
|
||||
|
||||
psys_interpolate_mcol(&mc[num * 4], mface->v4, *fuv, &mcol);
|
||||
|
|
|
@ -911,7 +911,6 @@ static Mesh *explodeMesh(ExplodeModifierData *emd,
|
|||
int totdup = 0, totvert = 0, totface = 0, totpart = 0, delface = 0;
|
||||
int i, v, u;
|
||||
uint ed_v1, ed_v2, mindex = 0;
|
||||
MTFace *mtface = NULL, *mtf;
|
||||
|
||||
totface = mesh->totface;
|
||||
totvert = mesh->totvert;
|
||||
|
@ -977,7 +976,7 @@ static Mesh *explodeMesh(ExplodeModifierData *emd,
|
|||
/* the final duplicated vertices */
|
||||
explode = BKE_mesh_new_nomain_from_template(mesh, totdup, 0, totface - delface, 0, 0);
|
||||
|
||||
mtface = CustomData_get_layer_named(&explode->fdata, CD_MTFACE, emd->uvname);
|
||||
MTFace *mtface = CustomData_get_layer_named(&explode->fdata, CD_MTFACE, emd->uvname);
|
||||
|
||||
/* getting back to object space */
|
||||
invert_m4_m4(imat, ctx->object->obmat);
|
||||
|
@ -1086,7 +1085,7 @@ static Mesh *explodeMesh(ExplodeModifierData *emd,
|
|||
/* Clamp to this range to avoid flipping to the other side of the coordinates. */
|
||||
CLAMP(age, 0.001f, 0.999f);
|
||||
|
||||
mtf = mtface + u;
|
||||
MTFace *mtf = mtface + u;
|
||||
|
||||
mtf->uv[0][0] = mtf->uv[1][0] = mtf->uv[2][0] = mtf->uv[3][0] = age;
|
||||
mtf->uv[0][1] = mtf->uv[1][1] = mtf->uv[2][1] = mtf->uv[3][1] = 0.5f;
|
||||
|
|
|
@ -508,11 +508,11 @@ static void generate_margin(ImBuf *ibuf,
|
|||
mloop = me->mloop;
|
||||
|
||||
if ((uv_layer == nullptr) || (uv_layer[0] == '\0')) {
|
||||
mloopuv = static_cast<MLoopUV const *>(CustomData_get_layer(&me->ldata, CD_MLOOPUV));
|
||||
mloopuv = static_cast<const MLoopUV *>(CustomData_get_layer(&me->ldata, CD_MLOOPUV));
|
||||
}
|
||||
else {
|
||||
int uv_id = CustomData_get_named_layer(&me->ldata, CD_MLOOPUV, uv_layer);
|
||||
mloopuv = static_cast<MLoopUV const *>(
|
||||
mloopuv = static_cast<const MLoopUV *>(
|
||||
CustomData_get_layer_n(&me->ldata, CD_MLOOPUV, uv_id));
|
||||
}
|
||||
|
||||
|
|
|
@ -271,7 +271,6 @@ static void pointdensity_cache_vertex_color(PointDensity *pd,
|
|||
{
|
||||
const MLoop *mloop = mesh->mloop;
|
||||
const int totloop = mesh->totloop;
|
||||
const MLoopCol *mcol;
|
||||
char layername[MAX_CUSTOMDATA_LAYER_NAME];
|
||||
int i;
|
||||
|
||||
|
@ -282,7 +281,7 @@ static void pointdensity_cache_vertex_color(PointDensity *pd,
|
|||
}
|
||||
CustomData_validate_layer_name(
|
||||
&mesh->ldata, CD_PROP_BYTE_COLOR, pd->vertex_attribute_name, layername);
|
||||
mcol = CustomData_get_layer_named(&mesh->ldata, CD_PROP_BYTE_COLOR, layername);
|
||||
const MLoopCol *mcol = CustomData_get_layer_named(&mesh->ldata, CD_PROP_BYTE_COLOR, layername);
|
||||
if (!mcol) {
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue