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:
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r--source/blender/blenkernel/intern/brush.c102
-rw-r--r--source/blender/blenkernel/intern/colortools.c56
-rw-r--r--source/blender/blenkernel/intern/icons.c5
-rw-r--r--source/blender/blenkernel/intern/image.c6
4 files changed, 124 insertions, 45 deletions
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index 538012ccc41..c423d426e32 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -53,8 +53,7 @@
#include "BKE_main.h"
#include "BKE_paint.h"
#include "BKE_texture.h"
-
-
+#include "BKE_icons.h"
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
@@ -70,29 +69,59 @@ Brush *add_brush(const char *name)
brush= alloc_libblock(&G.main->brush, ID_BR, name);
- brush->rgb[0]= 1.0f;
+ /* BRUSH SCULPT TOOL SETTINGS */
+ brush->sculpt_tool = SCULPT_TOOL_DRAW; /* sculpting defaults to the draw tool for new brushes */
+ brush->size= 35; /* radius of the brush in pixels */
+ brush->alpha= 0.5f; /* brush strength/intensity probably variable should be renamed? */
+ brush->autosmooth_factor= 0.0f;
+ brush->crease_pinch_factor= 0.5f;
+ brush->sculpt_plane = SCULPT_DISP_DIR_VIEW;
+ brush->plane_offset= 0.0f; /* how far above or below the plane that is found by averaging the faces */
+ brush->plane_trim= 0.5f;
+ brush->clone.alpha= 0.5f;
+ brush->normal_weight= 0.0f;
+
+ /* BRUSH PAINT TOOL SETTINGS */
+ brush->rgb[0]= 1.0f; /* default rgb color of the brush when painting - white */
brush->rgb[1]= 1.0f;
brush->rgb[2]= 1.0f;
- brush->alpha= 0.2f;
- brush->size= 25;
- brush->spacing= 3.5f;
+
+ /* BRUSH STROKE SETTINGS */
+ brush->flag |= (BRUSH_SPACE|BRUSH_SPACE_ATTEN);
+ brush->spacing= 10; /* how far each brush dot should be spaced as a percentage of brush diameter */
+
brush->smooth_stroke_radius= 75;
- brush->smooth_stroke_factor= 0.9;
- brush->rate= 0.1f;
+ brush->smooth_stroke_factor= 0.9f;
+
+ brush->rate= 0.1f; /* time delay between dots of paint or sculpting when doing airbrush mode */
+
brush->jitter= 0.0f;
- brush->clone.alpha= 0.5;
- brush->sculpt_tool = SCULPT_TOOL_DRAW;
- brush->flag |= BRUSH_SPACE;
- brush_curve_preset(brush, CURVE_PRESET_SMOOTH);
-
+ /* BRUSH TEXTURE SETTINGS */
default_mtex(&brush->mtex);
+ brush->texture_sample_bias= 0; /* value to added to texture samples */
+
+ /* brush appearance */
+
+ brush->image_icon= NULL;
+
+ brush->add_col[0]= 1.00; /* add mode color is light red */
+ brush->add_col[1]= 0.39;
+ brush->add_col[2]= 0.39;
+
+ brush->sub_col[0]= 0.39; /* subtract mode color is light blue */
+ brush->sub_col[1]= 0.39;
+ brush->sub_col[2]= 1.00;
+
+ /* the default alpha falloff curve */
+ brush_curve_preset(brush, CURVE_PRESET_SMOOTH);
+
/* enable fake user by default */
brush->id.flag |= LIB_FAKEUSER;
brush_toggled_fake_user(brush);
-
- return brush;
+
+ return brush;
}
Brush *copy_brush(Brush *brush)
@@ -118,7 +147,7 @@ Brush *copy_brush(Brush *brush)
void free_brush(Brush *brush)
{
if(brush->mtex.tex) brush->mtex.tex->id.us--;
-
+
curvemapping_free(brush->curve);
}
@@ -731,11 +760,19 @@ static void brush_apply_pressure(BrushPainter *painter, Brush *brush, float pres
brush->spacing = MAX2(1.0, painter->startspacing*(1.5f-pressure));
}
-static void brush_jitter_pos(Brush *brush, float *pos, float *jitterpos)
+void brush_jitter_pos(Brush *brush, float *pos, float *jitterpos)
{
if(brush->jitter){
- jitterpos[0] = pos[0] + ((BLI_frand()-0.5f) * brush->size * brush->jitter * 2);
- jitterpos[1] = pos[1] + ((BLI_frand()-0.5f) * brush->size * brush->jitter * 2);
+ float rand_pos[2];
+
+ // find random position within a circle of diameter 1
+ do {
+ rand_pos[0] = BLI_frand()-0.5f;
+ rand_pos[1] = BLI_frand()-0.5f;
+ } while (len_v2(rand_pos) > 0.5f);
+
+ jitterpos[0] = pos[0] + 2*rand_pos[0]*brush->size*brush->jitter;
+ jitterpos[1] = pos[1] + 2*rand_pos[1]*brush->size*brush->jitter;
}
else {
VECCOPY2D(jitterpos, pos);
@@ -887,7 +924,7 @@ int brush_painter_paint(BrushPainter *painter, BrushFunc func, float *pos, doubl
/* Uses the brush curve control to find a strength value between 0 and 1 */
float brush_curve_strength_clamp(Brush *br, float p, const float len)
{
- if(p >= len) p= 1.0f;
+ if(p >= len) return 0;
else p= p/len;
p= curvemapping_evaluateF(br->curve, 0, p);
@@ -899,9 +936,12 @@ float brush_curve_strength_clamp(Brush *br, float p, const float len)
* used for sculpt only */
float brush_curve_strength(Brush *br, float p, const float len)
{
- if(p >= len) p= 1.0f;
- else p= p/len;
- return curvemapping_evaluateF(br->curve, 0, p);
+ if(p >= len)
+ p= 1.0f;
+ else
+ p= p/len;
+
+ return curvemapping_evaluateF(br->curve, 0, p);
}
/* TODO: should probably be unified with BrushPainter stuff? */
@@ -915,7 +955,7 @@ unsigned int *brush_gen_texture_cache(Brush *br, int half_side)
memset(&texres, 0, sizeof(TexResult));
- if(mtex && mtex->tex) {
+ if(mtex->tex) {
float x, y, step = 2.0 / side, co[3];
texcache = MEM_callocN(sizeof(int) * side * side, "Brush texture cache");
@@ -993,9 +1033,9 @@ void brush_radial_control_invoke(wmOperator *op, Brush *br, float size_weight)
float original_value= 0;
if(mode == WM_RADIALCONTROL_SIZE)
- original_value = br->size * size_weight;
+ original_value = sculpt_get_brush_size(br) * size_weight;
else if(mode == WM_RADIALCONTROL_STRENGTH)
- original_value = br->alpha;
+ original_value = sculpt_get_brush_alpha(br);
else if(mode == WM_RADIALCONTROL_ANGLE) {
MTex *mtex = brush_active_texture(br);
if(mtex)
@@ -1013,9 +1053,15 @@ int brush_radial_control_exec(wmOperator *op, Brush *br, float size_weight)
const float conv = 0.017453293;
if(mode == WM_RADIALCONTROL_SIZE)
- br->size = new_value * size_weight;
+ if (sculpt_get_lock_brush_size(br)) {
+ float initial_value = RNA_float_get(op->ptr, "initial_value");
+ const float unprojected_radius = sculpt_get_brush_unprojected_radius(br);
+ sculpt_set_brush_unprojected_radius(br, unprojected_radius * new_value/initial_value * size_weight);
+ }
+ else
+ sculpt_set_brush_size(br, new_value * size_weight);
else if(mode == WM_RADIALCONTROL_STRENGTH)
- br->alpha = new_value;
+ sculpt_set_brush_alpha(br, new_value);
else if(mode == WM_RADIALCONTROL_ANGLE) {
MTex *mtex = brush_active_texture(br);
if(mtex)
diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c
index c8a01b1c12f..a07c18f42f3 100644
--- a/source/blender/blenkernel/intern/colortools.c
+++ b/source/blender/blenkernel/intern/colortools.c
@@ -126,6 +126,9 @@ CurveMapping *curvemapping_add(int tot, float minx, float miny, float maxx, floa
cumap->cm[a].curve[1].x= maxx;
cumap->cm[a].curve[1].y= maxy;
}
+
+ cumap->changed_timestamp = 0;
+
return cumap;
}
@@ -240,10 +243,12 @@ void curvemap_reset(CurveMap *cuma, rctf *clipr, int preset)
switch(preset) {
case CURVE_PRESET_LINE: cuma->totpoint= 2; break;
- case CURVE_PRESET_SHARP: cuma->totpoint= 3; break;
+ case CURVE_PRESET_SHARP: cuma->totpoint= 4; break;
case CURVE_PRESET_SMOOTH: cuma->totpoint= 4; break;
case CURVE_PRESET_MAX: cuma->totpoint= 2; break;
- case CURVE_PRESET_MID9: cuma->totpoint= 9;
+ case CURVE_PRESET_MID9: cuma->totpoint= 9; break;
+ case CURVE_PRESET_ROUND: cuma->totpoint= 4; break;
+ case CURVE_PRESET_ROOT: cuma->totpoint= 4; break;
}
cuma->curve= MEM_callocN(cuma->totpoint*sizeof(CurveMapPoint), "curve points");
@@ -251,27 +256,29 @@ void curvemap_reset(CurveMap *cuma, rctf *clipr, int preset)
switch(preset) {
case CURVE_PRESET_LINE:
cuma->curve[0].x= clipr->xmin;
- cuma->curve[0].y= clipr->ymin;
+ cuma->curve[0].y= clipr->ymax;
cuma->curve[0].flag= 0;
cuma->curve[1].x= clipr->xmax;
- cuma->curve[1].y= clipr->ymax;
+ cuma->curve[1].y= clipr->ymin;
cuma->curve[1].flag= 0;
break;
case CURVE_PRESET_SHARP:
cuma->curve[0].x= 0;
cuma->curve[0].y= 1;
- cuma->curve[1].x= 0.33;
- cuma->curve[1].y= 0.33;
- cuma->curve[2].x= 1;
- cuma->curve[2].y= 0;
+ cuma->curve[1].x= 0.25;
+ cuma->curve[1].y= 0.50;
+ cuma->curve[2].x= 0.75;
+ cuma->curve[2].y= 0.04;
+ cuma->curve[3].x= 1;
+ cuma->curve[3].y= 0;
break;
case CURVE_PRESET_SMOOTH:
cuma->curve[0].x= 0;
cuma->curve[0].y= 1;
cuma->curve[1].x= 0.25;
- cuma->curve[1].y= 0.92;
+ cuma->curve[1].y= 0.94;
cuma->curve[2].x= 0.75;
- cuma->curve[2].y= 0.08;
+ cuma->curve[2].y= 0.06;
cuma->curve[3].x= 1;
cuma->curve[3].y= 0;
break;
@@ -290,8 +297,29 @@ void curvemap_reset(CurveMap *cuma, rctf *clipr, int preset)
cuma->curve[i].y= 0.5;
}
}
+ break;
+ case CURVE_PRESET_ROUND:
+ cuma->curve[0].x= 0;
+ cuma->curve[0].y= 1;
+ cuma->curve[1].x= 0.5;
+ cuma->curve[1].y= 0.90;
+ cuma->curve[2].x= 0.86;
+ cuma->curve[2].y= 0.5;
+ cuma->curve[3].x= 1;
+ cuma->curve[3].y= 0;
+ break;
+ case CURVE_PRESET_ROOT:
+ cuma->curve[0].x= 0;
+ cuma->curve[0].y= 1;
+ cuma->curve[1].x= 0.25;
+ cuma->curve[1].y= 0.95;
+ cuma->curve[2].x= 0.75;
+ cuma->curve[2].y= 0.44;
+ cuma->curve[3].x= 1;
+ cuma->curve[3].y= 0;
+ break;
}
-
+
if(cuma->table) {
MEM_freeN(cuma->table);
cuma->table= NULL;
@@ -619,7 +647,9 @@ void curvemapping_changed(CurveMapping *cumap, int rem_doubles)
float thresh= 0.01f*(clipr->xmax - clipr->xmin);
float dx= 0.0f, dy= 0.0f;
int a;
-
+
+ cumap->changed_timestamp++;
+
/* clamp with clip */
if(cumap->flag & CUMA_DO_CLIP) {
for(a=0; a<cuma->totpoint; a++) {
@@ -701,7 +731,7 @@ float curvemapping_evaluateF(CurveMapping *cumap, int cur, float value)
if(cuma->table==NULL) {
curvemap_make_table(cuma, &cumap->clipr);
if(cuma->table==NULL)
- return value;
+ return 1.0f-value;
}
return curvemap_evaluateF(cuma, value);
}
diff --git a/source/blender/blenkernel/intern/icons.c b/source/blender/blenkernel/intern/icons.c
index 29314fb4865..ad2c857be75 100644
--- a/source/blender/blenkernel/intern/icons.c
+++ b/source/blender/blenkernel/intern/icons.c
@@ -38,6 +38,7 @@
#include "DNA_material_types.h"
#include "DNA_texture_types.h"
#include "DNA_world_types.h"
+#include "DNA_brush_types.h"
#include "BLI_ghash.h"
@@ -120,6 +121,7 @@ struct PreviewImage* BKE_previewimg_create()
for (i=0; i<PREVIEW_MIPMAPS; ++i) {
prv_img->changed[i] = 1;
+ prv_img->changed_timestamp[i] = 0;
}
return prv_img;
}
@@ -202,7 +204,7 @@ PreviewImage* BKE_previewimg_get(ID *id)
Image *img = (Image*)id;
if (!img->preview) img->preview = BKE_previewimg_create();
prv_img = img->preview;
- }
+ }
return prv_img;
}
@@ -224,6 +226,7 @@ void BKE_icon_changed(int id)
int i;
for (i=0; i<PREVIEW_MIPMAPS; ++i) {
prv->changed[i] = 1;
+ prv->changed_timestamp[i]++;
}
}
}
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index dc78dac04dd..b66b5c60916 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -200,9 +200,9 @@ void free_image(Image *ima)
}
BKE_icon_delete(&ima->id);
ima->id.icon_id = 0;
- if (ima->preview) {
- BKE_previewimg_free(&ima->preview);
- }
+
+ BKE_previewimg_free(&ima->preview);
+
for(a=0; a<IMA_MAX_RENDER_SLOT; a++) {
if(ima->renders[a]) {
RE_FreeRenderResult(ima->renders[a]);