[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [45227] trunk/blender/source/blender/ editors/sculpt_paint: style cleanup: mainly whitespace around operators and indentation - paint/sculpt tools

Campbell Barton ideasman42 at gmail.com
Wed Mar 28 05:47:50 CEST 2012


Revision: 45227
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=45227
Author:   campbellbarton
Date:     2012-03-28 03:47:33 +0000 (Wed, 28 Mar 2012)
Log Message:
-----------
style cleanup: mainly whitespace around operators and indentation - paint/sculpt tools

Modified Paths:
--------------
    trunk/blender/source/blender/editors/sculpt_paint/paint_cursor.c
    trunk/blender/source/blender/editors/sculpt_paint/paint_hide.c
    trunk/blender/source/blender/editors/sculpt_paint/paint_image.c
    trunk/blender/source/blender/editors/sculpt_paint/paint_ops.c
    trunk/blender/source/blender/editors/sculpt_paint/paint_stroke.c
    trunk/blender/source/blender/editors/sculpt_paint/paint_undo.c
    trunk/blender/source/blender/editors/sculpt_paint/paint_utils.c
    trunk/blender/source/blender/editors/sculpt_paint/paint_vertex.c
    trunk/blender/source/blender/editors/sculpt_paint/sculpt.c
    trunk/blender/source/blender/editors/sculpt_paint/sculpt_undo.c
    trunk/blender/source/blender/editors/sculpt_paint/sculpt_uv.c

Modified: trunk/blender/source/blender/editors/sculpt_paint/paint_cursor.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/paint_cursor.c	2012-03-28 03:17:22 UTC (rev 45226)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_cursor.c	2012-03-28 03:47:33 UTC (rev 45227)
@@ -76,26 +76,26 @@
 	int curve_changed_timestamp;
 } Snapshot;
 
-static int same_snap(Snapshot* snap, Brush* brush, ViewContext* vc)
+static int same_snap(Snapshot *snap, Brush *brush, ViewContext *vc)
 {
-	MTex* mtex = &brush->mtex;
+	MTex *mtex = &brush->mtex;
 
 	return (((mtex->tex) &&
-			 equals_v3v3(mtex->ofs, snap->ofs) &&
-			 equals_v3v3(mtex->size, snap->size) &&
-			 mtex->rot == snap->rot) &&
+	         equals_v3v3(mtex->ofs, snap->ofs) &&
+	         equals_v3v3(mtex->size, snap->size) &&
+	         mtex->rot == snap->rot) &&
 
-			/* make brush smaller shouldn't cause a resample */
-			((mtex->brush_map_mode == MTEX_MAP_MODE_FIXED &&
-			  (brush_size(vc->scene, brush) <= snap->brush_size)) ||
-			 (brush_size(vc->scene, brush) == snap->brush_size)) &&
+	        /* make brush smaller shouldn't cause a resample */
+	        ((mtex->brush_map_mode == MTEX_MAP_MODE_FIXED &&
+	          (brush_size(vc->scene, brush) <= snap->brush_size)) ||
+	         (brush_size(vc->scene, brush) == snap->brush_size)) &&
 
-			(mtex->brush_map_mode == snap->brush_map_mode) &&
-			(vc->ar->winx == snap->winx) &&
-			(vc->ar->winy == snap->winy));
+	        (mtex->brush_map_mode == snap->brush_map_mode) &&
+	        (vc->ar->winx == snap->winx) &&
+	        (vc->ar->winy == snap->winy));
 }
 
-static void make_snap(Snapshot* snap, Brush* brush, ViewContext* vc)
+static void make_snap(Snapshot *snap, Brush *brush, ViewContext *vc)
 {
 	if (brush->mtex.tex) {
 		snap->brush_map_mode = brush->mtex.brush_map_mode;
@@ -105,8 +105,8 @@
 	}
 	else {
 		snap->brush_map_mode = -1;
-		snap->ofs[0]= snap->ofs[1]= snap->ofs[2]= -1;
-		snap->size[0]= snap->size[1]= snap->size[2]= -1;
+		snap->ofs[0] = snap->ofs[1] = snap->ofs[2] = -1;
+		snap->size[0] = snap->size[1] = snap->size[2] = -1;
 		snap->rot = -1;
 	}
 
@@ -115,7 +115,7 @@
 	snap->winy = vc->ar->winy;
 }
 
