face-paint mode operators were not ported from 2.4x yet hide/reveal/sel-swap
[blender.git] / source / blender / editors / mesh / editface.c
index 72d1c703c0e1d6cc50b701eb67155caaeb64f9c1..552f4b3b954c136c4fb0e2846cdaff317a04c7d1 100644 (file)
@@ -152,61 +152,55 @@ MTFace *EM_get_active_mtface(EditMesh *em, EditFace **act_efa, MCol **mcol, int
        return NULL;
 }
 
-void paintface_unhide(Scene *scene)
+void paintface_hide(Object *ob, const int unselected)
 {
        Mesh *me;
        MFace *mface;
        int a;
        
-       me= get_mesh(OBACT);
+       me= get_mesh(ob);
        if(me==0 || me->totface==0) return;
-       
+
        mface= me->mface;
        a= me->totface;
        while(a--) {
-               if(mface->flag & ME_HIDE) {
-                       mface->flag |= ME_FACE_SEL;
-                       mface->flag -= ME_HIDE;
+               if((mface->flag & ME_HIDE) == 0) {
+                       if(unselected) {
+                               if( (mface->flag & ME_FACE_SEL)==0) mface->flag |= ME_HIDE;
+                       }
+                       else {
+                               if( (mface->flag & ME_FACE_SEL)) mface->flag |= ME_HIDE;
+                       }
                }
+               if(mface->flag & ME_HIDE) mface->flag &= ~ME_FACE_SEL;
+               
                mface++;
        }
-
-       paintface_flush_flags(OBACT);
+       
+       paintface_flush_flags(ob);
 }
 
-void paintface_hide(Scene *scene)
+
+void paintface_reveal(Object *ob)
 {
        Mesh *me;
        MFace *mface;
        int a;
-       int shift=0, alt= 0; // XXX
-       
-       me= get_mesh(OBACT);
+
+       me= get_mesh(ob);
        if(me==0 || me->totface==0) return;
-       
-       if(alt) {
-               paintface_unhide(scene);
-               return;
-       }
-       
+
        mface= me->mface;
        a= me->totface;
        while(a--) {
-               if(mface->flag & ME_HIDE);
-               else {
-                       if(shift) {
-                               if( (mface->flag & ME_FACE_SEL)==0) mface->flag |= ME_HIDE;
-                       }
-                       else {
-                               if( (mface->flag & ME_FACE_SEL)) mface->flag |= ME_HIDE;
-                       }
+               if(mface->flag & ME_HIDE) {
+                       mface->flag |= ME_FACE_SEL;
+                       mface->flag -= ME_HIDE;
                }
-               if(mface->flag & ME_HIDE) mface->flag &= ~ME_FACE_SEL;
-               
                mface++;
        }
-       
-       paintface_flush_flags(OBACT);
+
+       paintface_flush_flags(ob);
 }
 
 /* Set tface seams based on edge data, uses hash table to find seam edges. */
@@ -359,37 +353,49 @@ void paintface_deselect_all_visible(Object *ob, int action, short flush_flags)
        me= get_mesh(ob);
        if(me==0) return;
        
-       if (action == SEL_TOGGLE) {
-               action = SEL_SELECT;
-
+       if(action == SEL_INVERT) {
                mface= me->mface;
                a= me->totface;
                while(a--) {
-                       if((mface->flag & ME_HIDE) == 0 && mface->flag & ME_FACE_SEL) {
-                               action = SEL_DESELECT;
-                               break;
+                       if((mface->flag & ME_HIDE) == 0) {
+                               mface->flag ^= ME_FACE_SEL;
                        }
                        mface++;
                }
        }
-       
-       mface= me->mface;
-       a= me->totface;
-       while(a--) {
-               if((mface->flag & ME_HIDE) == 0) {
-                       switch (action) {
-                       case SEL_SELECT:
-                               mface->flag |= ME_FACE_SEL;
-                               break;
-                       case SEL_DESELECT:
-                               mface->flag &= ~ME_FACE_SEL;
-                               break;
-                       case SEL_INVERT:
-                               mface->flag ^= ME_FACE_SEL;
-                               break;
+       else {
+               if (action == SEL_TOGGLE) {
+                       action = SEL_SELECT;
+
+                       mface= me->mface;
+                       a= me->totface;
+                       while(a--) {
+                               if((mface->flag & ME_HIDE) == 0 && mface->flag & ME_FACE_SEL) {
+                                       action = SEL_DESELECT;
+                                       break;
+                               }
+                               mface++;
                        }
                }
-               mface++;
+
+               mface= me->mface;
+               a= me->totface;
+               while(a--) {
+                       if((mface->flag & ME_HIDE) == 0) {
+                               switch (action) {
+                               case SEL_SELECT:
+                                       mface->flag |= ME_FACE_SEL;
+                                       break;
+                               case SEL_DESELECT:
+                                       mface->flag &= ~ME_FACE_SEL;
+                                       break;
+                               case SEL_INVERT:
+                                       mface->flag ^= ME_FACE_SEL;
+                                       break;
+                               }
+                       }
+                       mface++;
+               }
        }
 
        if(flush_flags) {
@@ -397,29 +403,6 @@ void paintface_deselect_all_visible(Object *ob, int action, short flush_flags)
        }
 }
 
-void paintface_select_swap(Scene *scene)
-{
-       Mesh *me;
-       MFace *mface;
-       int a;
-               
-       me= get_mesh(OBACT);
-       if(me==0) return;
-       
-       mface= me->mface;
-       a= me->totface;
-       while(a--) {
-               if(mface->flag & ME_HIDE);
-               else {
-                       if(mface->flag & ME_FACE_SEL) mface->flag &= ~ME_FACE_SEL;
-                       else mface->flag |= ME_FACE_SEL;
-               }
-               mface++;
-       }
-       
-       paintface_flush_flags(OBACT);
-}
-
 int paintface_minmax(Object *ob, float *min, float *max)
 {
        Mesh *me= get_mesh(ob);