Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/mesh/editface.c
| Show First 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | |||||
| /* copy the face flags, most importantly selection from the mesh to the final derived mesh, | /* copy the face flags, most importantly selection from the mesh to the final derived mesh, | ||||
| * use in object mode when selecting faces (while painting) */ | * use in object mode when selecting faces (while painting) */ | ||||
| void paintface_flush_flags(Object *ob) | void paintface_flush_flags(Object *ob) | ||||
| { | { | ||||
| Mesh *me = BKE_mesh_from_object(ob); | Mesh *me = BKE_mesh_from_object(ob); | ||||
| DerivedMesh *dm = ob->derivedFinal; | DerivedMesh *dm = ob->derivedFinal; | ||||
| MPoly *polys, *mp_orig; | MPoly *polys, *mp_orig; | ||||
| MFace *faces; | |||||
| const int *index_array = NULL; | const int *index_array = NULL; | ||||
| int totface, totpoly; | int totpoly; | ||||
| int i; | int i; | ||||
| if (me == NULL) | if (me == NULL) | ||||
| return; | return; | ||||
| /* note, call #BKE_mesh_flush_hidden_from_verts_ex first when changing hidden flags */ | /* note, call #BKE_mesh_flush_hidden_from_verts_ex first when changing hidden flags */ | ||||
| /* we could call this directly in all areas that change selection, | /* we could call this directly in all areas that change selection, | ||||
| * since this could become slow for realtime updates (circle-select for eg) */ | * since this could become slow for realtime updates (circle-select for eg) */ | ||||
| BKE_mesh_flush_select_from_polys(me); | BKE_mesh_flush_select_from_polys(me); | ||||
| if (dm == NULL) | if (dm == NULL) | ||||
| return; | return; | ||||
| /* | /* Mesh polys => Final derived polys */ | ||||
| * Try to push updated mesh poly flags to three other data sets: | |||||
| * - Mesh polys => Mesh tess faces | |||||
| * - Mesh polys => Final derived polys | |||||
| * - Final derived polys => Final derived tessfaces | |||||
| */ | |||||
| if ((index_array = CustomData_get_layer(&me->fdata, CD_ORIGINDEX))) { | |||||
| faces = me->mface; | |||||
| totface = me->totface; | |||||
| /* loop over tessfaces */ | |||||
| for (i = 0; i < totface; i++) { | |||||
| if (index_array[i] != ORIGINDEX_NONE) { | |||||
| /* Copy flags onto the original tessface from its original poly */ | |||||
| mp_orig = me->mpoly + index_array[i]; | |||||
| faces[i].flag = mp_orig->flag; | |||||
| } | |||||
| } | |||||
| } | |||||
| if ((index_array = CustomData_get_layer(&dm->polyData, CD_ORIGINDEX))) { | if ((index_array = CustomData_get_layer(&dm->polyData, CD_ORIGINDEX))) { | ||||
| polys = dm->getPolyArray(dm); | polys = dm->getPolyArray(dm); | ||||
| totpoly = dm->getNumPolys(dm); | totpoly = dm->getNumPolys(dm); | ||||
| /* loop over final derived polys */ | /* loop over final derived polys */ | ||||
| for (i = 0; i < totpoly; i++) { | for (i = 0; i < totpoly; i++) { | ||||
| if (index_array[i] != ORIGINDEX_NONE) { | if (index_array[i] != ORIGINDEX_NONE) { | ||||
| /* Copy flags onto the final derived poly from the original mesh poly */ | /* Copy flags onto the final derived poly from the original mesh poly */ | ||||
| mp_orig = me->mpoly + index_array[i]; | mp_orig = me->mpoly + index_array[i]; | ||||
| polys[i].flag = mp_orig->flag; | polys[i].flag = mp_orig->flag; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| if ((index_array = CustomData_get_layer(&dm->faceData, CD_ORIGINDEX))) { | |||||
| polys = dm->getPolyArray(dm); | |||||
| faces = dm->getTessFaceArray(dm); | |||||
| totface = dm->getNumTessFaces(dm); | |||||
| /* loop over tessfaces */ | |||||
| for (i = 0; i < totface; i++) { | |||||
| if (index_array[i] != ORIGINDEX_NONE) { | |||||
| /* Copy flags onto the final tessface from its final poly */ | |||||
| mp_orig = polys + index_array[i]; | |||||
| faces[i].flag = mp_orig->flag; | |||||
| } | |||||
| } | |||||
| } | |||||
| } | } | ||||
| void paintface_hide(Object *ob, const bool unselected) | void paintface_hide(Object *ob, const bool unselected) | ||||
| { | { | ||||
| Mesh *me; | Mesh *me; | ||||
| MPoly *mpoly; | MPoly *mpoly; | ||||
| int a; | int a; | ||||
| ▲ Show 20 Lines • Show All 722 Lines • Show Last 20 Lines | |||||