-static int load_tex(Sculpt *sd, Brush* br, ViewContext* vc)
+static int load_tex(Sculpt *sd, Brush *br, ViewContext *vc)
 {
 	static GLuint overlay_texture = 0;
 	static int init = 0;
@@ -124,7 +124,7 @@
 	static Snapshot snap;
 	static int old_size = -1;
 
-	GLubyte* buffer = NULL;
+	GLubyte *buffer = NULL;
 
 	int size;
 	int j;
@@ -137,13 +137,13 @@
 	if (br->mtex.brush_map_mode == MTEX_MAP_MODE_TILED && !br->mtex.tex) return 0;
 	
 	refresh = 
-		!overlay_texture ||
-		(br->mtex.tex && 
-		    (!br->mtex.tex->preview ||
-		      br->mtex.tex->preview->changed_timestamp[0] != tex_changed_timestamp)) ||
-		!br->curve ||
-		br->curve->changed_timestamp != curve_changed_timestamp ||
-		!same_snap(&snap, br, vc);
+	    !overlay_texture ||
+	    (br->mtex.tex &&
+	     (!br->mtex.tex->preview ||
+	      br->mtex.tex->preview->changed_timestamp[0] != tex_changed_timestamp)) ||
+	    !br->curve ||
+	    br->curve->changed_timestamp != curve_changed_timestamp ||
+	    !same_snap(&snap, br, vc);
 
 	if (refresh) {
 		if (br->mtex.tex && br->mtex.tex->preview)
@@ -161,7 +161,7 @@
 			for (s >>= 1; s > 0; s >>= 1)
 				r++;
 
-			size = (1<<r);
+			size = (1 << r);
 
 			if (size < 256)
 				size = 256;
@@ -183,26 +183,26 @@
 			old_size = size;
 		}
 
-		buffer = MEM_mallocN(sizeof(GLubyte)*size*size, "load_tex");
+		buffer = MEM_mallocN(sizeof(GLubyte) * size * size, "load_tex");
 
 		#pragma omp parallel for schedule(static) if (sd->flags & SCULPT_USE_OPENMP)
-		for (j= 0; j < size; j++) {
+		for (j = 0; j < size; j++) {
 			int i;
 			float y;
 			float len;
 
-			for (i= 0; i < size; i++) {
+			for (i = 0; i < size; i++) {
 
 				// largely duplicated from tex_strength
 
 				const float rotation = -br->mtex.rot;
 				float radius = brush_size(vc->scene, br);
-				int index = j*size + i;
+				int index = j * size + i;
 				float x;
 				float avg;
 
-				x = (float)i/size;
-				y = (float)j/size;
+				x = (float)i / size;
+				y = (float)j / size;
 
 				x -= 0.5f;
 				y -= 0.5f;
@@ -216,7 +216,7 @@
 					y *= 2;
 				}
 
-				len = sqrtf(x*x + y*y);
+				len = sqrtf(x * x + y * y);
 
 				if ((br->mtex.brush_map_mode == MTEX_MAP_MODE_TILED) || len <= 1) {
 					/* it is probably worth optimizing for those cases where 
@@ -240,9 +240,9 @@
 					avg += br->texture_sample_bias;
 
 					if (br->mtex.brush_map_mode == MTEX_MAP_MODE_FIXED)
-						avg *= brush_curve_strength(br, len, 1); /* Falloff curve */
+						avg *= brush_curve_strength(br, len, 1);  /* Falloff curve */
 
-					buffer[index] = 255 - (GLubyte)(255*avg);
+					buffer[index] = 255 - (GLubyte)(255 * avg);
 				}
 				else {
 					buffer[index] = 0;
@@ -254,7 +254,7 @@
 			glGenTextures(1, &overlay_texture);
 	}
 	else {
-		size= old_size;
+		size = old_size;
 	}
 
 	glBindTexture(GL_TEXTURE_2D, overlay_texture);
@@ -287,8 +287,8 @@
 }
 
 static int project_brush_radius(ViewContext *vc,
-								float radius,
-								const float location[3])
+                                float radius,
+                                const float location[3])
 {
 	float view[3], nonortho[3], ortho[3], offset[3], p1[2], p2[2];
 
@@ -328,9 +328,9 @@
 	return len_v2v2(p1, p2);
 }
 
-static int sculpt_get_brush_geometry(bContext* C, ViewContext *vc,
-									 int x, int y, int* pixel_radius,
-									 float location[3])
+static int sculpt_get_brush_geometry(bContext *C, ViewContext *vc,
+                                     int x, int y, int *pixel_radius,
+                                     float location[3])
 {
 	Scene *scene = CTX_data_scene(C);
 	Paint *paint = paint_get_active(scene);
@@ -342,11 +342,11 @@
 	window[1] = y + vc->ar->winrct.ymin;
 
 	if (vc->obact->sculpt && vc->obact->sculpt->pbvh &&
-	   sculpt_stroke_get_location(C, location, window)) {
+	    sculpt_stroke_get_location(C, location, window)) {
 		*pixel_radius =
-			project_brush_radius(vc,
-								 brush_unprojected_radius(scene, brush),
-								 location);
+		    project_brush_radius(vc,
+		                         brush_unprojected_radius(scene, brush),
+		                         location);
 
 		if (*pixel_radius == 0)
 			*pixel_radius = brush_size(scene, brush);
@@ -356,8 +356,8 @@
 		hit = 1;
 	}
 	else {
-		Sculpt* sd    = CTX_data_tool_settings(C)->sculpt;
-		Brush*  brush = paint_brush(&sd->paint);
+		Sculpt *sd    = CTX_data_tool_settings(C)->sculpt;
+		Brush *brush = paint_brush(&sd->paint);
 
 		*pixel_radius = brush_size(scene, brush);
 		hit = 0;
@@ -370,26 +370,26 @@
  * have on brush strength */
 /* TODO: sculpt only for now */
 static void paint_draw_alpha_overlay(Sculpt *sd, Brush *brush,
-				     ViewContext *vc, int x, int y)
+                                     ViewContext *vc, int x, int y)
 {
 	rctf quad;
 
 	/* check for overlay mode */
 	if (!(brush->flag & BRUSH_TEXTURE_OVERLAY) ||
-	   !(ELEM(brush->mtex.brush_map_mode, MTEX_MAP_MODE_FIXED, MTEX_MAP_MODE_TILED)))
+	    !(ELEM(brush->mtex.brush_map_mode, MTEX_MAP_MODE_FIXED, MTEX_MAP_MODE_TILED)))
 		return;
 
 	/* save lots of GL state
 	 * TODO: check on whether all of these are needed? */
-	glPushAttrib(GL_COLOR_BUFFER_BIT|
-	             GL_CURRENT_BIT|
-	             GL_DEPTH_BUFFER_BIT|
-	             GL_ENABLE_BIT|
-	             GL_LINE_BIT|
-	             GL_POLYGON_BIT|
-	             GL_STENCIL_BUFFER_BIT|
-	             GL_TRANSFORM_BIT|
-	             GL_VIEWPORT_BIT|
+	glPushAttrib(GL_COLOR_BUFFER_BIT |
+	             GL_CURRENT_BIT |
+	             GL_DEPTH_BUFFER_BIT |
+	             GL_ENABLE_BIT |
+	             GL_LINE_BIT |
+	             GL_POLYGON_BIT |
+	             GL_STENCIL_BUFFER_BIT |
+	             GL_TRANSFORM_BIT |
+	             GL_VIEWPORT_BIT |
 	             GL_TEXTURE_BIT);
 
 	if (load_tex(sd, brush, vc)) {
@@ -408,26 +408,26 @@
 			glTranslatef(0.5, 0.5, 0);
 			glRotatef((double)RAD2DEGF((brush->flag & BRUSH_RAKE) ?
 			                           sd->last_angle : sd->special_rotation),
-			                           0.0, 0.0, 1.0);
+			          0.0, 0.0, 1.0);
 			glTranslatef(-0.5f, -0.5f, 0);
 
 			/* scale based on tablet pressure */
 			if (sd->draw_pressure && brush_use_size_pressure(vc->scene, brush)) {
 				glTranslatef(0.5f, 0.5f, 0);
-				glScalef(1.0f/sd->pressure_value, 1.0f/sd->pressure_value, 1);
+				glScalef(1.0f / sd->pressure_value, 1.0f / sd->pressure_value, 1);
 				glTranslatef(-0.5f, -0.5f, 0);
 			}
 
 			if (sd->draw_anchored) {
 				const float *aim = sd->anchored_initial_mouse;
 				const rcti *win = &vc->ar->winrct;
-				quad.xmin = aim[0]-sd->anchored_size - win->xmin;
-				quad.ymin = aim[1]-sd->anchored_size - win->ymin;
-				quad.xmax = aim[0]+sd->anchored_size - win->xmin;
-				quad.ymax = aim[1]+sd->anchored_size - win->ymin;
+				quad.xmin = aim[0] - sd->anchored_size - win->xmin;
+				quad.ymin = aim[1] - sd->anchored_size - win->ymin;
+				quad.xmax = aim[0] + sd->anchored_size - win->xmin;
+				quad.ymax = aim[1] + sd->anchored_size - win->ymin;
 			}
 			else {
-				const int radius= brush_size(vc->scene, brush);
+				const int radius = brush_size(vc->scene, brush);
 				quad.xmin = x - radius;
 				quad.ymin = y - radius;
 				quad.xmax = x + radius;
@@ -468,7 +468,7 @@
 /* Special actions taken when paint cursor goes over mesh */
 /* TODO: sculpt only for now */
 static void paint_cursor_on_hit(Sculpt *sd, Brush *brush, ViewContext *vc,
-								const float location[3])
+                                const float location[3])
 {
 	float unprojected_radius, projected_radius;
 
@@ -486,7 +486,7 @@
 	
 		/* convert brush radius from 2D to 3D */
 		unprojected_radius = paint_calc_object_space_radius(vc, location,
-															projected_radius);
+		                                                    projected_radius);
 
 		/* scale 3D brush radius by pressure */
 		if (sd->draw_pressure && brush_use_size_pressure(vc->scene, brush))
@@ -541,11 +541,11 @@
 			const float dx = sd->last_x - x;
 			const float dy = sd->last_y - y;
 
-			if (dx*dx + dy*dy >= r*r) {
+			if (dx * dx + dy * dy >= r * r) {
 				sd->last_angle = atan2(dx, dy);
 
-				sd->last_x = u*sd->last_x + v*x;
-				sd->last_y = u*sd->last_y + v*y;
+				sd->last_x = u * sd->last_x + v * x;
+				sd->last_y = u * sd->last_y + v * y;
 			}
 		}
 
@@ -562,10 +562,10 @@
 		/* TODO: no way currently to know state of pen flip or

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list