2.5/Sculpt:
* Moved the brush texture settings to MTex/TextureSlot. The mapping settings now show up in the texture panel, pretty much like they do for textures used with materials. TODO: * Tiled mode should not show Z size setting * Add a locked mode so that texture size can be changed uniformly like in 2.4x
This commit is contained in:
@@ -137,9 +137,20 @@ class TEXTURE_PT_mapping(TextureButtonsPanel):
|
||||
row.itemR(tex, "y_mapping", text="")
|
||||
row.itemR(tex, "z_mapping", text="")
|
||||
|
||||
row = layout.row()
|
||||
row.column().itemR(tex, "offset")
|
||||
row.column().itemR(tex, "size")
|
||||
if br:
|
||||
layout.itemR(tex, "brush_map_mode", expand=True)
|
||||
|
||||
row = layout.row()
|
||||
row.active = tex.brush_map_mode in ('FIXED', 'TILED')
|
||||
row.itemR(tex, "angle")
|
||||
|
||||
row = layout.row()
|
||||
row.active = tex.brush_map_mode in ('TILED', '3D')
|
||||
row.column().itemR(tex, "size")
|
||||
else:
|
||||
row = layout.row()
|
||||
row.column().itemR(tex, "offset")
|
||||
row.column().itemR(tex, "size")
|
||||
|
||||
class TEXTURE_PT_influence(TextureButtonsPanel):
|
||||
__label__ = "Influence"
|
||||
|
||||
@@ -300,6 +300,13 @@ void brush_curve_preset(Brush *b, BrushCurvePreset preset)
|
||||
curvemapping_changed(b->curve, 0);
|
||||
}
|
||||
|
||||
static MTex *brush_active_texture(Brush *brush)
|
||||
{
|
||||
if(brush && brush->texact >= 0)
|
||||
return brush->mtex[brush->texact];
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int brush_texture_set_nr(Brush *brush, int nr)
|
||||
{
|
||||
ID *idtest, *id=NULL;
|
||||
@@ -1077,8 +1084,11 @@ void brush_radial_control_invoke(wmOperator *op, Brush *br, float size_weight)
|
||||
original_value = br->size * size_weight;
|
||||
else if(mode == WM_RADIALCONTROL_STRENGTH)
|
||||
original_value = br->alpha;
|
||||
else if(mode == WM_RADIALCONTROL_ANGLE)
|
||||
original_value = br->rot;
|
||||
else if(mode == WM_RADIALCONTROL_ANGLE) {
|
||||
MTex *mtex = brush_active_texture(br);
|
||||
if(mtex)
|
||||
original_value = mtex->rot;
|
||||
}
|
||||
|
||||
RNA_float_set(op->ptr, "initial_value", original_value);
|
||||
op->customdata = brush_gen_radial_control_imbuf(br);
|
||||
@@ -1094,8 +1104,11 @@ int brush_radial_control_exec(wmOperator *op, Brush *br, float size_weight)
|
||||
br->size = new_value * size_weight;
|
||||
else if(mode == WM_RADIALCONTROL_STRENGTH)
|
||||
br->alpha = new_value;
|
||||
else if(mode == WM_RADIALCONTROL_ANGLE)
|
||||
br->rot = new_value * conv;
|
||||
else if(mode == WM_RADIALCONTROL_ANGLE) {
|
||||
MTex *mtex = brush_active_texture(br);
|
||||
if(mtex)
|
||||
mtex->rot = new_value * conv;
|
||||
}
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
@@ -655,31 +655,26 @@ static float tex_strength(Sculpt *sd, float *point, const float len)
|
||||
{
|
||||
SculptSession *ss= sd->session;
|
||||
Brush *br = sd->brush;
|
||||
MTex *tex = NULL;
|
||||
float avg= 1;
|
||||
|
||||
if(br->texact==-1 || !br->mtex[br->texact])
|
||||
if(br->texact >= 0)
|
||||
tex = br->mtex[br->texact];
|
||||
|
||||
if(!tex) {
|
||||
avg= 1;
|
||||
else if(br->tex_mode==BRUSH_TEX_3D) {
|
||||
/* Get strength by feeding the vertex location directly
|
||||
into a texture */
|
||||
}
|
||||
else if(tex->brush_map_mode == MTEX_MAP_MODE_3D) {
|
||||
float jnk;
|
||||
const float factor= 0.01;
|
||||
MTex mtex;
|
||||
memset(&mtex,0,sizeof(MTex));
|
||||
mtex.tex= br->mtex[br->texact]->tex;
|
||||
mtex.projx= 1;
|
||||
mtex.projy= 2;
|
||||
mtex.projz= 3;
|
||||
VecCopyf(mtex.size, br->mtex[br->texact]->size);
|
||||
VecMulf(mtex.size, factor);
|
||||
if(!sd->texsep)
|
||||
mtex.size[1]= mtex.size[2]= mtex.size[0];
|
||||
|
||||
externtex(&mtex,point,&avg,&jnk,&jnk,&jnk,&jnk);
|
||||
|
||||
/* Get strength by feeding the vertex
|
||||
location directly into a texture */
|
||||
externtex(tex, point, &avg,
|
||||
&jnk, &jnk, &jnk, &jnk);
|
||||
}
|
||||
else if(ss->texcache) {
|
||||
const float bsize= ss->cache->pixel_radius * 2;
|
||||
const float rot= sd->brush->rot + ss->cache->rotation;
|
||||
const float rot= tex->rot + ss->cache->rotation;
|
||||
int px, py;
|
||||
float flip[3], point_2d[2];
|
||||
|
||||
@@ -692,9 +687,9 @@ 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(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;
|
||||
if(tex->brush_map_mode == MTEX_MAP_MODE_TILED) {
|
||||
const int sx= (const int)tex->size[0];
|
||||
const int sy= (const int)tex->size[1];
|
||||
|
||||
float fx= point_2d[0];
|
||||
float fy= point_2d[1];
|
||||
@@ -714,7 +709,8 @@ static float tex_strength(Sculpt *sd, float *point, const float len)
|
||||
if(sy != 1)
|
||||
py %= sy-1;
|
||||
avg= get_texcache_pixel_bilinear(ss, ss->texcache_side*px/sx, ss->texcache_side*py/sy);
|
||||
} else {
|
||||
}
|
||||
else if(tex->brush_map_mode == MTEX_MAP_MODE_FIXED) {
|
||||
float fx= (point_2d[0] - ss->cache->mouse[0]) / bsize;
|
||||
float fy= (point_2d[1] - ss->cache->mouse[1]) / bsize;
|
||||
|
||||
|
||||
@@ -63,13 +63,10 @@ typedef struct Brush {
|
||||
float rgb[3]; /* color */
|
||||
float alpha; /* opacity */
|
||||
|
||||
float rot; /* rotation in radians */
|
||||
|
||||
short texact; /* active texture */
|
||||
char sculpt_tool; /* active tool */
|
||||
char tex_mode;
|
||||
|
||||
char pad[4];
|
||||
char pad;
|
||||
} Brush;
|
||||
|
||||
/* Brush.flag */
|
||||
@@ -97,11 +94,6 @@ 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
|
||||
|
||||
@@ -476,11 +476,10 @@ typedef struct Sculpt
|
||||
/* For rotating around a pivot point */
|
||||
float pivot[3];
|
||||
int flags;
|
||||
/* For the Brush Shape */
|
||||
char texsep;
|
||||
|
||||
/* Control tablet input */
|
||||
char tablet_size, tablet_strength;
|
||||
char pad[5];
|
||||
char pad[6];
|
||||
} Sculpt;
|
||||
|
||||
typedef struct VPaint {
|
||||
|
||||
@@ -53,17 +53,17 @@ typedef struct MTex {
|
||||
char uvname[32];
|
||||
|
||||
char projx, projy, projz, mapping;
|
||||
float ofs[3], size[3];
|
||||
float ofs[3], size[3], rot;
|
||||
|
||||
short texflag, colormodel, pmapto, pmaptoneg;
|
||||
short normapspace, which_output, pad[2];
|
||||
short normapspace, which_output;
|
||||
char brush_map_mode, pad[7];
|
||||
float r, g, b, k;
|
||||
float def_var, rt;
|
||||
|
||||
float colfac, norfac, varfac;
|
||||
float dispfac;
|
||||
float warpfac;
|
||||
|
||||
} MTex;
|
||||
|
||||
#ifndef DNA_USHORT_FIX
|
||||
@@ -396,6 +396,11 @@ typedef struct TexMapping {
|
||||
#define MTEX_BLEND_COLOR 13
|
||||
#define MTEX_NUM_BLENDTYPES 14
|
||||
|
||||
/* brush_map_mode */
|
||||
#define MTEX_MAP_MODE_FIXED 0
|
||||
#define MTEX_MAP_MODE_TILED 1
|
||||
#define MTEX_MAP_MODE_3D 2
|
||||
|
||||
/* **************** EnvMap ********************* */
|
||||
|
||||
/* type */
|
||||
|
||||
@@ -74,20 +74,6 @@ static void rna_Brush_active_texture_set(PointerRNA *ptr, PointerRNA value)
|
||||
}
|
||||
}
|
||||
|
||||
static float rna_Brush_rotation_get(PointerRNA *ptr)
|
||||
{
|
||||
Brush *brush= (Brush*)ptr->data;
|
||||
const float conv = 57.295779506;
|
||||
return brush->rot * conv;
|
||||
}
|
||||
|
||||
static void rna_Brush_rotation_set(PointerRNA *ptr, float v)
|
||||
{
|
||||
Brush *brush= (Brush*)ptr->data;
|
||||
const float conv = 0.017453293;
|
||||
brush->rot = v * conv;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void rna_def_brush(BlenderRNA *brna)
|
||||
@@ -106,12 +92,6 @@ void rna_def_brush(BlenderRNA *brna)
|
||||
{BRUSH_BLEND_ADD_ALPHA, "ADD_ALPHA", 0, "Add Alpha", "Add alpha while painting."},
|
||||
{0, NULL, 0, NULL, NULL}};
|
||||
|
||||
static EnumPropertyItem prop_texture_mode_items[] = {
|
||||
{BRUSH_TEX_DRAG, "TEX_DRAG", 0, "Drag", ""},
|
||||
{BRUSH_TEX_TILE, "TEX_TILE", 0, "Tile", ""},
|
||||
{BRUSH_TEX_3D, "TEX_3D", 0, "3D", ""},
|
||||
{0, NULL, 0, NULL, NULL}};
|
||||
|
||||
static EnumPropertyItem prop_sculpt_tool_items[] = {
|
||||
{SCULPT_TOOL_DRAW, "DRAW", 0, "Draw", ""},
|
||||
{SCULPT_TOOL_SMOOTH, "SMOOTH", 0, "Smooth", ""},
|
||||
@@ -132,11 +112,6 @@ 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", "");
|
||||
@@ -170,12 +145,6 @@ void rna_def_brush(BlenderRNA *brna)
|
||||
RNA_def_property_range(prop, 0.0f, 1.0f);
|
||||
RNA_def_property_ui_text(prop, "Strength", "The amount of pressure on the brush.");
|
||||
|
||||
prop= RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_NONE);
|
||||
RNA_def_property_float_sdna(prop, NULL, "rot");
|
||||
RNA_def_property_range(prop, 0, 360);
|
||||
RNA_def_property_float_funcs(prop, "rna_Brush_rotation_get", "rna_Brush_rotation_set", NULL);
|
||||
RNA_def_property_ui_text(prop, "Rotation", "Angle of the brush texture.");
|
||||
|
||||
/* flag */
|
||||
prop= RNA_def_property(srna, "airbrush", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_AIRBRUSH);
|
||||
|
||||
@@ -147,6 +147,20 @@ static EnumPropertyItem *rna_ImageTexture_filter_itemf(bContext *C, PointerRNA *
|
||||
return item;
|
||||
}
|
||||
|
||||
static float rna_TextureSlot_angle_get(PointerRNA *ptr)
|
||||
{
|
||||
MTex *tex= (MTex*)ptr->data;
|
||||
const float conv = 57.295779506;
|
||||
return tex->rot * conv;
|
||||
}
|
||||
|
||||
static void rna_TextureSlot_angle_set(PointerRNA *ptr, float v)
|
||||
{
|
||||
MTex *tex= (MTex*)ptr->data;
|
||||
const float conv = 0.017453293;
|
||||
tex->rot = v * conv;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static void rna_def_color_ramp_element(BlenderRNA *brna)
|
||||
@@ -267,6 +281,12 @@ static void rna_def_mtex(BlenderRNA *brna)
|
||||
{MTEX_BLEND_COLOR, "COLOR", 0, "Color", ""},
|
||||
{0, NULL, 0, NULL, NULL}};
|
||||
|
||||
static EnumPropertyItem prop_map_mode_items[] = {
|
||||
{MTEX_MAP_MODE_FIXED, "FIXED", 0, "Fixed", ""},
|
||||
{MTEX_MAP_MODE_TILED, "TILED", 0, "Tiled", ""},
|
||||
{MTEX_MAP_MODE_3D, "3D", 0, "3D", ""},
|
||||
{0, NULL, 0, NULL, NULL}};
|
||||
|
||||
srna= RNA_def_struct(brna, "TextureSlot", NULL);
|
||||
RNA_def_struct_sdna(srna, "MTex");
|
||||
RNA_def_struct_ui_text(srna, "Texture Slot", "Texture slot defining the mapping and influence of a texture.");
|
||||
@@ -325,6 +345,17 @@ static void rna_def_mtex(BlenderRNA *brna)
|
||||
RNA_def_property_ui_text(prop, "RGB to Intensity", "Converts texture RGB values to intensity (gray) values.");
|
||||
RNA_def_property_update(prop, NC_TEXTURE, NULL);
|
||||
|
||||
prop= RNA_def_property(srna, "angle", PROP_FLOAT, PROP_ANGLE);
|
||||
RNA_def_property_float_sdna(prop, NULL, "rot");
|
||||
RNA_def_property_range(prop, 0, 360);
|
||||
RNA_def_property_float_funcs(prop, "rna_TextureSlot_angle_get", "rna_TextureSlot_angle_set", NULL);
|
||||
RNA_def_property_ui_text(prop, "Angle", "Defines brush texture rotation.");
|
||||
RNA_def_property_update(prop, NC_TEXTURE, NULL);
|
||||
|
||||
prop= RNA_def_property(srna, "brush_map_mode", PROP_ENUM, PROP_NONE);
|
||||
RNA_def_property_enum_items(prop, prop_map_mode_items);
|
||||
RNA_def_property_ui_text(prop, "Mode", "");
|
||||
|
||||
prop= RNA_def_property(srna, "default_value", PROP_FLOAT, PROP_NONE);
|
||||
RNA_def_property_float_sdna(prop, NULL, "def_var");
|
||||
RNA_def_property_ui_range(prop, 0, 1, 10, 3);
|
||||
|
||||
Reference in New Issue
Block a user