Fix bugs to get X-Mirror editing functionality working again
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
/**
|
||||
* $Id$
|
||||
*
|
||||
/*
|
||||
* ***** BEGIN GPL LICENSE BLOCK *****
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
|
||||
@@ -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];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user