Fix T61427: Bevel crash with patch miter.

The adjustment phase had broken assumptions after adding miters,
and sent a null problem to eigen. Fixed code to check assumptions.
This commit is contained in:
Howard Trickey
2019-02-14 17:21:50 -05:00
parent 0f135f80f2
commit 5c432cd11b
2 changed files with 10 additions and 4 deletions

View File

@@ -2816,10 +2816,11 @@ static void adjust_the_cycle_or_chain(BoundVert *vstart, bool iscycle)
static void adjust_offsets(BevelParams *bp) static void adjust_offsets(BevelParams *bp)
{ {
BevVert *bv, *bvcur; BevVert *bv, *bvcur;
BoundVert *v, *vanchor, *vchainstart, *vnext; BoundVert *v, *vanchor, *vchainstart, *vchainend, *vnext;
EdgeHalf *enext; EdgeHalf *enext;
GHashIterator giter; GHashIterator giter;
bool iscycle; bool iscycle;
int chainlen;
/* find and process chains and cycles of unvisited BoundVerts that have eon set */ /* find and process chains and cycles of unvisited BoundVerts that have eon set */
GHASH_ITER(giter, bp->vert_hash) { GHASH_ITER(giter, bp->vert_hash) {
@@ -2840,8 +2841,9 @@ static void adjust_offsets(BevelParams *bp)
* pairs with the right side of the next edge in the cycle or chain. */ * pairs with the right side of the next edge in the cycle or chain. */
/* first follow paired edges in left->right direction */ /* first follow paired edges in left->right direction */
v = vchainstart = vanchor; v = vchainstart = vchainend = vanchor;
iscycle = false; iscycle = false;
chainlen = 1;
while (v->eon && !v->visited && !iscycle) { while (v->eon && !v->visited && !iscycle) {
v->visited = true; v->visited = true;
if (!v->efirst) if (!v->efirst)
@@ -2852,6 +2854,8 @@ static void adjust_offsets(BevelParams *bp)
BLI_assert(enext != NULL); BLI_assert(enext != NULL);
vnext = enext->leftv; vnext = enext->leftv;
v->adjchain = vnext; v->adjchain = vnext;
vchainend = vnext;
chainlen++;
if (vnext->visited) { if (vnext->visited) {
if (vnext != vchainstart) { if (vnext != vchainstart) {
break; break;
@@ -2874,9 +2878,11 @@ static void adjust_offsets(BevelParams *bp)
break; break;
vnext = enext->rightv; vnext = enext->rightv;
vnext->adjchain = v; vnext->adjchain = v;
chainlen++;
vchainstart = vnext; vchainstart = vnext;
v = vnext; v = vnext;
} while (!v->visited && v->eon); } while (!v->visited && v->eon);
if (chainlen >= 3 && !vchainstart->eon && !vchainend->eon)
adjust_the_cycle_or_chain(vchainstart, false); adjust_the_cycle_or_chain(vchainstart, false);
} }
} while ((vanchor = vanchor->next) != bv->vmesh->boundstart); } while ((vanchor = vanchor->next) != bv->vmesh->boundstart);