Fix for crash in Freestyle with sketchy chaining and Bezier Curve geometry modifier.

When the sketchy chaining is used, stroke geometry may contain a 180-degree U-turn.
If the 'error' parameter of the Bezier Curve geometry modifier is small (e.g., 10),
Bezier curve fitting will recursively split the original stroke into two pieces.
This splitting may take place at a U-turn point, causing a numerical singularity issue
that leads to a crash.

Problem report by edna in the BA Freestyle thread, with an example .blend to reproduce
the problem.  Thanks a lot!
This commit is contained in:
Tamito Kajiyama 2013-05-28 00:35:29 +00:00
parent 5de17660e2
commit 1ab7a6f9af

@ -376,6 +376,12 @@ static Vector2 ComputeCenterTangent(Vector2 *d, int center)
tHatCenter[0] = (V1[0] + V2[0]) / 2.0;
tHatCenter[1] = (V1[1] + V2[1]) / 2.0;
tHatCenter = *V2Normalize(&tHatCenter);
/* avoid numerical singularity in the special case when V1 == -V2 */
if (V2Length(&tHatCenter) < M_EPSILON) {
tHatCenter = *V2Normalize(&V1);
}
return tHatCenter;
}