Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/mesh_evaluate.c
| Show First 20 Lines • Show All 3,194 Lines • ▼ Show 20 Lines | # undef ML | ||||
| *r_mpoly = mpoly; | *r_mpoly = mpoly; | ||||
| *r_mloop = mloop; | *r_mloop = mloop; | ||||
| #undef ME_FGON | #undef ME_FGON | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| /** | |||||
| * Flip (invert winding of) the given \a mpoly, i.e. reverse order of its loops | |||||
| * (keeping the same vertex as 'start point'). | |||||
| * | |||||
| * \param mpoly the polygon to flip. | |||||
| * \param mloop the full loops array. | |||||
| * \param ldata the loops custom data. | |||||
| */ | |||||
| void BKE_mesh_polygon_flip(MPoly *mpoly, MLoop *mloop, CustomData *ldata) | |||||
| { | |||||
| int loopstart = mpoly->loopstart; | |||||
| int loopend = loopstart + mpoly->totloop - 1; | |||||
| const bool loops_in_ldata = (CustomData_get_layer(ldata, CD_MLOOP) == mloop); | |||||
| /* Note that we keep same start vertex for flipped face. */ | |||||
| /* We also have to update loops' edge | |||||
| * (they ell get ther original 'other edge', that is, the original edge of their original previous loop)... */ | |||||
| unsigned int prev_edge_index = mloop[loopstart].e; | |||||
| mloop[loopstart].e = mloop[loopend].e; | |||||
| for (loopstart++; loopend > loopstart; loopstart++, loopend--) { | |||||
| mloop[loopend].e = mloop[loopend - 1].e; | |||||
| SWAP(unsigned int, mloop[loopstart].e, prev_edge_index); | |||||
| if (!loops_in_ldata) { | |||||
| SWAP(MLoop, mloop[loopstart], mloop[loopend]); | |||||
| } | |||||
| CustomData_swap(ldata, loopstart, loopend); | |||||
| } | |||||
| /* Even if we did not swap the other 'pivot' loop, we need to set its swapped edge. */ | |||||
| if (loopstart == loopend) { | |||||
| mloop[loopstart].e = prev_edge_index; | |||||
| } | |||||
| } | |||||
| /** | |||||
| * Flip (invert winding of) all polygons (used to inverse their normals). | |||||
| * | |||||
| * \note Invalidates tessalation, caller must handle that. | |||||
| */ | |||||
| void BKE_mesh_polygons_flip( | |||||
| MPoly *mpoly, MLoop *mloop, CustomData *ldata, int totpoly) | |||||
| { | |||||
| MPoly *mp; | |||||
| int i; | |||||
| for (mp = mpoly, i = 0; i < totpoly; mp++, i++) { | |||||
| BKE_mesh_polygon_flip(mp, mloop, ldata); | |||||
| } | |||||
| } | |||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Mesh Flag Flushing | /** \name Mesh Flag Flushing | ||||
| * \{ */ | * \{ */ | ||||
| /* update the hide flag for edges and faces from the corresponding | /* update the hide flag for edges and faces from the corresponding | ||||
| * flag in verts */ | * flag in verts */ | ||||
| ▲ Show 20 Lines • Show All 242 Lines • Show Last 20 Lines | |||||