[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [34163] trunk/blender/source/blender/ editors/sculpt_paint: Paint/Sculpt:

Nicholas Bishop nicholasbishop at gmail.com
Fri Jan 7 23:03:17 CET 2011


Revision: 34163
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=34163
Author:   nicholasbishop
Date:     2011-01-07 22:03:16 +0000 (Fri, 07 Jan 2011)
Log Message:
-----------
Paint/Sculpt:

Some minor cleanups: removed `#if 0' code and moved a function into paint_util to avoid `extern' declaration.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/sculpt_paint/paint_intern.h
    trunk/blender/source/blender/editors/sculpt_paint/paint_stroke.c
    trunk/blender/source/blender/editors/sculpt_paint/paint_utils.c
    trunk/blender/source/blender/editors/sculpt_paint/sculpt.c

Modified: trunk/blender/source/blender/editors/sculpt_paint/paint_intern.h
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/paint_intern.h	2011-01-07 21:12:47 UTC (rev 34162)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_intern.h	2011-01-07 22:03:16 UTC (rev 34163)
@@ -29,19 +29,20 @@
 #ifndef ED_PAINT_INTERN_H
 #define ED_PAINT_INTERN_H
 
+struct ARegion;
 struct bContext;
-struct Scene;
+struct Brush;
+struct ListBase;
+struct Mesh;
 struct Object;
-struct Mesh;
 struct PaintStroke;
 struct PointerRNA;
+struct Scene;
+struct VPaint;
 struct ViewContext;
 struct wmEvent;
 struct wmOperator;
 struct wmOperatorType;
-struct ARegion;
-struct VPaint;
-struct ListBase;
 
 /* paint_stroke.c */
 typedef int (*StrokeGetLocation)(struct bContext *C, struct PaintStroke *stroke, float location[3], float mouse[2]);
@@ -98,6 +99,7 @@
 
 
 /* paint_utils.c */
+float paint_get_tex_pixel(struct Brush* br, float u, float v);
 int imapaint_pick_face(struct ViewContext *vc, struct Mesh *me, int *mval, unsigned int *index);
 void imapaint_pick_uv(struct Scene *scene, struct Object *ob, unsigned int faceindex, int *xy, float *uv);
 

Modified: trunk/blender/source/blender/editors/sculpt_paint/paint_stroke.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/paint_stroke.c	2011-01-07 21:12:47 UTC (rev 34162)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_stroke.c	2011-01-07 22:03:16 UTC (rev 34163)
@@ -100,109 +100,6 @@
 	glDisable(GL_LINE_SMOOTH);
 }
 
