[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [60163] trunk/blender/source/blender/ editors/sculpt_paint/paint_cursor.c: Fix issue with paint cursor overlay and size pressure drawing, it would

Antony Riakiotakis kalast at gmail.com
Mon Sep 16 15:03:28 CEST 2013


Revision: 60163
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=60163
Author:   psy-fi
Date:     2013-09-16 13:03:28 +0000 (Mon, 16 Sep 2013)
Log Message:
-----------
Fix issue with paint cursor overlay and size pressure drawing, it would
draw incorrectly and leave openGL in an inconsistent state, making for a
quite surreal UI. Reported by Sebastian Koenig thanks!

Modified Paths:
--------------
    trunk/blender/source/blender/editors/sculpt_paint/paint_cursor.c

Modified: trunk/blender/source/blender/editors/sculpt_paint/paint_cursor.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/paint_cursor.c	2013-09-16 13:02:49 UTC (rev 60162)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_cursor.c	2013-09-16 13:03:28 UTC (rev 60163)
@@ -643,21 +643,17 @@
 	}
 
 	if (load_tex_cursor(brush, vc, zoom)) {
+		bool do_pop = false;
+		float center[2];
 		glEnable(GL_BLEND);
 
 		glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
 		glDepthMask(GL_FALSE);
 		glDepthFunc(GL_ALWAYS);
 
-		/* scale based on tablet pressure */
-		if (ups->draw_pressure && BKE_brush_use_size_pressure(vc->scene, brush)) {
-			glTranslatef(0.5f, 0.5f, 0);
-			glScalef(1.0f / ups->pressure_value, 1.0f / ups->pressure_value, 1);
-			glTranslatef(-0.5f, -0.5f, 0);
-		}
-
 		if (ups->draw_anchored) {
 			const float *aim = ups->anchored_initial_mouse;
+			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;
@@ -665,12 +661,25 @@
 		}
 		else {
 			const int radius = BKE_brush_size_get(vc->scene, brush) * zoom;
+			center[0] = x;
+			center[1] = y;
+
 			quad.xmin = x - radius;
 			quad.ymin = y - radius;
 			quad.xmax = x + radius;
 			quad.ymax = y + radius;
 		}
 
+		/* scale based on tablet pressure */
+		if (ups->draw_pressure && BKE_brush_use_size_pressure(vc->scene, brush)) {
+			do_pop = true;
+			glPushMatrix();
+			glLoadIdentity();
+			glTranslatef(center[0], center[1], 0);
+			glScalef(ups->pressure_value, ups->pressure_value, 1);
+			glTranslatef(-center[0], -center[1], 0);
+		}
+
 		glColor4f(U.sculpt_paint_overlay_col[0],
 		        U.sculpt_paint_overlay_col[1],
 		        U.sculpt_paint_overlay_col[2],
@@ -687,6 +696,9 @@
 		glTexCoord2f(0, 1);
 		glVertex2f(quad.xmin, quad.ymax);
 		glEnd();
+
+		if (do_pop)
+			glPopMatrix();
 	}
 }
 




More information about the Bf-blender-cvs mailing list