[Bf-blender-cvs] [f499ec49644] greasepencil-object: GPencil: Don't calculate arc if the angle is too sharp
Antonio Vazquez
noreply at git.blender.org
Tue Oct 15 15:50:32 CEST 2019
Commit: f499ec496442825ef5c9937b80b9d3bb99dd0f01
Author: Antonio Vazquez
Date: Tue Oct 15 15:50:22 2019 +0200
Branches: greasepencil-object
https://developer.blender.org/rBf499ec496442825ef5c9937b80b9d3bb99dd0f01
GPencil: Don't calculate arc if the angle is too sharp
This occurs when the stroke change of direction abruptly.
===================================================================
M source/blender/editors/gpencil/gpencil_paint.c
===================================================================
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index f8d05a231d9..66cf8fbb7ee 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -3518,6 +3518,14 @@ static void gpencil_add_arc_points(tGPsdata *p, float mval[2], int segments)
interp_v2_v2v2(v_half, &pt_prev->x, mval, 0.5f);
sub_v2_v2(v_half, &pt_prev->x);
+ /* If angle is too sharp undo all changes and return. */
+ const float min_angle = DEG2RADF(120.0f);
+ float angle = angle_v2v2(v_prev, v_half);
+ if (angle < min_angle) {
+ gpd->runtime.sbuffer_used -= segments - 1;
+ return;
+ }
+
/* Project the half vector to the previous vector and calculate the mid projected point. */
float dot = dot_v2v2(v_prev, v_half);
float l = len_squared_v2(v_prev);
More information about the Bf-blender-cvs
mailing list