diff options
Diffstat (limited to 'source/blender/blenkernel/intern/particle.c')
-rw-r--r-- | source/blender/blenkernel/intern/particle.c | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 9ccd6562649..dbacd141e0e 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -1399,7 +1399,8 @@ static void init_particle_interpolation(Object *ob, pind->dietime = (key + pa->totkey - 1)->time; if (pind->mesh) { - pind->mvert[0] = &pind->mesh->mvert[pa->hair_index]; + MVert *verts = BKE_mesh_vertices_for_write(pind->mesh); + pind->mvert[0] = &verts[pa->hair_index]; pind->mvert[1] = pind->mvert[0] + 1; } } @@ -1852,7 +1853,8 @@ static float psys_interpolate_value_from_verts( return values[index]; case PART_FROM_FACE: case PART_FROM_VOLUME: { - MFace *mf = &mesh->mface[index]; + MFace *mfaces = CustomData_get_layer(&mesh->fdata, CD_MFACE); + MFace *mf = &mfaces[index]; return interpolate_particle_value( values[mf->v1], values[mf->v2], values[mf->v3], values[mf->v4], fw, mf->v4); } @@ -1941,7 +1943,7 @@ int psys_particle_dm_face_lookup(Mesh *mesh_final, index_mf_to_mpoly_deformed = NULL; - mtessface_final = mesh_final->mface; + mtessface_final = CustomData_get_layer(&mesh_final->fdata, CD_MFACE); osface_final = CustomData_get_layer(&mesh_final->fdata, CD_ORIGSPACE); if (osface_final == NULL) { @@ -2061,7 +2063,8 @@ static int psys_map_index_on_dm(Mesh *mesh, /* modify the original weights to become * weights for the derived mesh face */ OrigSpaceFace *osface = CustomData_get_layer(&mesh->fdata, CD_ORIGSPACE); - const MFace *mface = &mesh->mface[i]; + const MFace *mfaces = CustomData_get_layer(&mesh->fdata, CD_MFACE); + const MFace *mface = &mfaces[i]; if (osface == NULL) { mapfw[0] = mapfw[1] = mapfw[2] = mapfw[3] = 0.0f; @@ -2117,7 +2120,8 @@ void psys_particle_on_dm(Mesh *mesh_final, const float(*vert_normals)[3] = BKE_mesh_vertex_normals_ensure(mesh_final); if (from == PART_FROM_VERT) { - copy_v3_v3(vec, mesh_final->mvert[mapindex].co); + const MVert *vertices = BKE_mesh_vertices(mesh_final); + copy_v3_v3(vec, vertices[mapindex].co); if (nor) { copy_v3_v3(nor, vert_normals[mapindex]); @@ -2143,9 +2147,10 @@ void psys_particle_on_dm(Mesh *mesh_final, MTFace *mtface; MVert *mvert; - mface = &mesh_final->mface[mapindex]; - mvert = mesh_final->mvert; - mtface = mesh_final->mtface; + MFace *mfaces = CustomData_get_layer(&mesh_final->fdata, CD_MFACE); + mface = &mfaces[mapindex]; + mvert = BKE_mesh_vertices_for_write(mesh_final); + mtface = CustomData_get_layer(&mesh_final->fdata, CD_MTFACE); if (mtface) { mtface += mapindex; @@ -2634,7 +2639,7 @@ float *psys_cache_vgroup(Mesh *mesh, ParticleSystem *psys, int vgroup) /* hair dynamics pinning vgroup */ } else if (psys->vgroup[vgroup]) { - MDeformVert *dvert = mesh->dvert; + const MDeformVert *dvert = BKE_mesh_deform_verts(mesh); if (dvert) { int totvert = mesh->totvert, i; vg = MEM_callocN(sizeof(float) * totvert, "vg_cache"); @@ -3848,7 +3853,8 @@ static void psys_face_mat(Object *ob, Mesh *mesh, ParticleData *pa, float mat[4] return; } - mface = &mesh->mface[i]; + MFace *mfaces = CustomData_get_layer(&mesh->fdata, CD_MFACE); + mface = &mfaces[i]; const OrigSpaceFace *osface = CustomData_get(&mesh->fdata, i, CD_ORIGSPACE); if (orco && (orcodata = CustomData_get_layer(&mesh->vdata, CD_ORCO))) { @@ -3863,9 +3869,10 @@ static void psys_face_mat(Object *ob, Mesh *mesh, ParticleData *pa, float mat[4] } } else { - copy_v3_v3(v[0], mesh->mvert[mface->v1].co); - copy_v3_v3(v[1], mesh->mvert[mface->v2].co); - copy_v3_v3(v[2], mesh->mvert[mface->v3].co); + const MVert *verts = BKE_mesh_vertices(mesh); + copy_v3_v3(v[0], verts[mface->v1].co); + copy_v3_v3(v[1], verts[mface->v2].co); + copy_v3_v3(v[2], verts[mface->v3].co); } triatomat(v[0], v[1], v[2], (osface) ? osface->uv : NULL, mat); @@ -4155,6 +4162,7 @@ static int get_particle_uv(Mesh *mesh, float *texco, bool from_vert) { + MFace *mfaces = (MFace *)CustomData_get_layer(&mesh->fdata, CD_MFACE); MFace *mf; const MTFace *tf; int i; @@ -4162,10 +4170,6 @@ static int get_particle_uv(Mesh *mesh, tf = CustomData_get_layer_named(&mesh->fdata, CD_MTFACE, name); if (tf == NULL) { - tf = mesh->mtface; - } - - if (tf == NULL) { return 0; } @@ -4186,7 +4190,7 @@ static int get_particle_uv(Mesh *mesh, } else { if (from_vert) { - mf = mesh->mface; + mf = mfaces; /* This finds the first face to contain the emitting vertex, * this is not ideal, but is mostly fine as UV seams generally @@ -4199,7 +4203,7 @@ static int get_particle_uv(Mesh *mesh, } } else { - mf = &mesh->mface[i]; + mf = &mfaces[i]; } psys_interpolate_uvs(&tf[i], mf->v4, fuv, texco); |