[Bf-blender-cvs] [38e08ec66bb] blender2.8: Fix T56012: brush stencil overlay draws in the wrong location.

Brecht Van Lommel noreply at git.blender.org
Wed Aug 15 17:23:18 CEST 2018


Commit: 38e08ec66bb4d05d530cc57f1a9a7c79470000b0
Author: Brecht Van Lommel
Date:   Wed Aug 15 17:16:21 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB38e08ec66bb4d05d530cc57f1a9a7c79470000b0

Fix T56012: brush stencil overlay draws in the wrong location.

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

M	source/blender/editors/sculpt_paint/paint_cursor.c
M	source/blender/windowmanager/intern/wm_draw.c

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

diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c
index 997fe1282f9..36568632ffa 100644
--- a/source/blender/editors/sculpt_paint/paint_cursor.c
+++ b/source/blender/editors/sculpt_paint/paint_cursor.c
@@ -634,14 +634,10 @@ static void paint_draw_tex_overlay(
 			}
 
 			if (ups->draw_anchored) {
-				float aim[2] = {
-				    ups->anchored_initial_mouse[0] + vc->ar->winrct.xmin,
-				    ups->anchored_initial_mouse[1] + vc->ar->winrct.ymin,
-				};
-				quad.xmin = aim[0] - ups->anchored_size;
-				quad.ymin = aim[1] - ups->anchored_size;
-				quad.xmax = aim[0] + ups->anchored_size;
-				quad.ymax = aim[1] + ups->anchored_size;
+				quad.xmin = ups->anchored_initial_mouse[0] - ups->anchored_size;
+				quad.ymin = ups->anchored_initial_mouse[1] - ups->anchored_size;
+				quad.xmax = ups->anchored_initial_mouse[0] + ups->anchored_size;
+				quad.ymax = ups->anchored_initial_mouse[1] + ups->anchored_size;
 			}
 			else {
 				const int radius = BKE_brush_size_get(vc->scene, brush) * zoom;
@@ -738,15 +734,11 @@ static void paint_draw_cursor_overlay(
 		glDepthFunc(GL_ALWAYS);
 
 		if (ups->draw_anchored) {
-			float aim[2] = {
-			    ups->anchored_initial_mouse[0] + vc->ar->winrct.xmin,
-			    ups->anchored_initial_mouse[1] + vc->ar->winrct.ymin,
-			};
-			copy_v2_v2(center, aim);
-			quad.xmin = aim[0] - ups->anchored_size;
-			quad.ymin = aim[1] - ups->anchored_size;
-			quad.xmax = aim[0] + ups->anchored_size;
-			quad.ymax = aim[1] + ups->anchored_size;
+			copy_v2_v2(center, ups->anchored_initial_mouse);
+			quad.xmin = ups->anchored_initial_mouse[0] - ups->anchored_size;
+			quad.ymin = ups->anchored_initial_mouse[1] - ups->anchored_size;
+			quad.xmax = ups->anchored_initial_mouse[0] + ups->anchored_size;
+			quad.ymax = ups->anchored_initial_mouse[1] + ups->anchored_size;
 		}
 		else {
 			const int radius = BKE_brush_size_get(vc->scene, brush) * zoom;
@@ -763,7 +755,6 @@ static void paint_draw_cursor_overlay(
 		if (ups->stroke_active && BKE_brush_use_size_pressure(vc->scene, brush)) {
 			do_pop = true;
 			GPU_matrix_push();
-			GPU_matrix_identity_set();
 			GPU_matrix_translate_2fv(center);
 			GPU_matrix_scale_1f(ups->size_pressure_value);
 			GPU_matrix_translate_2f(-center[0], -center[1]);
@@ -809,6 +800,12 @@ static void paint_draw_alpha_overlay(
 	eOverlayControlFlags flags = BKE_paint_get_overlay_flags();
 	gpuPushAttrib(GPU_DEPTH_BUFFER_BIT | GPU_BLEND_BIT);
 
+	/* Translate to region. */
+	GPU_matrix_push();
+	GPU_matrix_translate_2f(vc->ar->winrct.xmin, vc->ar->winrct.ymin);
+	x -= vc->ar->winrct.xmin;
+	y -= vc->ar->winrct.ymin;
+
 	/* coloured overlay should be drawn separately */
 	if (col) {
 		if (!(flags & PAINT_OVERLAY_OVERRIDE_PRIMARY))
@@ -825,6 +822,7 @@ static void paint_draw_alpha_overlay(
 			paint_draw_cursor_overlay(ups, brush, vc, x, y, zoom);
 	}
 
+	GPU_matrix_pop();
 	gpuPopAttrib();
 }
 
diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c
index 160aeb6671b..c869ec90469 100644
--- a/source/blender/windowmanager/intern/wm_draw.c
+++ b/source/blender/windowmanager/intern/wm_draw.c
@@ -96,8 +96,7 @@ static void wm_paintcursor_draw(bContext *C, ARegion *ar)
 		for (pc = wm->paintcursors.first; pc; pc = pc->next) {
 			if (pc->poll == NULL || pc->poll(C)) {
 				/* Prevent drawing outside region. */
-				GLint scissor[4];
-				glGetIntegerv(GL_SCISSOR_BOX, scissor);
+				glEnable(GL_SCISSOR_TEST);
 				glScissor(ar->winrct.xmin,
 				          ar->winrct.ymin,
 				          BLI_rcti_size_x(&ar->winrct) + 1,
@@ -112,7 +111,7 @@ static void wm_paintcursor_draw(bContext *C, ARegion *ar)
 					pc->draw(C, win->eventstate->x, win->eventstate->y, pc->customdata);
 				}
 
-				glScissor(scissor[0], scissor[1], scissor[2], scissor[3]);
+				glDisable(GL_SCISSOR_TEST);
 			}
 		}
 	}



More information about the Bf-blender-cvs mailing list