diff options
author | Nicholas Bishop <nicholasbishop@gmail.com> | 2009-01-21 23:03:41 +0300 |
---|---|---|
committer | Nicholas Bishop <nicholasbishop@gmail.com> | 2009-01-21 23:03:41 +0300 |
commit | bf72c26c578df16d6d90bf4b107887e6187766f8 (patch) | |
tree | 18bad058f111fe221552f362273541dcb68e350e | |
parent | 446ed90fd62a524e00a5ad3dcbe5600e9c0521ad (diff) |
Brought back textures for sculpt mode. These are stored in Brush DNA now, as well as the three texture modes (drag/tile/3D).
-rw-r--r-- | source/blender/editors/sculpt/sculpt.c | 35 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_brush_types.h | 8 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_scene_types.h | 8 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_brush.c | 10 |
4 files changed, 45 insertions, 16 deletions
diff --git a/source/blender/editors/sculpt/sculpt.c b/source/blender/editors/sculpt/sculpt.c index 5af41a78658..01e84704c02 100644 --- a/source/blender/editors/sculpt/sculpt.c +++ b/source/blender/editors/sculpt/sculpt.c @@ -750,9 +750,9 @@ static float tex_strength(Sculpt *sd, float *point, const float len) Brush *br = sd->brush; float avg= 1; - if(br->texact==-1 || !br->mtex[sd->texact]) + if(br->texact==-1 || !br->mtex[br->texact]) avg= 1; - else if(sd->texrept==SCULPTREPT_3D) { + else if(br->tex_mode==BRUSH_TEX_3D) { /* Get strength by feeding the vertex location directly into a texture */ float jnk; @@ -785,7 +785,7 @@ static float tex_strength(Sculpt *sd, float *point, const float len) /* For Tile and Drag modes, get the 2D screen coordinates of the and scale them up or down to the texture size. */ - if(sd->texrept==SCULPTREPT_TILE) { + if(br->tex_mode==BRUSH_TEX_TILE) { const int sx= (const int)br->mtex[br->texact]->size[0]; const int sy= (const int)sd->texsep ? br->mtex[br->texact]->size[1] : sx; @@ -808,8 +808,8 @@ static float tex_strength(Sculpt *sd, float *point, const float len) py %= sy-1; avg= get_texcache_pixel_bilinear(ss, TC_SIZE*px/sx, TC_SIZE*py/sy); } else { - float fx= (point_2d[0] - ss->cache->initial_mouse[0]) / bsize; - float fy= (point_2d[1] - ss->cache->initial_mouse[1]) / bsize; + float fx= (point_2d[0] - ss->cache->mouse[0]) / bsize; + float fy= (point_2d[1] - ss->cache->mouse[1]) / bsize; float angle= atan2(fy, fx) - rot; float flen= sqrtf(fx*fx + fy*fy); @@ -1087,7 +1087,7 @@ static void projverts_clear_inside(SculptSession *ss) ss->projverts[i].inside = 0; } -static void sculptmode_update_tex(Sculpt *sd) +static void sculpt_update_tex(Sculpt *sd) { SculptSession *ss= sd->session; Brush *br = sd->brush; @@ -1099,7 +1099,7 @@ static void sculptmode_update_tex(Sculpt *sd) memset(&texres, 0, sizeof(TexResult)); /* Skip Default brush shape and non-textures */ - if(br->texact == -1 || !br->mtex[sd->texact]) return; + if(br->texact == -1 || !br->mtex[br->texact]) return; if(ss->texcache) { MEM_freeN(ss->texcache); @@ -1274,7 +1274,7 @@ static GLuint sculpt_radialcontrol_calctex() float *texdata= MEM_mallocN(sizeof(float)*tsz*tsz, "Brush preview"); GLuint tex; - if(sd->texrept!=SCULPTREPT_3D) + if(sd->tex_mode!=SCULPTREPT_3D) sculptmode_update_tex(); for(i=0; i<tsz; ++i) for(j=0; j<tsz; ++j) { @@ -1729,6 +1729,11 @@ static int sculpt_brush_stroke_invoke(bContext *C, wmOperator *op, wmEvent *even sculptmode_update_all_projverts(sd->session); + /* TODO: Shouldn't really have to do this at the start of every + stroke, but sculpt would need some sort of notification when + changes are made to the texture. */ + sculpt_update_tex(sd); + /* add modal handler */ WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op); @@ -1805,6 +1810,7 @@ static int sculpt_brush_stroke_exec(bContext *C, wmOperator *op) view3d_operator_needs_opengl(C); sculpt_update_cache_invariants(sd, C, op); + sculpt_update_tex(sd); RNA_BEGIN(op->ptr, itemptr, "stroke") { sculpt_update_cache_variants(sd, &itemptr); @@ -1899,6 +1905,8 @@ static int sculpt_toggle_mode(bContext *C, wmOperator *op) sculptsession_free(ts->sculpt); } else { + MTex *mtex; // XXX: temporary + /* Enter sculptmode */ G.f |= G_SCULPTMODE; @@ -1910,6 +1918,15 @@ static int sculpt_toggle_mode(bContext *C, wmOperator *op) /* Needed for testing, if there's no brush then create one */ ts->sculpt->brush = add_brush("test brush"); + /* Also for testing, set the brush texture to the first available one */ + if(G.main->tex.first) { + mtex = MEM_callocN(sizeof(MTex), "test mtex"); + ts->sculpt->brush->texact = 0; + ts->sculpt->brush->mtex[0] = mtex; + mtex->tex = G.main->tex.first; + mtex->size[0] = mtex->size[1] = mtex->size[2] = 50; + } + /* Activate visible brush */ ts->sculpt->session->cursor = @@ -1997,7 +2014,7 @@ void sculpt(Sculpt *sd) /* Init texture FIXME: Shouldn't be doing this every time! */ - if(sd->texrept!=SCULPTREPT_3D) + if(sd->tex_mode!=SCULPTREPT_3D) sculptmode_update_tex(sd); /*XXX: getmouseco_areawin(mouse); */ diff --git a/source/blender/makesdna/DNA_brush_types.h b/source/blender/makesdna/DNA_brush_types.h index bca5546dd80..305571b36ad 100644 --- a/source/blender/makesdna/DNA_brush_types.h +++ b/source/blender/makesdna/DNA_brush_types.h @@ -64,7 +64,8 @@ typedef struct Brush { float alpha; /* opacity */ short texact; /* active texture */ - char sculpt_tool, pad; /* active tool */ + char sculpt_tool; /* active tool */ + char tex_mode; } Brush; /* Brush.flag */ @@ -89,6 +90,11 @@ typedef struct Brush { #define BRUSH_BLEND_ERASE_ALPHA 6 #define BRUSH_BLEND_ADD_ALPHA 7 +/* Brush.tex_mode */ +#define BRUSH_TEX_DRAG 0 +#define BRUSH_TEX_TILE 1 +#define BRUSH_TEX_3D 2 + /* Brush.sculpt_tool */ #define SCULPT_TOOL_DRAW 1 #define SCULPT_TOOL_SMOOTH 2 diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index 1fe9908d961..aeb5fe01533 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -387,10 +387,10 @@ typedef struct Sculpt float pivot[3]; int flags; /* For the Brush Shape */ - short texact, texnr; - char texrept, texsep; + char texsep; /* Control tablet input */ char tablet_size, tablet_strength; + char pad[5]; } Sculpt; typedef struct VPaint { @@ -810,10 +810,6 @@ typedef struct Scene { #define SCULPT_LOCK_X 64 #define SCULPT_LOCK_Y 128 #define SCULPT_LOCK_Z 256 -/* SculptData.texrept */ -#define SCULPTREPT_DRAG 1 -#define SCULPTREPT_TILE 2 -#define SCULPTREPT_3D 3 /* toolsettings->imagepaint_flag */ #define IMAGEPAINT_DRAWING 1 diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c index 15136daaff5..04c36fd4965 100644 --- a/source/blender/makesrna/intern/rna_brush.c +++ b/source/blender/makesrna/intern/rna_brush.c @@ -62,6 +62,11 @@ void rna_def_brush(BlenderRNA *brna) {BRUSH_BLEND_ERASE_ALPHA, "ERASE_ALPHA", "Erase Alpha", "Erase alpha while painting."}, {BRUSH_BLEND_ADD_ALPHA, "ADD_ALPHA", "Add Alpha", "Add alpha while painting."}, {0, NULL, NULL, NULL}}; + static EnumPropertyItem prop_texture_mode_items[] = { + {BRUSH_TEX_DRAG, "TEX_DRAG", "Drag", ""}, + {BRUSH_TEX_TILE, "TEX_TILE", "Tile", ""}, + {BRUSH_TEX_3D, "TEX_3D", "3D", ""}, + {0, NULL, NULL, NULL}}; static EnumPropertyItem prop_sculpt_tool_items[] = { {SCULPT_TOOL_DRAW, "DRAW", "Draw", ""}, {SCULPT_TOOL_SMOOTH, "SMOOTH", "Smooth", ""}, @@ -80,6 +85,11 @@ void rna_def_brush(BlenderRNA *brna) RNA_def_property_enum_items(prop, prop_blend_items); RNA_def_property_ui_text(prop, "Blending mode", "Brush blending mode."); + prop= RNA_def_property(srna, "texture_mode", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "tex_mode"); + RNA_def_property_enum_items(prop, prop_texture_mode_items); + RNA_def_property_ui_text(prop, "Texture Mode", ""); + prop= RNA_def_property(srna, "sculpt_tool", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, prop_sculpt_tool_items); RNA_def_property_ui_text(prop, "Sculpt Tool", ""); |