-#if 0
-
-// grid texture for testing
-
-#define GRID_WIDTH   8
-#define GRID_LENGTH  8
-
-#define W (0xFFFFFFFF)
-#define G (0x00888888)
-#define E (0xE1E1E1E1)
-#define C (0xC3C3C3C3)
-#define O (0xB4B4B4B4)
-#define Q (0xA9A9A9A9)
-
-static unsigned grid_texture0[256] =
-{
-   W,W,W,W,W,W,W,W,W,W,W,W,W,W,W,W,
-   W,G,G,G,G,G,G,G,G,G,G,G,G,G,G,W,
-   W,G,G,G,G,G,G,G,G,G,G,G,G,G,G,W,
-   W,G,G,G,G,G,G,G,G,G,G,G,G,G,G,W,
-   W,G,G,G,G,G,G,G,G,G,G,G,G,G,G,W,
-   W,G,G,G,G,G,G,G,G,G,G,G,G,G,G,W,
-   W,G,G,G,G,G,G,G,G,G,G,G,G,G,G,W,
-   W,G,G,G,G,G,G,G,G,G,G,G,G,G,G,W,
-   W,G,G,G,G,G,G,G,G,G,G,G,G,G,G,W,
-   W,G,G,G,G,G,G,G,G,G,G,G,G,G,G,W,
-   W,G,G,G,G,G,G,G,G,G,G,G,G,G,G,W,
-   W,G,G,G,G,G,G,G,G,G,G,G,G,G,G,W,
-   W,G,G,G,G,G,G,G,G,G,G,G,G,G,G,W,
-   W,G,G,G,G,G,G,G,G,G,G,G,G,G,G,W,
-   W,G,G,G,G,G,G,G,G,G,G,G,G,G,G,W,
-   W,W,W,W,W,W,W,W,W,W,W,W,W,W,W,W,
-};
-
-static unsigned grid_texture1[64] =
-{
-   C,C,C,C,C,C,C,C,
-   C,G,G,G,G,G,G,C,
-   C,G,G,G,G,G,G,C,
-   C,G,G,G,G,G,G,C,
-   C,G,G,G,G,G,G,C,
-   C,G,G,G,G,G,G,C,
-   C,G,G,G,G,G,G,C,
-   C,C,C,C,C,C,C,C,
-};
-
-static unsigned grid_texture2[16] =
-{
-   O,O,O,O,
-   O,G,G,O,
-   O,G,G,O,
-   O,O,O,O,
-};
-
-static unsigned grid_texture3[4] =
-{
-   Q,Q,
-   Q,Q,
-};
-
-static unsigned grid_texture4[1] =
-{
-   Q,
-};
-
-#undef W
-#undef G
-#undef E
-#undef C
-#undef O
-#undef Q
-
-static void load_grid()
-{
-	static GLuint overlay_texture;
-
-	if (!overlay_texture) {
-		//GLfloat largest_supported_anisotropy;
-
-		glGenTextures(1, &overlay_texture);
-		glBindTexture(GL_TEXTURE_2D, overlay_texture);
-		glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, grid_texture0);
-		glTexImage2D(GL_TEXTURE_2D, 1, GL_RGB,  8,  8, 0, GL_RGBA, GL_UNSIGNED_BYTE, grid_texture1);
-		glTexImage2D(GL_TEXTURE_2D, 2, GL_RGB,  4,  4, 0, GL_RGBA, GL_UNSIGNED_BYTE, grid_texture2);
-		glTexImage2D(GL_TEXTURE_2D, 3, GL_RGB,  2,  2, 0, GL_RGBA, GL_UNSIGNED_BYTE, grid_texture3);
-		glTexImage2D(GL_TEXTURE_2D, 4, GL_RGB,  1,  1, 0, GL_RGBA, GL_UNSIGNED_BYTE, grid_texture4);
-		glEnable(GL_TEXTURE_2D);
-		glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
-		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
-		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR);
-
-		//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
-		//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
-
-		//glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &largest_supported_anisotropy);
-		//glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, largest_supported_anisotropy);
-	}
-}
-
-#endif
-
-extern float get_tex_pixel(Brush* br, float u, float v);
-
 typedef struct Snapshot {
 	float size[3];
 	float ofs[3];
@@ -373,7 +270,7 @@
 					x += br->mtex.ofs[0];
 					y += br->mtex.ofs[1];
 
-					avg = br->mtex.tex ? get_tex_pixel(br, x, y) : 1;
+					avg = br->mtex.tex ? paint_get_tex_pixel(br, x, y) : 1;
 
 					avg += br->texture_sample_bias;
 

Modified: trunk/blender/source/blender/editors/sculpt_paint/paint_utils.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/paint_utils.c	2011-01-07 21:12:47 UTC (rev 34162)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_utils.c	2011-01-07 22:03:16 UTC (rev 34163)
@@ -22,6 +22,8 @@
 
 #include "BIF_gl.h"
 
+#include "RE_shader_ext.h"
+
 #include "ED_view3d.h"
 #include "ED_screen.h"
 
@@ -33,6 +35,25 @@
 
 #include "paint_intern.h"
 
+float paint_get_tex_pixel(Brush* br, float u, float v)
+{
+	TexResult texres;
+	float co[3];
+	int hasrgb;
+
+	co[0] = u;
+	co[1] = v;
+	co[2] = 0;
+
+	memset(&texres, 0, sizeof(TexResult));
+	hasrgb = multitex_ext(br->mtex.tex, co, NULL, NULL, 1, &texres);
+
+	if (hasrgb & TEX_RGB)
+		texres.tin = (0.35*texres.tr + 0.45*texres.tg + 0.2*texres.tb)*texres.ta;
+
+	return texres.tin;
+}
+
 /* 3D Paint */
 
 static void imapaint_project(Object *ob, float *model, float *proj, float *co, float *pco)

Modified: trunk/blender/source/blender/editors/sculpt_paint/sculpt.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/sculpt.c	2011-01-07 21:12:47 UTC (rev 34162)
+++ trunk/blender/source/blender/editors/sculpt_paint/sculpt.c	2011-01-07 22:03:16 UTC (rev 34163)
@@ -72,9 +72,7 @@
 #include "RNA_access.h"
 #include "RNA_define.h"
 
-
 #include "RE_render_ext.h"
-#include "RE_shader_ext.h"
 
 #include "GPU_buffers.h"
 
@@ -649,66 +647,6 @@
 	}
 }
 
