From 1ab7a6f9af2fa0124fafee84d96099de9ec051e3 Mon Sep 17 00:00:00 2001 From: Tamito Kajiyama Date: Tue, 28 May 2013 00:35:29 +0000 Subject: 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! --- source/blender/freestyle/intern/geometry/FitCurve.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source/blender/freestyle/intern/geometry') diff --git a/source/blender/freestyle/intern/geometry/FitCurve.cpp b/source/blender/freestyle/intern/geometry/FitCurve.cpp index cc21ba05f3d..a5701ea05e5 100644 --- a/source/blender/freestyle/intern/geometry/FitCurve.cpp +++ b/source/blender/freestyle/intern/geometry/FitCurve.cpp @@ -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; } -- cgit v1.2.3