[Bf-blender-cvs] [abc361736b9] greasepencil-object: Fix error with normal vector calculation

Antonio Vazquez noreply at git.blender.org
Mon Jan 15 19:18:28 CET 2018


Commit: abc361736b9200925416181b9d42acd95f747da3
Author: Antonio Vazquez
Date:   Mon Jan 15 19:18:21 2018 +0100
Branches: greasepencil-object
https://developer.blender.org/rBabc361736b9200925416181b9d42acd95f747da3

Fix error with normal vector calculation

In some weird situations, the normal vector of the stroke cannot be calculated and this produces errors, specially in modifiers like lighting modifier.

Now, if the stroke selected is not valid, try with the next stroke to get a right value.

===================================================================

M	source/blender/draw/engines/gpencil/gpencil_vfx.c

===================================================================

diff --git a/source/blender/draw/engines/gpencil/gpencil_vfx.c b/source/blender/draw/engines/gpencil/gpencil_vfx.c
index ad275397198..bb428eeea0d 100644
--- a/source/blender/draw/engines/gpencil/gpencil_vfx.c
+++ b/source/blender/draw/engines/gpencil/gpencil_vfx.c
@@ -352,8 +352,11 @@ static bool get_normal_vector(bGPdata *gpd, float r_point[3], float r_normal[3])
 			if (gps->totpoints >= 3) {
 				bGPDspoint *pt = &gps->points[0];
 				BKE_gpencil_stroke_normal(gps, r_normal);
-				copy_v3_v3(r_point, &pt->x);
-				return true;
+				/* in some weird situations, the normal cannot be calculated, so try next stroke */
+				if ((r_normal[0] != 0.0f) || (r_normal[1] != 0.0f) || (r_normal[2] != 0.0f)) {
+					copy_v3_v3(r_point, &pt->x);
+					return true;
+				}
 			}
 		}
 	}



More information about the Bf-blender-cvs mailing list