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:
-rw-r--r--source/blender/blenkernel/BKE_brush.h8
-rw-r--r--source/blender/blenkernel/intern/brush.c37
-rw-r--r--source/blender/blenkernel/intern/scene.c36
-rw-r--r--source/blender/blenloader/intern/readfile.c43
-rw-r--r--source/blender/blenloader/intern/writefile.c5
-rw-r--r--source/blender/editors/sculpt/sculpt.c180
-rw-r--r--source/blender/editors/sculpt/sculpt_intern.h4
-rw-r--r--source/blender/editors/space_view3d/view3d_header.c22
-rw-r--r--source/blender/makesdna/DNA_brush_types.h24
-rw-r--r--source/blender/makesdna/DNA_scene_types.h65
10 files changed, 198 insertions, 226 deletions
diff --git a/source/blender/blenkernel/BKE_brush.h b/source/blender/blenkernel/BKE_brush.h
index 398d203709f..07ca975c46f 100644
--- a/source/blender/blenkernel/BKE_brush.h
+++ b/source/blender/blenkernel/BKE_brush.h
@@ -51,6 +51,14 @@ int brush_texture_delete(struct Brush *brush);
int brush_clone_image_set_nr(struct Brush *brush, int nr);
int brush_clone_image_delete(struct Brush *brush);
+/* brush curve */
+typedef enum {
+ BRUSH_PRESET_SHARP,
+ BRUSH_PRESET_SMOOTH,
+ BRUSH_PRESET_MAX
+} BrushCurvePreset;
+void brush_curve_preset(struct Brush *b, BrushCurvePreset preset);
+
/* sampling */
float brush_sample_falloff(struct Brush *brush, float dist);
float brush_sample_falloff_noalpha(struct Brush *brush, float dist);
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index 021f76fd2f1..f8301943822 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -32,6 +32,7 @@
#include "MEM_guardedalloc.h"
#include "DNA_brush_types.h"
+#include "DNA_color_types.h"
#include "DNA_image_types.h"
#include "DNA_texture_types.h"
#include "DNA_scene_types.h"
@@ -114,6 +115,8 @@ void free_brush(Brush *brush)
MEM_freeN(mtex);
}
}
+
+ curvemapping_free(brush->curve);
}
void make_local_brush(Brush *brush)
@@ -217,6 +220,40 @@ void brush_toggled_fake_user(Brush *brush)
}
}
+
+void sculpt_preset_curve(Brush *b, BrushCurvePreset preset)
+{
+ CurveMap *cm = NULL;
+
+ if(!b->curve)
+ b->curve = curvemapping_add(1, 0, 0, 1, 1);
+
+ cm = b->curve->cm;
+
+ if(cm->curve)
+ MEM_freeN(cm->curve);
+
+ if(preset == BRUSH_PRESET_SHARP) {
+ cm->curve= MEM_callocN(3*sizeof(CurveMapPoint), "curve points");
+ cm->flag &= ~CUMA_EXTEND_EXTRAPOLATE;
+ cm->totpoint= 3;
+ cm->curve[0].x= 0;
+ cm->curve[0].y= 1;
+ cm->curve[1].x= 0.33;
+ cm->curve[1].y= 0.33;
+ cm->curve[2].x= 1;
+ cm->curve[2].y= 0;
+ }
+ else if(preset == BRUSH_PRESET_SMOOTH) {
+ // XXX: todo
+ }
+ else if(preset == BRUSH_PRESET_MAX) {
+ // XXX: todo
+ }
+
+ curvemapping_changed(b->curve, 0);
+}
+
int brush_texture_set_nr(Brush *brush, int nr)
{
ID *idtest, *id=NULL;
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index 49597f49759..91783a3c85f 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -625,13 +625,9 @@ void sculptdata_init(Scene *sce)
sd= &sce->sculptdata;
- if(sd->cumap) {
- curvemapping_free(sd->cumap);
- sd->cumap = NULL;
- }
-
memset(sd, 0, sizeof(SculptData));
+ /* XXX: create preset brushes here
sd->drawbrush.size = sd->smoothbrush.size = sd->pinchbrush.size =
sd->inflatebrush.size = sd->grabbrush.size =
sd->layerbrush.size = sd->flattenbrush.size = 50;
@@ -653,8 +649,7 @@ void sculptdata_init(Scene *sce)
sd->flags= SCULPT_DRAW_BRUSH;
sd->tablet_size=3;
sd->tablet_strength=10;
- sd->rake=0;
- sculpt_reset_curve(sd);
+ sd->rake=0;*/
}
void sculptdata_free(Scene *sce)
@@ -671,9 +666,6 @@ void sculptdata_free(Scene *sce)
MEM_freeN(mtex);
}
}
-
- curvemapping_free(sd->cumap);
- sd->cumap = NULL;
}
void sculpt_vertexusers_free(SculptSession *ss)
@@ -707,30 +699,6 @@ void sculptsession_free(Scene *sce)
}
}
-void sculpt_reset_curve(SculptData *sd)
-{
- CurveMap *cm = NULL;
-
- if(!sd->cumap)
- sd->cumap = curvemapping_add(1, 0, 0, 1, 1);
-
- cm = sd->cumap->cm;
-
- if(cm->curve)
- MEM_freeN(cm->curve);
- cm->curve= MEM_callocN(3*sizeof(CurveMapPoint), "curve points");
- cm->flag &= ~CUMA_EXTEND_EXTRAPOLATE;
- cm->totpoint= 3;
- cm->curve[0].x= 0;
- cm->curve[0].y= 1;
- cm->curve[1].x= 0.33;
- cm->curve[1].y= 0.33;
- cm->curve[2].x= 1;
- cm->curve[2].y= 0;
-
- curvemapping_changed(sd->cumap, 0);
-}
-
/* render simplification */
int get_render_subsurf_level(RenderData *r, int lvl)
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 24dc69c50bf..042516e518e 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -1456,6 +1456,22 @@ void IDP_LibLinkProperty(IDProperty *prop, int switch_endian, FileData *fd)
{
}
+/* ************ READ CurveMapping *************** */
+
+/* cuma itself has been read! */
+static void direct_link_curvemapping(FileData *fd, CurveMapping *cumap)
+{
+ int a;
+
+ /* flag seems to be able to hang? Maybe old files... not bad to clear anyway */
+ cumap->flag &= ~CUMA_PREMULLED;
+
+ for(a=0; a<CM_TOT; a++) {
+ cumap->cm[a].curve= newdataadr(fd, cumap->cm[a].curve);
+ cumap->cm[a].table= NULL;
+ }
+}
+
/* ************ READ Brush *************** */
/* library brush linking after fileread */
static void lib_link_brush(FileData *fd, Main *main)
@@ -1485,6 +1501,11 @@ static void direct_link_brush(FileData *fd, Brush *brush)
for(a=0; a<MAX_MTEX; a++)
brush->mtex[a]= newdataadr(fd, brush->mtex[a]);
+
+ /* fallof curve */
+ brush->curve= newdataadr(fd, brush->curve);
+ if(brush->curve)
+ direct_link_curvemapping(fd, brush->curve);
}
static void direct_link_script(FileData *fd, Script *script)
@@ -1493,22 +1514,6 @@ static void direct_link_script(FileData *fd, Script *script)
SCRIPT_SET_NULL(script)
}
-/* ************ READ CurveMapping *************** */
-
-/* cuma itself has been read! */
-static void direct_link_curvemapping(FileData *fd, CurveMapping *cumap)
-{
- int a;
-
- /* flag seems to be able to hang? Maybe old files... not bad to clear anyway */
- cumap->flag &= ~CUMA_PREMULLED;
-
- for(a=0; a<CM_TOT; a++) {
- cumap->cm[a].curve= newdataadr(fd, cumap->cm[a].curve);
- cumap->cm[a].table= NULL;
- }
-}
-
/* ************ READ NODE TREE *************** */
/* singe node tree (also used for material/scene trees), ntree is not NULL */
@@ -3604,12 +3609,6 @@ static void direct_link_scene(FileData *fd, Scene *sce)
/* SculptData textures */
for(a=0; a<MAX_MTEX; ++a)
sce->sculptdata.mtex[a]= newdataadr(fd,sce->sculptdata.mtex[a]);
- /* Sculpt intensity curve */
- sce->sculptdata.cumap= newdataadr(fd, sce->sculptdata.cumap);
- if(sce->sculptdata.cumap)
- direct_link_curvemapping(fd, sce->sculptdata.cumap);
- else
- sculpt_reset_curve(&sce->sculptdata);
if(sce->ed) {
ListBase *old_seqbasep= &((Editing *)sce->ed)->seqbase;
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index 1d17b471b0e..57dde906fa3 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -1475,8 +1475,6 @@ static void write_scenes(WriteData *wd, ListBase *scebase)
for(a=0; a<MAX_MTEX; ++a)
writestruct(wd, DATA, "MTex", 1, sce->sculptdata.mtex[a]);
- if(sce->sculptdata.cumap)
- write_curvemapping(wd, sce->sculptdata.cumap);
ed= sce->ed;
if(ed) {
@@ -2011,6 +2009,9 @@ static void write_brushes(WriteData *wd, ListBase *idbase)
for(a=0; a<MAX_MTEX; a++)
if(brush->mtex[a])
writestruct(wd, DATA, "MTex", 1, brush->mtex[a]);
+
+ if(brush->curve)
+ write_curvemapping(wd, brush->curve);
}
}
}
diff --git a/source/blender/editors/sculpt/sculpt.c b/source/blender/editors/sculpt/sculpt.c
index 57d02d1c5e0..4a81744a79a 100644
--- a/source/blender/editors/sculpt/sculpt.c
+++ b/source/blender/editors/sculpt/sculpt.c
@@ -333,15 +333,14 @@ static void project(const float v[3], short p[2])
shrink the brush. Skipped for grab brush because only the first mouse down
size is used, which is small if the user has just touched the pen to the
tablet */
-char brush_size()
+char brush_size(Brush *b)
{
SculptData *sd = NULL; /* XXX */
- const BrushData *b= sculptmode_brush();
float size= b->size;
float pressure= 0; /* XXX: get_pressure(); */
short activedevice= get_activedevice();
- if(sculpt_data()->brush_type!=GRAB_BRUSH) {
+ if(b->sculpt_tool!=SCULPT_TOOL_GRAB) {
const float size_factor= sd->tablet_size / 10.0f;
/* XXX: tablet stuff
@@ -356,15 +355,14 @@ char brush_size()
/* Return modified brush strength. Includes the direction of the brush, positive
values pull vertices, negative values push. Uses tablet pressure and a
special multiplier found experimentally to scale the strength factor. */
-float brush_strength(BrushAction *a)
+float brush_strength(Brush *b, BrushAction *a)
{
SculptData *sd = NULL; /* XXX */
- const BrushData* b= sculptmode_brush();
- float dir= b->dir==1 ? 1 : -1;
+ float dir= b->flag & BRUSH_DIR_IN ? -1 : 1;
float pressure= 1;
short activedevice= get_activedevice();
float flip= a->flip ? -1:1;
- float anchored = b->flag & SCULPT_BRUSH_ANCHORED ? 25 : 1;
+ float anchored = b->flag & BRUSH_ANCHORED ? 25 : 1;
const float strength_factor= sd->tablet_strength / 10.0f;
@@ -379,20 +377,20 @@ float brush_strength(BrushAction *a)
dir= -dir;
#endif
- switch(sd->brush_type){
- case DRAW_BRUSH:
- case LAYER_BRUSH:
- return b->strength / 5000.0f * dir * pressure * flip * anchored; /*XXX: not sure why? multiplied by G.vd->grid */;
- case SMOOTH_BRUSH:
- return b->strength / 50.0f * pressure * anchored;
- case PINCH_BRUSH:
- return b->strength / 1000.0f * dir * pressure * flip * anchored;
- case GRAB_BRUSH:
+ switch(b->sculpt_tool){
+ case SCULPT_TOOL_DRAW:
+ case SCULPT_TOOL_LAYER:
+ return b->alpha / 5000.0f * dir * pressure * flip * anchored; /*XXX: not sure why? multiplied by G.vd->grid */;
+ case SCULPT_TOOL_SMOOTH:
+ return b->alpha / 50.0f * pressure * anchored;
+ case SCULPT_TOOL_PINCH:
+ return b->alpha / 1000.0f * dir * pressure * flip * anchored;
+ case SCULPT_TOOL_GRAB:
return 1;
- case INFLATE_BRUSH:
- return b->strength / 5000.0f * dir * pressure * flip * anchored;
- case FLATTEN_BRUSH:
- return b->strength / 500.0f * pressure * anchored;
+ case SCULPT_TOOL_INFLATE:
+ return b->alpha / 5000.0f * dir * pressure * flip * anchored;
+ case SCULPT_TOOL_FLATTEN:
+ return b->alpha / 500.0f * pressure * anchored;
default:
return 0;
}
@@ -413,21 +411,21 @@ void sculpt_clip(const BrushAction *a, float *co, const float val[3])
void sculpt_axislock(float *co)
{
SculptData *sd = sculpt_data();
- if (sd->axislock == AXISLOCK_X+AXISLOCK_Y+AXISLOCK_Z) return;
+ if (sd->flags & (SCULPT_LOCK_X|SCULPT_LOCK_Y|SCULPT_LOCK_Z)) return;
/* XXX: if(G.vd->twmode == V3D_MANIP_LOCAL) { */
if(0) {
float mat[3][3], imat[3][3];
/* XXX: Mat3CpyMat4(mat, OBACT->obmat); */
Mat3Inv(imat, mat);
Mat3MulVecfl(mat, co);
- if (sd->axislock & AXISLOCK_X) co[0] = 0.0;
- if (sd->axislock & AXISLOCK_Y) co[1] = 0.0;
- if (sd->axislock & AXISLOCK_Z) co[2] = 0.0;
+ if (sd->flags & SCULPT_LOCK_X) co[0] = 0.0;
+ if (sd->flags & SCULPT_LOCK_Y) co[1] = 0.0;
+ if (sd->flags & SCULPT_LOCK_Z) co[2] = 0.0;
Mat3MulVecfl(imat, co);
} else {
- if (sd->axislock & AXISLOCK_X) co[0] = 0.0;
- if (sd->axislock & AXISLOCK_Y) co[1] = 0.0;
- if (sd->axislock & AXISLOCK_Z) co[2] = 0.0;
+ if (sd->flags & SCULPT_LOCK_X) co[0] = 0.0;
+ if (sd->flags & SCULPT_LOCK_Y) co[1] = 0.0;
+ if (sd->flags & SCULPT_LOCK_Z) co[2] = 0.0;
}
}
@@ -450,12 +448,12 @@ void calc_area_normal(float out[3], const BrushAction *a, const float *outdir, c
{
ActiveData *node = active_verts->first;
SculptData *sd = sculpt_data();
- const int view = sd->brush_type==DRAW_BRUSH ? sculptmode_brush()->view : 0;
+ const int view = 0; /* XXX: should probably be a flag, not number: sd->brush_type==SCULPT_TOOL_DRAW ? sculptmode_brush()->view : 0; */
float out_flip[3];
out[0]=out[1]=out[2] = out_flip[0]=out_flip[1]=out_flip[2] = 0;
- if(sculptmode_brush()->flag & SCULPT_BRUSH_ANCHORED) {
+ if(sculptmode_brush()->flag & BRUSH_ANCHORED) {
for(; node; node = node->next)
add_norm_if(((BrushAction*)a)->symm.out, out, out_flip, a->orig_norms[node->Index]);
}
@@ -604,7 +602,7 @@ void do_layer_brush(SculptSession *ss, BrushAction *a, const ListBase *active_ve
{
float area_normal[3];
ActiveData *node= active_verts->first;
- const float bstr= brush_strength(a);
+ const float bstr= brush_strength(sculptmode_brush(), a);
calc_area_normal(area_normal, a, NULL, active_verts);
@@ -717,21 +715,20 @@ void do_flatten_brush(SculptSession *ss, const BrushAction *a, const ListBase *a
}
/* Uses the brush curve control to find a strength value between 0 and 1 */
-float curve_strength(float p, const float len)
+float curve_strength(CurveMapping *cumap, float p, const float len)
{
- SculptData *sd = NULL; /* XXX */
if(p > len) p= len;
- return curvemapping_evaluateF(sd->cumap, 0, p/len);
+ return curvemapping_evaluateF(cumap, 0, p/len);
}
/* Uses symm to selectively flip any axis of a coordinate. */
void flip_coord(float co[3], const char symm)
{
- if(symm & SYMM_X)
+ if(symm & SCULPT_SYMM_X)
co[0]= -co[0];
- if(symm & SYMM_Y)
+ if(symm & SCULPT_SYMM_Y)
co[1]= -co[1];
- if(symm & SYMM_Z)
+ if(symm & SCULPT_SYMM_Z)
co[2]= -co[2];
}
@@ -876,8 +873,7 @@ float tex_strength(BrushAction *a, float *point, const float len,const unsigned
}
}
- if(sd->texfade)
- avg*= curve_strength(len, a->size_3d); /* Smooth curve */
+//XXX avg*= curve_strength(NULL, len, a->size_3d); /* Falloff curve */
return avg;
}
@@ -943,7 +939,7 @@ void sculpt_clear_damaged_areas(SculptSession *ss)
}
}
-void do_brush_action(BrushAction *a)
+void do_brush_action(Brush *b, BrushAction *a)
{
int i;
float av_dist;
@@ -951,7 +947,7 @@ void do_brush_action(BrushAction *a)
ActiveData *adata= 0;
float *vert;
Mesh *me= NULL; /*XXX: get_mesh(OBACT); */
- const float bstrength= brush_strength(a);
+ const float bstrength= brush_strength(sculptmode_brush(), a);
KeyBlock *keyblock= NULL; /*XXX: ob_get_keyblock(OBACT); */
SculptData *sd = sculpt_data();
SculptSession *ss = sculpt_session();
@@ -960,7 +956,7 @@ void do_brush_action(BrushAction *a)
/* Build a list of all vertices that are potentially within the brush's
area of influence. Only do this once for the grab brush. */
- if((sd->brush_type != GRAB_BRUSH) || a->firsttime) {
+ if((b->sculpt_tool != SCULPT_TOOL_GRAB) || a->firsttime) {
for(i=0; i<ss->totvert; ++i) {
/* Projverts.inside provides a rough bounding box */
if(ss->multires || ss->projverts[i].inside) {
@@ -976,7 +972,7 @@ void do_brush_action(BrushAction *a)
adata->Fade= tex_strength(a, vert, av_dist, i) * bstrength;
adata->dist = av_dist;
- if(sd->brush_type == GRAB_BRUSH && a->firsttime)
+ if(b->sculpt_tool == SCULPT_TOOL_GRAB && a->firsttime)
BLI_addtail(&a->grab_active_verts[a->symm.index], adata);
else
BLI_addtail(&active_verts, adata);
@@ -986,28 +982,28 @@ void do_brush_action(BrushAction *a)
}
/* Only act if some verts are inside the brush area */
- if(active_verts.first || (sd->brush_type == GRAB_BRUSH && a->grab_active_verts[a->symm.index].first)) {
+ if(active_verts.first || (b->sculpt_tool == SCULPT_TOOL_GRAB && a->grab_active_verts[a->symm.index].first)) {
/* Apply one type of brush action */
- switch(sd->brush_type){
- case DRAW_BRUSH:
+ switch(b->sculpt_tool){
+ case SCULPT_TOOL_DRAW:
do_draw_brush(ss, a, &active_verts);
break;
- case SMOOTH_BRUSH:
+ case SCULPT_TOOL_SMOOTH:
do_smooth_brush(ss, a, &active_verts);
break;
- case PINCH_BRUSH:
+ case SCULPT_TOOL_PINCH:
do_pinch_brush(ss, a, &active_verts);
break;
- case INFLATE_BRUSH:
+ case SCULPT_TOOL_INFLATE:
do_inflate_brush(ss, a, &active_verts);
break;
- case GRAB_BRUSH:
+ case SCULPT_TOOL_GRAB:
do_grab_brush(ss, a);
break;
- case LAYER_BRUSH:
+ case SCULPT_TOOL_LAYER:
do_layer_brush(ss, a, &active_verts);
break;
- case FLATTEN_BRUSH:
+ case SCULPT_TOOL_FLATTEN:
do_flatten_brush(ss, a, &active_verts);
break;
}
@@ -1016,7 +1012,7 @@ void do_brush_action(BrushAction *a)
if(keyblock && !ss->multires) {
float *co= keyblock->data;
if(co) {
- if(sd->brush_type == GRAB_BRUSH)
+ if(b->sculpt_tool == SCULPT_TOOL_GRAB)
adata = a->grab_active_verts[a->symm.index].first;
else
adata = active_verts.first;
@@ -1030,7 +1026,7 @@ void do_brush_action(BrushAction *a)
if(ss->vertexcosnos && !ss->multires)
BLI_freelistN(&active_verts);
else {
- if(sd->brush_type != GRAB_BRUSH)
+ if(b->sculpt_tool != SCULPT_TOOL_GRAB)
addlisttolist(&ss->damaged_verts, &active_verts);
}
}
@@ -1052,13 +1048,14 @@ void calc_brushdata_symm(BrushAction *a, const char symm)
void do_symmetrical_brush_actions(BrushAction *a, short co[2], short pr_co[2])
{
- const char symm = sculpt_data()->symm;
+ SculptData *sd = NULL; // XXX
+ const char symm = sd->flags & 7;
BrushActionSymm orig;
int i;
init_brushaction(a, co, pr_co);
orig = a->symm;
- do_brush_action(a);
+ do_brush_action(sd->brush, a);
for(i = 1; i <= symm; ++i) {
if(symm & i && (symm != 5 || i != 3) && (symm != 6 || (i != 3 && i != 5))) {
@@ -1066,7 +1063,7 @@ void do_symmetrical_brush_actions(BrushAction *a, short co[2], short pr_co[2])
a->symm = orig;
calc_brushdata_symm(a, i);
- do_brush_action(a);
+ do_brush_action(sd->brush, a);
}
}
@@ -1139,27 +1136,6 @@ void projverts_clear_inside(SculptSession *ss)
ss->projverts[i].inside = 0;
}
-BrushData *sculptmode_brush(void)
-{
- SculptData *sd= sculpt_data();
-
- BrushData *bd =
- (sd->brush_type==DRAW_BRUSH ? &sd->drawbrush :
- sd->brush_type==SMOOTH_BRUSH ? &sd->smoothbrush :
- sd->brush_type==PINCH_BRUSH ? &sd->pinchbrush :
- sd->brush_type==INFLATE_BRUSH ? &sd->inflatebrush :
- sd->brush_type==GRAB_BRUSH ? &sd->grabbrush :
- sd->brush_type==LAYER_BRUSH ? &sd->layerbrush :
- sd->brush_type==FLATTEN_BRUSH ? &sd->flattenbrush : NULL);
-
- if(!bd) {
- /* XXX: sculptdata_init(G.scene); */
- bd = &sd->drawbrush;
- }
-
- return bd;
-}
-
void sculptmode_update_tex()
{
SculptData *sd= sculpt_data();
@@ -1216,14 +1192,16 @@ static void init_brushaction(BrushAction *a, short *mouse, short *pr_mouse)
{
SculptData *sd = sculpt_data();
SculptSession *ss = sculpt_session();
+ Brush *b = sd->brush;
Object *ob = NULL; /* XXX */
const float mouse_depth = get_depth(mouse[0], mouse[1]);
float brush_edge_loc[3], zero_loc[3], oldloc[3];
ModifierData *md;
int i;
const char flip = 0; /*XXX: (get_qual() == LR_SHIFTKEY); */
- const char anchored = sculptmode_brush()->flag & SCULPT_BRUSH_ANCHORED;
+ const char anchored = sculptmode_brush()->flag & BRUSH_ANCHORED;
short orig_mouse[2], dx=0, dy=0;
+ float size = brush_size(b);
a->flip = flip;
a->symm.index = 0;
@@ -1250,7 +1228,7 @@ static void init_brushaction(BrushAction *a, short *mouse, short *pr_mouse)
a->anchored_rot = atan2(dy, dx);
}
else
- unproject(brush_edge_loc, mouse[0] + brush_size(), mouse[1], mouse_depth);
+ unproject(brush_edge_loc, mouse[0] + size, mouse[1], mouse_depth);
a->size_3d = VecLenf(a->symm.center_3d, brush_edge_loc);
@@ -1259,7 +1237,7 @@ static void init_brushaction(BrushAction *a, short *mouse, short *pr_mouse)
if(anchored)
a->radius = sqrt(dx*dx + dy*dy);
else
- a->radius = brush_size();
+ a->radius = size;
/* Set the pivot to allow the model to rotate around the center of the brush */
if(get_depth(mouse[0],mouse[1]) < 1.0)
@@ -1294,7 +1272,7 @@ static void init_brushaction(BrushAction *a, short *mouse, short *pr_mouse)
}
}
- if(sd->brush_type == GRAB_BRUSH) {
+ if(b->sculpt_tool == SCULPT_TOOL_GRAB) {
float gcenter[3];
/* Find the delta */
@@ -1302,12 +1280,12 @@ static void init_brushaction(BrushAction *a, short *mouse, short *pr_mouse)
unproject(oldloc, pr_mouse[0], pr_mouse[1], a->depth);
VecSubf(a->symm.grab_delta, gcenter, oldloc);
}
- else if(sd->brush_type == LAYER_BRUSH) {
+ else if(b->sculpt_tool == SCULPT_TOOL_LAYER) {
if(!a->layer_disps)
a->layer_disps= MEM_callocN(sizeof(float)*ss->totvert,"Layer disps");
}
- if(sd->brush_type == LAYER_BRUSH || anchored) {
+ if(b->sculpt_tool == SCULPT_TOOL_LAYER || anchored) {
unsigned i;
if(!a->mesh_store) {
@@ -1329,13 +1307,15 @@ static void init_brushaction(BrushAction *a, short *mouse, short *pr_mouse)
}
}
}
+
+/* XXX: Used anywhere?
void sculptmode_set_strength(const int delta)
{
int val = sculptmode_brush()->strength + delta;
if(val < 1) val = 1;
if(val > 100) val = 100;
sculptmode_brush()->strength= val;
-}
+}*/
/* XXX: haven't brought in the radial control files, not sure where to put them. Note that all the paint modes should have access to radial control! */
#if 0
@@ -1424,7 +1404,7 @@ void sculpt_radialcontrol_start(int mode)
/* XXX: drawing code to go elsewhere!
void sculpt_paint_brush(char clear)
{
- if(sculpt_data()->flags & SCULPT_DRAW_BRUSH) {
+ if(sculpt_data()->flags & SCULPT_SCULPT_TOOL_DRAW) {
static short mvalo[2];
short mval[2];
const short rad= sculptmode_brush()->size;
@@ -1639,7 +1619,7 @@ void sculpt(void)
int scissor_box[4];
float offsetRot;
int smooth_stroke = 0, i;
- int anchored;
+ int anchored, rake = 0 /* XXX: rake = ? */;
/* XXX: checking that sculpting is allowed
if(!(G.f & G_SCULPTMODE) || G.obedit || !ob || ob->id.lib || !get_mesh(ob) || (get_mesh(ob)->totface == 0))
@@ -1658,8 +1638,8 @@ void sculpt(void)
ss= sd->session;
}
- anchored = sculptmode_brush()->flag & SCULPT_BRUSH_ANCHORED;
- smooth_stroke = (sd->flags & SCULPT_INPUT_SMOOTH) && (sd->brush_type != GRAB_BRUSH) && !anchored;
+ anchored = sculptmode_brush()->flag & BRUSH_ANCHORED;
+ smooth_stroke = (sd->flags & SCULPT_INPUT_SMOOTH) && (sd->brush->sculpt_tool != SCULPT_TOOL_GRAB) && !anchored;
if(smooth_stroke)
sculpt_stroke_new(256);
@@ -1731,7 +1711,7 @@ void sculpt(void)
while (get_mbut() & mousebut) {
getmouseco_areawin(mouse);
/* If rake, and the mouse has moved over 10 pixels (euclidean) (prevents jitter) then get the new angle */
- if (sd->rake && (pow(lastSigMouse[0]-mouse[0],2)+pow(lastSigMouse[1]-mouse[1],2))>100){
+ if (rake && (pow(lastSigMouse[0]-mouse[0],2)+pow(lastSigMouse[1]-mouse[1],2))>100){
/*Nasty looking, but just orig + new angle really*/
set_tex_angle(offsetRot+180.+to_deg(atan2((float)(mouse[1]-lastSigMouse[1]),(float)(mouse[0]-lastSigMouse[0]))));
lastSigMouse[0]=mouse[0];
@@ -1739,7 +1719,7 @@ void sculpt(void)
}
if(firsttime || mouse[0]!=mvalo[0] || mouse[1]!=mvalo[1] ||
- sculptmode_brush()->flag & SCULPT_BRUSH_AIRBRUSH) {
+ sculptmode_brush()->flag & BRUSH_AIRBRUSH) {
a->firsttime = firsttime;
firsttime= 0;
@@ -1751,7 +1731,7 @@ void sculpt(void)
if(modifier_calculations && !ss->vertexcosnos)
ss->vertexcosnos= mesh_get_mapped_verts_nors(NULL, ob); /*XXX scene = ? */
- if(sd->brush_type != GRAB_BRUSH) {
+ if(sd->brush->sculpt_tool != SCULPT_TOOL_GRAB) {
if(anchored) {
/* Restore the mesh before continuing with anchored stroke */
if(a->mesh_store) {
@@ -1783,7 +1763,7 @@ void sculpt(void)
if((!ss->multires && modifier_calculations) || ob_get_keyblock(ob))
;/* XXX: DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA); */
- if(modifier_calculations || sd->brush_type == GRAB_BRUSH || !(sd->flags & SCULPT_DRAW_FAST)) {
+ if(modifier_calculations || sd->brush->sculpt_tool == SCULPT_TOOL_GRAB || !(sd->flags & SCULPT_DRAW_FAST)) {
calc_damaged_verts(&ss->damaged_verts, a);
/*XXX: scrarea_do_windraw(curarea); */
screen_swapbuffers();
@@ -1806,7 +1786,7 @@ void sculpt(void)
glDisable(GL_DEPTH_TEST);
/* Draw cursor */
- if(sculpt_data()->flags & SCULPT_DRAW_BRUSH)
+ if(sculpt_data()->flags & SCULPT_TOOL_DRAW)
fdrawXORcirc((float)mouse[0],(float)mouse[1],sculptmode_brush()->size);
if(smooth_stroke)
sculpt_stroke_draw();
@@ -1863,19 +1843,19 @@ void sculpt(void)
static void sculpt_undo_push(const short brush_type)
{
switch(brush_type) {
- case DRAW_BRUSH:
+ case SCULPT_TOOL_DRAW:
BIF_undo_push("Draw Brush"); break;
- case SMOOTH_BRUSH:
+ case SCULPT_TOOL_SMOOTH:
BIF_undo_push("Smooth Brush"); break;
- case PINCH_BRUSH:
+ case SCULPT_TOOL_PINCH:
BIF_undo_push("Pinch Brush"); break;
- case INFLATE_BRUSH:
+ case SCULPT_TOOL_INFLATE:
BIF_undo_push("Inflate Brush"); break;
- case GRAB_BRUSH:
+ case SCULPT_TOOL_GRAB:
BIF_undo_push("Grab Brush"); break;
- case LAYER_BRUSH:
+ case SCULPT_TOOL_LAYER:
BIF_undo_push("Layer Brush"); break;
- case FLATTEN_BRUSH:
+ case SCULPT_TOOL_FLATTEN:
BIF_undo_push("Flatten Brush"); break;
default:
BIF_undo_push("Sculpting"); break;
diff --git a/source/blender/editors/sculpt/sculpt_intern.h b/source/blender/editors/sculpt/sculpt_intern.h
index 04112da55d3..35a9861eceb 100644
--- a/source/blender/editors/sculpt/sculpt_intern.h
+++ b/source/blender/editors/sculpt/sculpt_intern.h
@@ -36,7 +36,7 @@
struct uiBlock;
struct BrushAction;
-struct BrushData;
+struct Brush;
struct IndexNode;
struct KeyBlock;
struct Mesh;
@@ -64,7 +64,7 @@ void sculpt_paint_brush(char clear);
void sculpt_stroke_draw();
void sculpt_radialcontrol_start(int mode);
-struct BrushData *sculptmode_brush(void);
+struct Brush *sculptmode_brush(void);
void do_symmetrical_brush_actions(struct BrushAction *a, short *, short *);
void sculptmode_update_tex(void);
diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c
index ff07df36764..3caa2d25da7 100644
--- a/source/blender/editors/space_view3d/view3d_header.c
+++ b/source/blender/editors/space_view3d/view3d_header.c
@@ -4869,26 +4869,26 @@ uiBlock *view3d_sculptmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unu
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Rotate Brush|Ctrl F", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 15, "");
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
- uiDefIconTextBut(block, BUTM, 1, (sd->symm & SYMM_Z ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT), "Z Symmetry|Z", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 10, "");
- uiDefIconTextBut(block, BUTM, 1, (sd->symm & SYMM_Y ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT), "Y Symmetry|Y", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 9, "");
- uiDefIconTextBut(block, BUTM, 1, (sd->symm & SYMM_X ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT), "X Symmetry|X", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 8, "");
+ uiDefIconTextBut(block, BUTM, 1, (sd->flags & SCULPT_SYMM_Z ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT), "Z Symmetry|Z", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 10, "");
+ uiDefIconTextBut(block, BUTM, 1, (sd->flags & SCULPT_SYMM_Y ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT), "Y Symmetry|Y", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 9, "");
+ uiDefIconTextBut(block, BUTM, 1, (sd->flags & SCULPT_SYMM_X ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT), "X Symmetry|X", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 8, "");
- if(sd->brush_type!=GRAB_BRUSH) {
+ /* XXX if(sd->brush_type!=GRAB_BRUSH) {
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
-// XXX uiDefIconTextBut(block, BUTM, 1, (br->flag & SCULPT_BRUSH_AIRBRUSH ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT), "Airbrush|A", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 7, "");
+ uiDefIconTextBut(block, BUTM, 1, (br->flag & SCULPT_BRUSH_AIRBRUSH ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT), "Airbrush|A", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 7, "");
-// if(sd->brush_type!=SMOOTH_BRUSH && sd->brush_type!=FLATTEN_BRUSH) {
-// uiDefIconTextBut(block, BUTM, 1, (br->dir==1 ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT), "Add|V", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 18, "");
-// }
- }
+ if(sd->brush_type!=SMOOTH_BRUSH && sd->brush_type!=FLATTEN_BRUSH) {
+ uiDefIconTextBut(block, BUTM, 1, (br->dir==1 ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT), "Add|V", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 18, "");
+ }
+ }*/
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
- uiDefIconTextBut(block, BUTM, 1, (sd->brush_type==FLATTEN_BRUSH ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT), "Flatten|T", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 6, "");
+ /* XXX uiDefIconTextBut(block, BUTM, 1, (sd->brush_type==FLATTEN_BRUSH ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT), "Flatten|T", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 6, "");
uiDefIconTextBut(block, BUTM, 1, (sd->brush_type==LAYER_BRUSH ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT), "Layer|L", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 5, "");
uiDefIconTextBut(block, BUTM, 1, (sd->brush_type==GRAB_BRUSH ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT), "Grab|G", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 4, "");
uiDefIconTextBut(block, BUTM, 1, (sd->brush_type==INFLATE_BRUSH ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT), "Inflate|I", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 3, "");
uiDefIconTextBut(block, BUTM, 1, (sd->brush_type==PINCH_BRUSH ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT), "Pinch|P", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 2, "");
uiDefIconTextBut(block, BUTM, 1, (sd->brush_type==SMOOTH_BRUSH ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT), "Smooth|S", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1, "");
- uiDefIconTextBut(block, BUTM, 1, (sd->brush_type==DRAW_BRUSH ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT), "Draw|D", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 0, "");
+ uiDefIconTextBut(block, BUTM, 1, (sd->brush_type==DRAW_BRUSH ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT), "Draw|D", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 0, "");*/
if(handle->region->alignment==RGN_ALIGN_TOP) {
diff --git a/source/blender/makesdna/DNA_brush_types.h b/source/blender/makesdna/DNA_brush_types.h
index c7196763358..bca5546dd80 100644
--- a/source/blender/makesdna/DNA_brush_types.h
+++ b/source/blender/makesdna/DNA_brush_types.h
@@ -36,6 +36,7 @@
#define MAX_MTEX 18
#endif
+struct CurveMapping;
struct MTex;
struct Image;
@@ -47,6 +48,11 @@ typedef struct BrushClone {
typedef struct Brush {
ID id;
+
+ struct BrushClone clone;
+
+ struct CurveMapping *curve; /* falloff curve */
+ struct MTex *mtex[18]; /* MAX_MTEX */
short flag, blend; /* general purpose flag, blend mode */
int size; /* brush diameter */
@@ -57,10 +63,8 @@ typedef struct Brush {
float rgb[3]; /* color */
float alpha; /* opacity */
- short texact, pad;
- struct MTex *mtex[18]; /* MAX_MTEX */
-
- struct BrushClone clone;
+ short texact; /* active texture */
+ char sculpt_tool, pad; /* active tool */
} Brush;
/* Brush.flag */
@@ -71,6 +75,9 @@ typedef struct Brush {
#define BRUSH_RAD_PRESSURE 16
#define BRUSH_SPACING_PRESSURE 32
#define BRUSH_FIXED_TEX 64
+#define BRUSH_RAKE 128
+#define BRUSH_ANCHORED 256
+#define BRUSH_DIR_IN 512
/* Brush.blend */
#define BRUSH_BLEND_MIX 0
@@ -82,6 +89,15 @@ typedef struct Brush {
#define BRUSH_BLEND_ERASE_ALPHA 6
#define BRUSH_BLEND_ADD_ALPHA 7
+/* Brush.sculpt_tool */
+#define SCULPT_TOOL_DRAW 1
+#define SCULPT_TOOL_SMOOTH 2
+#define SCULPT_TOOL_PINCH 3
+#define SCULPT_TOOL_INFLATE 4
+#define SCULPT_TOOL_GRAB 5
+#define SCULPT_TOOL_LAYER 6
+#define SCULPT_TOOL_FLATTEN 7
+
#define PAINT_TOOL_DRAW 0
#define PAINT_TOOL_SOFTEN 1
#define PAINT_TOOL_SMEAR 2
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index 8d446d265ad..1dfdd940cfa 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -33,6 +33,7 @@
extern "C" {
#endif
+#include "DNA_brush_types.h"
#include "DNA_vec_types.h"
#include "DNA_listBase.h"
#include "DNA_scriptlink_types.h"
@@ -451,22 +452,10 @@ typedef struct ToolSettings {
char edge_mode;
} ToolSettings;
-/* Used by all brushes to store their properties, which can be directly set
- by the interface code. Note that not all properties are actually used by
- all the brushes. */
-typedef struct BrushData
-{
- short size;
- char strength, dir; /* Not used for smooth brush */
- char view;
- char flag;
- char pad[2];
-} BrushData;
-
struct SculptSession;
typedef struct SculptData
{
- /* Note! all pointers in this struct must be duplicated header_info.c's copy_scene function */
+ /* Note! a deep copy of this struct must be done header_info.c's copy_scene function */
/* Data stored only from entering sculptmode until exiting sculptmode */
struct SculptSession *session;
@@ -474,38 +463,25 @@ typedef struct SculptData
/* Pointers to all of sculptmodes's textures */
struct MTex *mtex[18];
- /* Editable brush shape */
- struct CurveMapping *cumap;
-
- /* Settings for each brush */
- BrushData drawbrush, smoothbrush, pinchbrush, inflatebrush, grabbrush, layerbrush, flattenbrush;
+ struct Brush *brush;
/* For rotating around a pivot point */
float pivot[3];
- short brush_type;
+ int flags;
/* For the Brush Shape */
short texact, texnr;
short spacing;
char texrept;
- char texfade;
char texsep;
char averaging;
- char flags;
/* Control tablet input */
char tablet_size, tablet_strength;
-
- /* Symmetry is separate from the other BrushData because the same
- settings are always used for all brush types */
- char symm;
- /* Added to store if the 'Rake' setting has been set */
- char rake;
- char axislock;
- char pad[2];
+ char pad[5];
} SculptData;
typedef struct Scene {
@@ -800,34 +776,21 @@ typedef struct Scene {
#define FFMPEG_MULTIPLEX_AUDIO 1
#define FFMPEG_AUTOSPLIT_OUTPUT 2
-/* Sculpt brush flags */
-#define SCULPT_BRUSH_AIRBRUSH 1
-#define SCULPT_BRUSH_ANCHORED 2
/* SculptData.flags */
-#define SCULPT_INPUT_SMOOTH 1
-#define SCULPT_DRAW_FAST 2
-#define SCULPT_DRAW_BRUSH 4
-/* SculptData.brushtype */
-#define DRAW_BRUSH 1
-#define SMOOTH_BRUSH 2
-#define PINCH_BRUSH 3
-#define INFLATE_BRUSH 4
-#define GRAB_BRUSH 5
-#define LAYER_BRUSH 6
-#define FLATTEN_BRUSH 7
+#define SCULPT_SYMM_X 1
+#define SCULPT_SYMM_Y 2
+#define SCULPT_SYMM_Z 4
+#define SCULPT_INPUT_SMOOTH 8
+#define SCULPT_DRAW_FAST 16
+#define SCULPT_DRAW_BRUSH 32
+#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
-#define SYMM_X 1
-#define SYMM_Y 2
-#define SYMM_Z 4
-
-#define AXISLOCK_X 1
-#define AXISLOCK_Y 2
-#define AXISLOCK_Z 4
-
/* toolsettings->imagepaint_flag */
#define IMAGEPAINT_DRAWING 1
#define IMAGEPAINT_DRAW_TOOL 2