-float get_tex_pixel(Brush* br, float u, float v)
-{
-	TexResult texres;
-	float co[3];
-	int hasrgb;
-
-	co[0] = u;
-	co[1] = v;
-	co[2] = 0;
-
-	memset(&texres, 0, sizeof(TexResult));
-	hasrgb = multitex_ext(br->mtex.tex, co, NULL, NULL, 1, &texres);
-
-	if (hasrgb & TEX_RGB)
-		texres.tin = (0.35*texres.tr + 0.45*texres.tg + 0.2*texres.tb)*texres.ta;
-
-	return texres.tin;
-}
-
-#if 0
-
-/* Get a pixel from the texcache at (px, py) */
-static unsigned char get_texcache_pixel(const SculptSession *ss, int px, int py)
-{
-	unsigned *p;
-	p = ss->texcache + py * ss->texcache_side + px;
-	return ((unsigned char*)(p))[0];
-}
-
-static float get_texcache_pixel_bilinear(const SculptSession *ss, float u, float v)
-{
-	unsigned x, y, x2, y2;
-	const int tc_max = ss->texcache_side - 1;
-	float urat, vrat, uopp;
-
-	if(u < 0) u = 0;
-	else if(u >= ss->texcache_side) u = tc_max;
-	if(v < 0) v = 0;
-	else if(v >= ss->texcache_side) v = tc_max;
-
-	x = floor(u);
-	y = floor(v);
-	x2 = x + 1;
-	y2 = y + 1;
-
-	if(x2 > ss->texcache_side) x2 = tc_max;
-	if(y2 > ss->texcache_side) y2 = tc_max;
-	
-	urat = u - x;
-	vrat = v - y;
-	uopp = 1 - urat;
-		
-	return ((get_texcache_pixel(ss, x, y) * uopp +
-		 get_texcache_pixel(ss, x2, y) * urat) * (1 - vrat) + 
-		(get_texcache_pixel(ss, x, y2) * uopp +
-		 get_texcache_pixel(ss, x2, y2) * urat) * vrat) / 255.0;
-}
-
-#endif
-
 /* Return a multiplier for brush strength on a particular vertex. */
 static float tex_strength(SculptSession *ss, Brush *br, float *point, const float len)
 {
@@ -792,7 +730,7 @@
 		x += br->mtex.ofs[0];
 		y += br->mtex.ofs[1];
 
-		avg = get_tex_pixel(br, x, y);
+		avg = paint_get_tex_pixel(br, x, y);
 	}
 
 	avg += br->texture_sample_bias;




More information about the Bf-blender-cvs mailing list