diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-11-22 17:16:11 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-11-22 17:16:11 +0300 |
commit | 4a20c386fd14553a03f64bb433a2c3d335a971fe (patch) | |
tree | c5df7d6758915696d9e9a65ad01d93989cc9cf66 /source/blender/blenkernel/intern/bvhutils.c | |
parent | 69246d908018abe7c47a924dd1a16183bc8ec803 (diff) |
bugfix [#20768] Project Snap Broken
Diffstat (limited to 'source/blender/blenkernel/intern/bvhutils.c')
-rw-r--r-- | source/blender/blenkernel/intern/bvhutils.c | 39 |
1 files changed, 29 insertions, 10 deletions
diff --git a/source/blender/blenkernel/intern/bvhutils.c b/source/blender/blenkernel/intern/bvhutils.c index 671bcb36680..882295b931c 100644 --- a/source/blender/blenkernel/intern/bvhutils.c +++ b/source/blender/blenkernel/intern/bvhutils.c @@ -36,6 +36,7 @@ #include "BKE_DerivedMesh.h" #include "BKE_utildefines.h" +#include "BLI_editVert.h" #include "BLI_math.h" #include "MEM_guardedalloc.h" @@ -577,16 +578,34 @@ BVHTree* bvhtree_from_mesh_faces(BVHTreeFromMesh *data, DerivedMesh *mesh, float tree = BLI_bvhtree_new(numFaces, epsilon, tree_type, axis); if(tree != NULL) { - for(i = 0; i < numFaces; i++) - { - float co[4][3]; - VECCOPY(co[0], vert[ face[i].v1 ].co); - VECCOPY(co[1], vert[ face[i].v2 ].co); - VECCOPY(co[2], vert[ face[i].v3 ].co); - if(face[i].v4) - VECCOPY(co[3], vert[ face[i].v4 ].co); - - BLI_bvhtree_insert(tree, i, co[0], face[i].v4 ? 4 : 3); + /* XXX, for snap only, em & dm are assumed to be aligned, since dm is the em's cage */ + EditMesh *em= data->em_evil; + if(em) { + EditFace *efa= em->faces.first; + for(i = 0; i < numFaces; i++, efa= efa->next) { + if(!(efa->f & 1) && efa->h==0 && !((efa->v1->f&1)+(efa->v2->f&1)+(efa->v3->f&1)+(efa->v4?efa->v4->f&1:0))) { + float co[4][3]; + VECCOPY(co[0], vert[ face[i].v1 ].co); + VECCOPY(co[1], vert[ face[i].v2 ].co); + VECCOPY(co[2], vert[ face[i].v3 ].co); + if(face[i].v4) + VECCOPY(co[3], vert[ face[i].v4 ].co); + + BLI_bvhtree_insert(tree, i, co[0], face[i].v4 ? 4 : 3); + } + } + } + else { + for(i = 0; i < numFaces; i++) { + float co[4][3]; + VECCOPY(co[0], vert[ face[i].v1 ].co); + VECCOPY(co[1], vert[ face[i].v2 ].co); + VECCOPY(co[2], vert[ face[i].v3 ].co); + if(face[i].v4) + VECCOPY(co[3], vert[ face[i].v4 ].co); + + BLI_bvhtree_insert(tree, i, co[0], face[i].v4 ? 4 : 3); + } } BLI_bvhtree_balance(tree); |