[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [30871] branches/soc-2010-jwilkins/source/ blender: * f-key for on surface brush now uses the same overlay for fixed mode so that the texture is consistent with the on surface brush

Jason Wilkins Jason.A.Wilkins at gmail.com
Thu Jul 29 10:08:35 CEST 2010


Revision: 30871
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=30871
Author:   jwilkins
Date:     2010-07-29 10:08:34 +0200 (Thu, 29 Jul 2010)

Log Message:
-----------
* f-key for on surface brush now uses the same overlay for fixed mode so that the texture is consistent with the on surface brush
* tiled overlay now disappears when sculpting
* transparency of brush doubles when sculpting

Modified Paths:
--------------
    branches/soc-2010-jwilkins/source/blender/editors/include/ED_sculpt.h
    branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/paint_stroke.c
    branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/sculpt.c
    branches/soc-2010-jwilkins/source/blender/windowmanager/intern/wm_operators.c

Modified: branches/soc-2010-jwilkins/source/blender/editors/include/ED_sculpt.h
===================================================================
--- branches/soc-2010-jwilkins/source/blender/editors/include/ED_sculpt.h	2010-07-29 07:29:31 UTC (rev 30870)
+++ branches/soc-2010-jwilkins/source/blender/editors/include/ED_sculpt.h	2010-07-29 08:08:34 UTC (rev 30871)
@@ -54,5 +54,6 @@
 
 void ED_draw_paint_overlay(const struct bContext *C, struct ARegion *ar);
 void ED_draw_on_surface_cursor(float modelview[16], float projection[16], float col[3], float alpha, float size[3], int viewport[4], float location[3], float inner_radius, float outer_radius, int brush_size);
+void ED_draw_fixed_overlay_on_surface(float modelview[16], float projection[16], float size[3], int viewport[4], float location[3], float outer_radius, struct Sculpt *sd, struct Brush *brush, struct ViewContext *vc, float t, float b, float l, float r, float angle);
 
 #endif

Modified: branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/paint_stroke.c
===================================================================
--- branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/paint_stroke.c	2010-07-29 07:29:31 UTC (rev 30870)
+++ branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/paint_stroke.c	2010-07-29 08:08:34 UTC (rev 30871)
@@ -226,7 +226,7 @@
 		    mtex->size[0] == snap->size[0] &&
 		    mtex->size[1] == snap->size[1] &&
 		    mtex->size[2] == snap->size[2] &&
-		    mtex->rot == snap->rot) &&
+		    (mtex->brush_map_mode == MTEX_MAP_MODE_FIXED || mtex->rot == snap->rot)) && // rotation does not cause fixed texture to be regenerated
 		((mtex->brush_map_mode == MTEX_MAP_MODE_FIXED && brush_size(brush) <= snap->brush_size) || (brush_size(brush) == snap->brush_size)) && // make brush smaller shouldn't cause a resample
 		mtex->brush_map_mode == snap->brush_map_mode &&
 		ar->winx == snap->winx &&
@@ -268,8 +268,6 @@
 	int j;
 	int refresh;
 
-	//if (sd->sculpting) return 0;
-
 	if (br->mtex.brush_map_mode == MTEX_MAP_MODE_WRAP) return 0; // XXX wrap mode doesn't support overlays atm
 
 	if (br->mtex.brush_map_mode == MTEX_MAP_MODE_TILED && !br->mtex.tex) return 0;
@@ -360,8 +358,11 @@
 					/* it is probably worth optimizing for those cases where 
 					   the texture is not rotated by skipping the calls to
 					   atan2, sqrtf, sin, and cos. */
