[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [57308] trunk/blender/source/blender/ editors/gpencil/gpencil_edit.c: Bugfix [#35686] Grease pencil to curve conversion causes NAN weights on vertices

Joshua Leung aligorith at gmail.com
Sun Jun 9 14:05:30 CEST 2013


Revision: 57308
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=57308
Author:   aligorith
Date:     2013-06-09 12:05:29 +0000 (Sun, 09 Jun 2013)
Log Message:
-----------
Bugfix [#35686] Grease pencil to curve conversion causes NAN weights on vertices

When you convert a grease pencil stroke to a polygon curve and look at the
vertices, the first and last vertex have weight = 0, but all others have a -NaN
value. This was caused by division by zero issues when minmax_weights[0] ==
minmax_weights[1].

Modified Paths:
--------------
    trunk/blender/source/blender/editors/gpencil/gpencil_edit.c

Modified: trunk/blender/source/blender/editors/gpencil/gpencil_edit.c
===================================================================
--- trunk/blender/source/blender/editors/gpencil/gpencil_edit.c	2013-06-09 11:57:51 UTC (rev 57307)
+++ trunk/blender/source/blender/editors/gpencil/gpencil_edit.c	2013-06-09 12:05:29 UTC (rev 57308)
@@ -1264,9 +1264,15 @@
 {
 	Nurb *nu;
 	const float delta = minmax_weights[0];
-	const float fac = 1.0f / (minmax_weights[1] - delta);
+	float fac;
 	int i;
 	
+	/* when delta == minmax_weights[0] == minmax_weights[1], we get div by zero [#35686] */
+	if (IS_EQ(delta, minmax_weights[1]))
+		fac = 1.0f;
+	else
+		fac = 1.0f / (minmax_weights[1] - delta);
+	
 	for (nu = cu->nurb.first; nu; nu = nu->next) {
 		if (nu->bezt) {
 			BezTriple *bezt = nu->bezt;
@@ -1361,12 +1367,14 @@
 	}
 
 	/* If link_strokes, be sure first and last points have a zero weight/size! */
-	if (link_strokes)
+	if (link_strokes) {
 		gp_stroke_finalize_curve_endpoints(cu);
-
+	}
+	
 	/* Update curve's weights, if needed */
-	if (norm_weights && ((minmax_weights[0] > 0.0f) || (minmax_weights[1] < 1.0f)))
+	if (norm_weights && ((minmax_weights[0] > 0.0f) || (minmax_weights[1] < 1.0f))) {
 		gp_stroke_norm_curve_weights(cu, minmax_weights);
+	}
 
 	/* Create the path animation, if needed */
 	gp_stroke_path_animation(C, reports, cu, gtd);




More information about the Bf-blender-cvs mailing list