Fix bugs to get X-Mirror editing functionality working again
authorAndrew Wiggin <ender79bl@gmail.com>
Tue, 25 Oct 2011 16:17:26 +0000 (16:17 +0000)
committerAndrew Wiggin <ender79bl@gmail.com>
Tue, 25 Oct 2011 16:17:26 +0000 (16:17 +0000)
source/blender/editors/mesh/bmeshutils.c
source/blender/editors/mesh/editbmesh_bvh.c
source/blender/editors/mesh/editbmesh_bvh.h
source/blender/editors/mesh/editface.c
source/blender/editors/mesh/knifetool.c
source/blender/editors/mesh/meshtools.c

index 53f9dcedd1f27e27d7606566565b59cae78f8800..3a75c17b765ac3b74178bff2d9246bb8f3e9d7a7 100644 (file)
@@ -509,8 +509,9 @@ void EDBM_set_flag_all(BMEditMesh *em, int flag)
                        if (flag & BM_SELECT) {
                                BM_Select(em->bm, ele, 1);
                        }
-
-                       BM_SetHFlag(ele, flag & ~BM_SELECT);
+                       else {
+                               BM_SetHFlag(ele, flag);
+                       }
                }
        }
 }
@@ -787,11 +788,16 @@ int EDBM_vertColorCheck(BMEditMesh *em)
 
 void EDBM_CacheMirrorVerts(BMEditMesh *em)
 {
+       Mesh *me = em->me;
        BMBVHTree *tree = BMBVH_NewBVH(em, 0, NULL, NULL);
        BMIter iter;
        BMVert *v;
        float invmat[4][4];
-       int li, i;
+       int li, i, topo = 0;
+
+       if (me && (me->editflag & ME_EDIT_MIRROR_TOPO)) {
+               topo = 1;
+       }
 
        if (!em->vert_index) {
                EDBM_init_index_arrays(em, 1, 0, 0);
@@ -805,17 +811,6 @@ void EDBM_CacheMirrorVerts(BMEditMesh *em)
        li = CustomData_get_named_layer_index(&em->bm->vdata, CD_PROP_INT, "__mirror_index");
        em->bm->vdata.layers[li].flag |= CD_FLAG_TEMPORARY;
 
-       /*multiply verts by object matrix, temporarily*/
-
-       i = 0;
-       BM_ITER(v, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
-               BM_SetIndex(v, i);
-               i++;
-
-               if (em->ob) 
-                       mul_m4_v3(em->ob->obmat, v->co);
-       }
-
        BM_ITER(v, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
                BMVert *mirr;
                int *idx = CustomData_bmesh_get_layer_n(&em->bm->vdata, v->head.data, li);
@@ -825,7 +820,9 @@ void EDBM_CacheMirrorVerts(BMEditMesh *em)
                if (!BM_TestHFlag(v, BM_SELECT))
                        continue;
                
-               mirr = BMBVH_FindClosestVertTopo(tree, co, BM_SEARCH_MAXDIST, v);
+               mirr = topo ?
+                       BMBVH_FindClosestVertTopo(tree, co, BM_SEARCH_MAXDIST, v) :
+                       BMBVH_FindClosestVert(tree, co, BM_SEARCH_MAXDIST);
                if (mirr && mirr != v) {
                        *idx = BM_GetIndex(mirr);
                        idx = CustomData_bmesh_get_layer_n(&em->bm->vdata,mirr->head.data, li);
@@ -833,19 +830,7 @@ void EDBM_CacheMirrorVerts(BMEditMesh *em)
                } else *idx = -1;
        }
 
-       /*unmultiply by object matrix*/
-       if (em->ob) {
-               i = 0;
-               invert_m4_m4(invmat, em->ob->obmat);
-               BM_ITER(v, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
-                       BM_SetIndex(v, i);
-                       i++;
-
-                       mul_m4_v3(invmat, v->co);
-               }
-
-               BMBVH_FreeBVH(tree);
-       }
+       BMBVH_FreeBVH(tree);
 }
 
 BMVert *EDBM_GetMirrorVert(BMEditMesh *em, BMVert *v)
index 8ad719377959553b28c4677ed43fcd9e256e63f9..b14bbe9ba8229df1b312ee5ef686f35cc8718db5 100644 (file)
@@ -304,6 +304,7 @@ static void vertsearchcallback(void *userdata, int index, const float *UNUSED(co
                        VECCOPY(hit->co, ls[i]->v->co);
                        VECCOPY(hit->no, ls[i]->v->no);
                        hit->dist = dist;
+                       hit->index = index;
                }
        }
 }
@@ -336,7 +337,7 @@ BMVert *BMBVH_FindClosestVert(BMBVHTree *tree, float *co, float maxdist)
                        }
                }
 
-               return ls[i]->v;
+               return ls[cur]->v;
        }
 
        return NULL;
index a3ad9c7dcca33d46bdb220eef3729493a7ee8540..67bcdef2e7aefc82b2191ba9213be1a773b621ae 100644 (file)
@@ -1,3 +1,34 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/editors/mesh/editbmesh_bvh.h
+ *  \ingroup edmesh
+ */
+
 #ifndef _EDITBMESH_BVH
 #define _EDITBMESH_BVH
 
index 7eb9c15ed0abcd78d530d8151e6412f5f8f01448..894db27abaa5e910fa2d2a3c6c387437877f594b 100644 (file)
@@ -73,7 +73,7 @@ void paintface_flush_flags(Object *ob)
        Mesh *me = get_mesh(ob);
        DerivedMesh *dm = ob->derivedFinal;
        MPoly *polys, *mp_orig;
-       MFace *faces, *mf;
+       MFace *faces;
        int *index_array = NULL;
        int totface, totpoly;
        int i;
index b954c44c74cfbebd3442e48b96dd6b5b2cc7f741..cc8936078d80dd0f3be7f1bc9d8ebce3f5a82d11 100755 (executable)
@@ -1,6 +1,4 @@
-/**
- * $Id$
- *
+/*
  * ***** BEGIN GPL LICENSE BLOCK *****
  *
  * This program is free software; you can redistribute it and/or
index 3b93ceb7a6d84c5b342d9346f3d8f3287ace17fb..da7306056481b1d7ac9a2010624f323cb49646c6 100644 (file)
@@ -790,7 +790,7 @@ static intptr_t mesh_octree_find_index(MocNode **bt, MVert *mvert, float *co)
                                        return (*bt)->index[a]-1;
                        }
                        else {
-                               EditVert *eve= (EditVert *)((*bt)->index[a]);
+                               BMVert *eve= (BMVert *)((*bt)->index[a]);
                                if(compare_v3v3(eve->co, co, MOC_THRESH))
                                        return (*bt)->index[a];
                        }