diff options
Diffstat (limited to 'source/blender/render/intern/bake.c')
-rw-r--r-- | source/blender/render/intern/bake.c | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/source/blender/render/intern/bake.c b/source/blender/render/intern/bake.c index d6e612ee061..64875ada5db 100644 --- a/source/blender/render/intern/bake.c +++ b/source/blender/render/intern/bake.c @@ -459,7 +459,10 @@ static TriTessFace *mesh_calc_tri_tessface(Mesh *me, bool tangent, Mesh *me_eval unsigned int mpoly_prev = UINT_MAX; float no[3]; - const MVert *mvert = CustomData_get_layer(&me->vdata, CD_MVERT); + const MVert *verts = BKE_mesh_vertices(me); + const MPoly *polys = BKE_mesh_polygons(me); + const MLoop *loops = BKE_mesh_loops(me); + looptri = MEM_mallocN(sizeof(*looptri) * tottri, __func__); triangles = MEM_callocN(sizeof(TriTessFace) * tottri, __func__); @@ -470,10 +473,10 @@ static TriTessFace *mesh_calc_tri_tessface(Mesh *me, bool tangent, Mesh *me_eval if (precomputed_normals != NULL) { BKE_mesh_recalc_looptri_with_normals( - me->mloop, me->mpoly, me->mvert, me->totloop, me->totpoly, looptri, precomputed_normals); + loops, polys, verts, me->totloop, me->totpoly, looptri, precomputed_normals); } else { - BKE_mesh_recalc_looptri(me->mloop, me->mpoly, me->mvert, me->totloop, me->totpoly, looptri); + BKE_mesh_recalc_looptri(loops, polys, verts, me->totloop, me->totpoly, looptri); } const TSpace *tspace = NULL; @@ -492,14 +495,14 @@ static TriTessFace *mesh_calc_tri_tessface(Mesh *me, bool tangent, Mesh *me_eval const float(*vert_normals)[3] = BKE_mesh_vertex_normals_ensure(me); for (i = 0; i < tottri; i++) { const MLoopTri *lt = &looptri[i]; - const MPoly *mp = &me->mpoly[lt->poly]; - - triangles[i].mverts[0] = &mvert[me->mloop[lt->tri[0]].v]; - triangles[i].mverts[1] = &mvert[me->mloop[lt->tri[1]].v]; - triangles[i].mverts[2] = &mvert[me->mloop[lt->tri[2]].v]; - triangles[i].vert_normals[0] = vert_normals[me->mloop[lt->tri[0]].v]; - triangles[i].vert_normals[1] = vert_normals[me->mloop[lt->tri[1]].v]; - triangles[i].vert_normals[2] = vert_normals[me->mloop[lt->tri[2]].v]; + const MPoly *mp = &polys[lt->poly]; + + triangles[i].mverts[0] = &verts[loops[lt->tri[0]].v]; + triangles[i].mverts[1] = &verts[loops[lt->tri[1]].v]; + triangles[i].mverts[2] = &verts[loops[lt->tri[2]].v]; + triangles[i].vert_normals[0] = vert_normals[loops[lt->tri[0]].v]; + triangles[i].vert_normals[1] = vert_normals[loops[lt->tri[1]].v]; + triangles[i].vert_normals[2] = vert_normals[loops[lt->tri[2]].v]; triangles[i].is_smooth = (mp->flag & ME_SMOOTH) != 0; if (tangent) { @@ -516,7 +519,7 @@ static TriTessFace *mesh_calc_tri_tessface(Mesh *me, bool tangent, Mesh *me_eval if (calculate_normal) { if (lt->poly != mpoly_prev) { - BKE_mesh_calc_poly_normal(mp, &me->mloop[mp->loopstart], me->mvert, no); + BKE_mesh_calc_poly_normal(mp, &loops[mp->loopstart], verts, no); mpoly_prev = lt->poly; } copy_v3_v3(triangles[i].normal, no); @@ -738,7 +741,10 @@ void RE_bake_pixels_populate(Mesh *me, const int tottri = poly_to_tri_count(me->totpoly, me->totloop); MLoopTri *looptri = MEM_mallocN(sizeof(*looptri) * tottri, __func__); - BKE_mesh_recalc_looptri(me->mloop, me->mpoly, me->mvert, me->totloop, me->totpoly, looptri); + const MVert *verts = BKE_mesh_vertices(me); + const MPoly *polys = BKE_mesh_polygons(me); + const MLoop *loops = BKE_mesh_loops(me); + BKE_mesh_recalc_looptri(loops, polys, verts, me->totloop, me->totpoly, looptri); const int *material_indices = BKE_mesh_material_indices(me); |