diff options
author | Nicholas Bishop <nicholasbishop@gmail.com> | 2011-01-08 01:03:16 +0300 |
---|---|---|
committer | Nicholas Bishop <nicholasbishop@gmail.com> | 2011-01-08 01:03:16 +0300 |
commit | ab41b9bbaf677fb807e73df137156a44c941295b (patch) | |
tree | 454dbba1df45b98dd18d06ec84eb593c990e0dd0 /source/blender/editors/sculpt_paint | |
parent | 473838aec99d81595def7634d61a48118e84b8ff (diff) |
Paint/Sculpt:
Some minor cleanups: removed `#if 0' code and moved a function into paint_util to avoid `extern' declaration.
Diffstat (limited to 'source/blender/editors/sculpt_paint')
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_intern.h | 12 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_stroke.c | 105 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_utils.c | 21 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/sculpt.c | 64 |
4 files changed, 30 insertions, 172 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h index 6232a8f2de1..e5854772400 100644 --- a/source/blender/editors/sculpt_paint/paint_intern.h +++ b/source/blender/editors/sculpt_paint/paint_intern.h @@ -29,19 +29,20 @@ #ifndef ED_PAINT_INTERN_H #define ED_PAINT_INTERN_H +struct ARegion; struct bContext; -struct Scene; -struct Object; +struct Brush; +struct ListBase; struct Mesh; +struct Object; 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 @@ void PAINT_OT_image_from_view(struct wmOperatorType *ot); /* 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); diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c index bbd5dae797e..f39ca89dddb 100644 --- a/source/blender/editors/sculpt_paint/paint_stroke.c +++ b/source/blender/editors/sculpt_paint/paint_stroke.c @@ -100,109 +100,6 @@ static void paint_draw_smooth_stroke(bContext *C, int x, int y, void *customdata 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 @@ static int load_tex(Sculpt *sd, Brush* br, ViewContext* vc) 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; diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c index 52cee23194b..cbd3a906207 100644 --- a/source/blender/editors/sculpt_paint/paint_utils.c +++ b/source/blender/editors/sculpt_paint/paint_utils.c @@ -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) diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 482aa08e9fe..08bed7404f5 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -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 @@ static float brush_strength(Sculpt *sd, StrokeCache *cache, float feather) } } -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 @@ static float tex_strength(SculptSession *ss, Brush *br, float *point, const floa 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; |