Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Ebb <matt@mke3.net>2010-01-03 11:37:18 +0300
committerMatt Ebb <matt@mke3.net>2010-01-03 11:37:18 +0300
commit251ef0a47f34806b911ab18b59f604dd0ef3ea5b (patch)
tree23574564a0d36337c8d2338197c1527cc77e76ca /source/blender/blenkernel/intern/brush.c
parentca4a5f309eed9922eb7d5188173942f36a5adc0d (diff)
Changes to Brush texture workflow
This changes how textures are accessed from Brushes, with the intention of simplifying the workflow, and reducing the amount of clicking. Rather than the previous texture slots (which didn't work as a stack anyway), brushes now have a single texture linked. Rather than taking time having to set up your slots in advance, you can now select and change textures directly as you sculpt/paint on the fly. For complex brushes, node textures can be used, or for fast access, it's easy to make a duplicate of your brush with the texture you like and assign a hotkey. Brush textures can now be chosen from a new Textures panel in the brush tool properties - click on the thumbnail to open a texture selector. This is done using a new variation on the ID template - the number of rows and columns to display in the popup can be customised in the UI scripts.
Diffstat (limited to 'source/blender/blenkernel/intern/brush.c')
-rw-r--r--source/blender/blenkernel/intern/brush.c58
1 files changed, 14 insertions, 44 deletions
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index 667b0d50ee9..444c6d2c903 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -100,19 +100,11 @@ Brush *add_brush(const char *name)
Brush *copy_brush(Brush *brush)
{
Brush *brushn;
- MTex *mtex;
- int a;
brushn= copy_libblock(brush);
- for(a=0; a<MAX_MTEX; a++) {
- mtex= brush->mtex[a];
- if(mtex) {
- brushn->mtex[a]= MEM_dupallocN(mtex);
- if(mtex->tex) id_us_plus((ID*)mtex->tex);
- }
- }
-
+ if(brush->mtex.tex) id_us_plus((ID*)brush->mtex.tex);
+
brushn->curve= curvemapping_copy(brush->curve);
/* enable fake user by default */
@@ -127,17 +119,8 @@ Brush *copy_brush(Brush *brush)
/* not brush itself */
void free_brush(Brush *brush)
{
- MTex *mtex;
- int a;
-
- for(a=0; a<MAX_MTEX; a++) {
- mtex= brush->mtex[a];
- if(mtex) {
- if(mtex->tex) mtex->tex->id.us--;
- MEM_freeN(mtex);
- }
- }
-
+ if(brush->mtex.tex) brush->mtex.tex->id.us--;
+
curvemapping_free(brush->curve);
}
@@ -295,8 +278,8 @@ void brush_curve_preset(Brush *b, BrushCurvePreset preset)
static MTex *brush_active_texture(Brush *brush)
{
- if(brush && brush->texact >= 0)
- return brush->mtex[brush->texact];
+ if(brush)
+ return &brush->mtex;
return NULL;
}
@@ -304,8 +287,7 @@ int brush_texture_set_nr(Brush *brush, int nr)
{
ID *idtest, *id=NULL;
- if(brush->mtex[brush->texact])
- id= (ID *)brush->mtex[brush->texact]->tex;
+ id= (ID *)brush->mtex.tex;
idtest= (ID*)BLI_findlink(&G.main->tex, nr-1);
if(idtest==0) { /* new tex */
@@ -316,13 +298,7 @@ int brush_texture_set_nr(Brush *brush, int nr)
if(idtest!=id) {
brush_texture_delete(brush);
- if(brush->mtex[brush->texact]==NULL) {
- brush->mtex[brush->texact]= add_mtex();
- brush->mtex[brush->texact]->r = 1.0f;
- brush->mtex[brush->texact]->g = 1.0f;
- brush->mtex[brush->texact]->b = 1.0f;
- }
- brush->mtex[brush->texact]->tex= (Tex*)idtest;
+ brush->mtex.tex= (Tex*)idtest;
id_us_plus(idtest);
return 1;
@@ -333,16 +309,10 @@ int brush_texture_set_nr(Brush *brush, int nr)
int brush_texture_delete(Brush *brush)
{
- if(brush->mtex[brush->texact]) {
- if(brush->mtex[brush->texact]->tex)
- brush->mtex[brush->texact]->tex->id.us--;
- MEM_freeN(brush->mtex[brush->texact]);
- brush->mtex[brush->texact]= NULL;
-
- return 1;
- }
+ if(brush->mtex.tex)
+ brush->mtex.tex->id.us--;
- return 0;
+ return 1;
}
int brush_clone_image_set_nr(Brush *brush, int nr)
@@ -383,7 +353,7 @@ void brush_check_exists(Brush **brush, const char *name)
/* Brush Sampling */
void brush_sample_tex(Brush *brush, float *xy, float *rgba)
{
- MTex *mtex= brush->mtex[brush->texact];
+ MTex *mtex= &brush->mtex;
if (mtex && mtex->tex) {
float co[3], tin, tr, tg, tb, ta;
@@ -741,7 +711,7 @@ static void brush_painter_refresh_cache(BrushPainter *painter, float *pos)
{
Brush *brush= painter->brush;
BrushPainterCache *cache= &painter->cache;
- MTex *mtex= brush->mtex[brush->texact];
+ MTex *mtex= &brush->mtex;
int size;
short flt;
@@ -976,7 +946,7 @@ float brush_curve_strength(Brush *br, float p, const float len)
unsigned int *brush_gen_texture_cache(Brush *br, int half_side)
{
unsigned int *texcache = NULL;
- MTex *mtex = br->mtex[br->texact];
+ MTex *mtex = &br->mtex;
TexResult texres;
int hasrgb, ix, iy;
int side = half_side * 2;