Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorHoward Trickey <howard.trickey@gmail.com>2013-09-19 16:47:35 +0400
committerHoward Trickey <howard.trickey@gmail.com>2013-09-19 16:47:35 +0400
commit67fa1a57ba953c749dac526104b4b185ab027476 (patch)
tree750a488ef30eab94d8ed3bf01eccf1b768f4821e /source
parent0be2e21e2d7e3ad170021ddf5ca82e634175324b (diff)
Fix potential crash in knife.
A crash was reported but without info to reproduce. This is a likely crash introduced by previous fix to allow linehits to snap to vertices. The function to find connected linehits can't assume all linehits have edges any more.
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/mesh/editmesh_knife.c66
1 files changed, 49 insertions, 17 deletions
diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c
index 7ea1432a791..5051a5ac259 100644
--- a/source/blender/editors/mesh/editmesh_knife.c
+++ b/source/blender/editors/mesh/editmesh_knife.c
@@ -590,25 +590,57 @@ static int verge_linehit(const void *vlh1, const void *vlh2)
static int find_connected_linehit(KnifeTool_OpData *kcd, int testi, BMFace *f, int firsti, int lasti)
{
int i;
-
- for (i = firsti; i <= lasti; i++) {
- if (testi >= 0 && testi < kcd->totlinehit) {
- if (knife_find_common_face(&kcd->linehits[testi].kfe->faces,
- &kcd->linehits[i].kfe->faces))
- {
- return i;
- }
- else if (kcd->linehits[testi].v &&
- kcd->linehits[testi].v == kcd->linehits[i].v)
- {
- return i;
- }
- }
- else if (f) {
- if (find_ref(&kcd->linehits[i].kfe->faces, f))
- return i;
+ ListBase *testfaces, *ifaces;
+ BMFace *testface, *iface;
+ BMEdgeHit *lh;
+ bool shareface;
+
+ if (testi >= 0 && testi < kcd->totlinehit) {
+ testface = NULL;
+ testfaces = NULL;
+ lh = &kcd->linehits[testi];
+ if (lh->v)
+ testfaces = &lh->v->faces;
+ else if (lh->kfe)
+ testfaces = &lh->kfe->faces;
+ else if (lh->f) {
+ testfaces = NULL;
+ testface = lh->f;
}
}
+ else {
+ testface = f;
+ testfaces = NULL;
+ }
+ for (i = firsti; i <= lasti; i++) {
+ shareface = false;
+ lh = &kcd->linehits[i];
+ iface = NULL;
+ ifaces = NULL;
+ if (lh->v)
+ ifaces = &lh->v->faces;
+ else if (lh->kfe)
+ ifaces = &lh->kfe->faces;
+ else if (lh->f) {
+ ifaces = NULL;
+ iface = lh->f;
+ }
+ if (testfaces) {
+ if (ifaces)
+ shareface = knife_find_common_face(testfaces, ifaces);
+ else if (iface)
+ shareface = find_ref(testfaces, iface);
+ }
+ else if (ifaces) {
+ if (testface)
+ shareface = find_ref(ifaces, testface);
+ }
+ else if (testface && iface) {
+ shareface = (testface == iface);
+ }
+ if (shareface)
+ return i;
+ }
return -1;
}