From c10fbc002b8968232ab4bfab19fe977f90744fba Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 15 Mar 2017 14:01:30 +0100 Subject: Correct assert failure in debug mode with lasso select Just do early output and don't bother with any GLSL program bind when there is not enough points of lasso to draw. This could have happened at the very beginning of the stroke. --- source/blender/windowmanager/intern/wm_gesture.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'source/blender/windowmanager/intern/wm_gesture.c') diff --git a/source/blender/windowmanager/intern/wm_gesture.c b/source/blender/windowmanager/intern/wm_gesture.c index 74dd9914c30..da490f793bb 100644 --- a/source/blender/windowmanager/intern/wm_gesture.c +++ b/source/blender/windowmanager/intern/wm_gesture.c @@ -400,6 +400,16 @@ static void wm_gesture_draw_lasso(wmWindow *win, wmGesture *gt, bool filled) draw_filled_lasso(win, gt); } + numverts = gt->points; + if (gt->type == WM_GESTURE_LASSO) { + numverts++; + } + + /* Nothing to drawe, do early output. */ + if(numverts < 2) { + return; + } + VertexFormat* format = immVertexFormat(); unsigned pos = add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT); unsigned line_origin = add_attrib(format, "line_origin", COMP_F32, 2, KEEP_FLOAT); @@ -415,11 +425,6 @@ static void wm_gesture_draw_lasso(wmWindow *win, wmGesture *gt, bool filled) immUniform1f("dash_width", 2.0f); immUniform1f("dash_width_on", 1.0f); - numverts = gt->points; - if (gt->type == WM_GESTURE_LASSO) { - numverts++; - } - immBegin(PRIM_LINE_STRIP, numverts); for (i = 0; i < gt->points; i++, lasso += 2) { @@ -441,7 +446,7 @@ static void wm_gesture_draw_lasso(wmWindow *win, wmGesture *gt, bool filled) } immEnd(); - + immUnbindProgram(); } -- cgit v1.2.3