[Bf-blender-cvs] [fb2330c1e04] blender2.8: Use model view matrix instead of texture matrix for texture brush overlay

Sergey Sharybin noreply at git.blender.org
Wed Apr 19 14:25:14 CEST 2017


Commit: fb2330c1e0415cc8cf6fe8c0e7dd0e2712721c71
Author: Sergey Sharybin
Date:   Wed Apr 19 14:13:53 2017 +0200
Branches: blender2.8
https://developer.blender.org/rBfb2330c1e0415cc8cf6fe8c0e7dd0e2712721c71

Use model view matrix instead of texture matrix for texture brush overlay

It is required for our new matrix stack to only have projection and model view
matrix modes. This commit ports paint cursor overlay to model view matrix.

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

M	source/blender/editors/sculpt_paint/paint_cursor.c

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

diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c
index 4ea85b465e7..e8e376b8a69 100644
--- a/source/blender/editors/sculpt_paint/paint_cursor.c
+++ b/source/blender/editors/sculpt_paint/paint_cursor.c
@@ -605,21 +605,20 @@ static void paint_draw_tex_overlay(UnifiedPaintSettings *ups, Brush *brush,
 		glDepthMask(GL_FALSE);
 		glDepthFunc(GL_ALWAYS);
 
-		glMatrixMode(GL_TEXTURE);
-		glPushMatrix(); /* TEXTURE */
-		glLoadIdentity(); /* TEXTURE */
-
 		if (mtex->brush_map_mode == MTEX_MAP_MODE_VIEW) {
+			gpuPushMatrix();
+
 			/* brush rotation */
-			glTranslatef(0.5, 0.5, 0); /* TEXTURE */
-			glRotatef(RAD2DEGF(primary ? ups->brush_rotation : ups->brush_rotation_sec), 0, 0, 1);  /* TEXTURE */
-			glTranslatef(-0.5f, -0.5f, 0); /* TEXTURE */
+			gpuTranslate2f(x, y);
+			gpuRotate2D(-RAD2DEGF(primary ? ups->brush_rotation : ups->brush_rotation_sec));
+			gpuTranslate2f(-x, -y);
 
 			/* scale based on tablet pressure */
 			if (primary && ups->stroke_active && BKE_brush_use_size_pressure(vc->scene, brush)) {
-				glTranslatef(0.5f, 0.5f, 0); /* TEXTURE */
-				glScalef(1.0f / ups->size_pressure_value, 1.0f / ups->size_pressure_value, 1.0f / ups->size_pressure_value); /* TEXTURE */
-				glTranslatef(-0.5f, -0.5f, 0); /* TEXTURE */
+				const float scale = ups->size_pressure_value;
+				gpuTranslate2f(x, y);
+				gpuScale2f(scale, scale);
+				gpuTranslate2f(-x, -y);
 			}
 
 			if (ups->draw_anchored) {
@@ -657,14 +656,12 @@ static void paint_draw_tex_overlay(UnifiedPaintSettings *ups, Brush *brush,
 				quad.xmax = brush->mask_stencil_dimension[0];
 				quad.ymax = brush->mask_stencil_dimension[1];
 			}
-			glMatrixMode(GL_MODELVIEW);
 			gpuPushMatrix();
 			if (primary)
 				gpuTranslate2fv(brush->stencil_pos);
 			else
 				gpuTranslate2fv(brush->mask_stencil_pos);
 			gpuRotate2D(RAD2DEGF(mtex->rot));
-			glMatrixMode(GL_TEXTURE);
 		}
 
 		/* set quad color. Colored overlay does not get blending */
@@ -697,10 +694,7 @@ static void paint_draw_tex_overlay(UnifiedPaintSettings *ups, Brush *brush,
 
 		immUnbindProgram();
 
-		glPopMatrix(); /* TEXTURE */
-		glMatrixMode(GL_MODELVIEW);
-
-		if (mtex->brush_map_mode == MTEX_MAP_MODE_STENCIL) {
+		if (ELEM(mtex->brush_map_mode, MTEX_MAP_MODE_STENCIL, MTEX_MAP_MODE_VIEW)) {
 			gpuPopMatrix();
 		}
 	}




More information about the Bf-blender-cvs mailing list