-					if (br->mtex.tex && (rotation > 0.001 || rotation < -0.001)) {
-						const float angle    = atan2(y, x) + rotation;
+					if ((br->mtex.brush_map_mode == MTEX_MAP_MODE_TILED) &&
+						 br->mtex.tex &&
+						 (rotation > 0.001 || rotation < -0.001))
+					{
+						const float angle= atan2(y, x) + rotation;
 
 						x = len * cos(angle);
 						y = len * sin(angle);
@@ -432,7 +433,8 @@
 	Brush  *brush = paint_brush(paint);
 	Sculpt *sd    = CTX_data_tool_settings(C)->sculpt;
 
-	if (brush &&
+	if (!sd->sculpting &&
+		brush &&
 		brush->mtex.brush_map_mode == MTEX_MAP_MODE_TILED &&
 		brush->flag & BRUSH_TEXTURE_OVERLAY)
 	{
@@ -695,10 +697,8 @@
 	glPopAttrib();
 }
 
-static void draw_fixed_overlay(Sculpt *sd, Brush *brush, ViewContext *vc, float x, float y)
+static void draw_fixed_overlay(Sculpt *sd, Brush *brush, ViewContext *vc, float t, float b, float l, float r, float angle)
 {
-	const int size = brush_size(brush);
-
 	glPushAttrib(
 		GL_COLOR_BUFFER_BIT|
 		GL_CURRENT_BIT|
@@ -729,14 +729,7 @@
 		if (brush->mtex.brush_map_mode == MTEX_MAP_MODE_FIXED) {
 			glTranslatef(0.5f, 0.5f, 0);
 
-			if (brush->flag & BRUSH_RAKE) {
-				//glRotatef((brush->mtex.rot+sd->last_angle)*(float)(180.0/M_PI), 0, 0, 1);
-				glRotatef(sd->last_angle*(float)(180.0/M_PI), 0, 0, 1);
-			}
-			else {
-				//glRotatef((brush->mtex.rot+sd->special_rotation)*(float)(180.0/M_PI), 0, 0, 1);
-				glRotatef(sd->special_rotation*(float)(180.0/M_PI), 0, 0, 1);
-			}
+			glRotatef(angle, 0, 0, 1);
 
 			glTranslatef(-0.5f, -0.5f, 0);
 
@@ -754,32 +747,17 @@
 			brush->texture_overlay_alpha / 100.0f);
 
 		glBegin(GL_QUADS);
-		if (sd->draw_anchored) {
 			glTexCoord2f(0, 0);
-			glVertex2f(sd->anchored_initial_mouse[0]-sd->anchored_size - vc->ar->winrct.xmin, sd->anchored_initial_mouse[1]-sd->anchored_size - vc->ar->winrct.ymin);
+			glVertex2f(l, b);
 
 			glTexCoord2f(1, 0);
-			glVertex2f(sd->anchored_initial_mouse[0]+sd->anchored_size - vc->ar->winrct.xmin, sd->anchored_initial_mouse[1]-sd->anchored_size - vc->ar->winrct.ymin);
+			glVertex2f(r, b);
 
 			glTexCoord2f(1, 1);
-			glVertex2f(sd->anchored_initial_mouse[0]+sd->anchored_size - vc->ar->winrct.xmin, sd->anchored_initial_mouse[1]+sd->anchored_size - vc->ar->winrct.ymin);
+			glVertex2f(r, t);
 
 			glTexCoord2f(0, 1);
-			glVertex2f(sd->anchored_initial_mouse[0]-sd->anchored_size - vc->ar->winrct.xmin, sd->anchored_initial_mouse[1]+sd->anchored_size - vc->ar->winrct.ymin);
-		}
-		else {
-			glTexCoord2f(0, 0);
-			glVertex2f((float)x-size, (float)y-size);
-
-			glTexCoord2f(1, 0);
-			glVertex2f((float)x+size, (float)y-size);
-
-			glTexCoord2f(1, 1);
-			glVertex2f((float)x+size, (float)y+size);
-
-			glTexCoord2f(0, 1);
-			glVertex2f((float)x-size, (float)y+size);
-		}
+			glVertex2f(l, t);
 		glEnd();
 
 		glPopMatrix();
@@ -871,7 +849,7 @@
 	glPopAttrib();
 }
 
-static void stencil_surface(float modelview[16], float projection[16], float size[3], int viewport[4], float location[3], float outer_radius, Sculpt *sd, Brush *brush, ViewContext *vc, float x, float y)
+void ED_draw_fixed_overlay_on_surface(float modelview[16], float projection[16], float size[3], int viewport[4], float location[3], float outer_radius, Sculpt *sd, Brush *brush, ViewContext *vc, float t, float b, float l, float r, float angle)
 {
 	GLUquadric* sphere;
 
@@ -937,7 +915,7 @@
 	glStencilFunc(GL_EQUAL, 2, 0xFF);
 	glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
 
-	draw_fixed_overlay(sd, brush, vc, x, y);
+	draw_fixed_overlay(sd, brush, vc, t, b, l, r, angle);
 
 	glPopAttrib();
 }
@@ -975,9 +953,11 @@
 		const float root_alpha = brush_alpha(brush);
 		float visual_strength = root_alpha*root_alpha;
 
-		const float min_alpha = 0.20f;
-		const float max_alpha = 0.80f;
+		const float min_alpha = sd->sculpting ? 0.10f : 0.20f;
+		const float max_alpha = sd->sculpting ? 0.40f : 0.80f;
 
+		float t, b, l, r, angle;
+
 		{
 			const float u = 0.5f;
 			const float v = 1 - u;
@@ -1014,11 +994,34 @@
 
 		alpha = (paint->flags & PAINT_SHOW_BRUSH_ON_SURFACE) ? min_alpha + (visual_strength*(max_alpha-min_alpha)) : 0.50f;
 
+		if (sd->draw_anchored) {
+			l = sd->anchored_initial_mouse[0]-sd->anchored_size - vc.ar->winrct.xmin;
+			b = sd->anchored_initial_mouse[1]-sd->anchored_size - vc.ar->winrct.ymin;
+			r = sd->anchored_initial_mouse[0]+sd->anchored_size - vc.ar->winrct.xmin;
+			t = sd->anchored_initial_mouse[1]+sd->anchored_size - vc.ar->winrct.ymin;
+		}
+		else {
+			const int size= brush_size(brush);
+			l= (float)x-size;
+			b= (float)y-size;
+			r= (float)x+size;
+			t= (float)y+size;
+		}
+
+		if (brush->flag & BRUSH_RAKE) {
+			angle= sd->last_angle*(float)(180.0/M_PI);
+		}
+		else {
+			angle= sd->special_rotation*(float)(180.0/M_PI);
+		}
+
+		angle -= brush->mtex.rot*(float)(180.0/M_PI);
+
 		if ((!hit || !(paint->flags & PAINT_SHOW_BRUSH_ON_SURFACE)) &&
 			brush->mtex.brush_map_mode == MTEX_MAP_MODE_FIXED &&
 			brush->flag & BRUSH_TEXTURE_OVERLAY)
 		{
-			draw_fixed_overlay(sd, brush, &vc, x, y);
+			draw_fixed_overlay(sd, brush, &vc, t, b, l, r, angle);
 		}
 
 		if (hit) {
@@ -1064,7 +1067,7 @@
 				if (brush->mtex.brush_map_mode == MTEX_MAP_MODE_FIXED &&
 					brush->flag & BRUSH_TEXTURE_OVERLAY)
 				{
-					stencil_surface(modelview, projection, ob->size, viewport, location, outer_radius, sd, brush, &vc, x, y);
+					ED_draw_fixed_overlay_on_surface(modelview, projection, ob->size, viewport, location, outer_radius, sd, brush, &vc, t, b, l, r, angle);
 				}
 
 				ED_draw_on_surface_cursor(modelview, projection, col, alpha, ob->size, viewport, location, inner_radius, outer_radius, brush_size(brush));

Modified: branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/sculpt.c
===================================================================
--- branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/sculpt.c	2010-07-29 07:29:31 UTC (rev 30870)
+++ branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/sculpt.c	2010-07-29 08:08:34 UTC (rev 30871)
@@ -3606,6 +3606,9 @@
 #endif
 		sd->sculpting= 1;
 
+		// redraw full screen at beginning of stroke so overlay can be erased
+		WM_main_add_notifier(NC_SPACE|ND_SPACE_VIEW3D, NULL);
+
 		return 1;
 	}
 	else

Modified: branches/soc-2010-jwilkins/source/blender/windowmanager/intern/wm_operators.c
===================================================================
--- branches/soc-2010-jwilkins/source/blender/windowmanager/intern/wm_operators.c	2010-07-29 07:29:31 UTC (rev 30870)
+++ branches/soc-2010-jwilkins/source/blender/windowmanager/intern/wm_operators.c	2010-07-29 08:08:34 UTC (rev 30871)
@@ -2725,46 +2725,6 @@
 		if (hit) {
 			Object *ob= CTX_data_active_object(C);
 
-			glTranslatef((float)x, (float)y, 0.0f);
-
-			glEnable(GL_BLEND);
-
-			if(rc->mode == WM_RADIALCONTROL_ANGLE) {
-				glRotatef(angle, 0, 0, 1);
-			}
-
-			if (rc->tex) {
-				glBindTexture(GL_TEXTURE_2D, rc->tex);
-
-				glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
-				glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-
-				glEnable(GL_TEXTURE_2D);
-				glBegin(GL_QUADS);
-				glColor4f(U.sculpt_paint_overlay_col[0],U.sculpt_paint_overlay_col[1],U.sculpt_paint_overlay_col[2], str);
-				glTexCoord2f(0,0);
-				glVertex2f(-r3, -r3);
-				glTexCoord2f(1,0);
-				glVertex2f(r3, -r3);
-				glTexCoord2f(1,1);
-				glVertex2f(r3, r3);
-				glTexCoord2f(0,1);
-				glVertex2f(-r3, r3);
-				glEnd();
-				glDisable(GL_TEXTURE_2D);
-			}
-
-			if(rc->mode == WM_RADIALCONTROL_ANGLE) {
-				glColor4f(col[0], col[1], col[2], 0.5f);
-				glEnable(GL_LINE_SMOOTH);
-				glRotatef(-angle, 0, 0, 1);
-				fdrawline(0, 0, WM_RADIAL_CONTROL_DISPLAY_SIZE, 0);
-				glRotatef(angle, 0, 0, 1);
-				glDisable(GL_LINE_SMOOTH);
-			}
-
-			glDisable(GL_BLEND);
-
 			{
 				const float unprojected_radius= unproject_brush_radius(CTX_data_active_object(C), &vc, location, r1);
 				const float max_thickness= 0.12;
@@ -2773,7 +2733,22 @@
 				const float inner_radius=  unprojected_radius*thickness;
 				const float outer_radius=  unprojected_radius;
 

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list