From 815791920f1f6172a1bf904351713c8a355da62d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 14 Apr 2008 21:37:23 +0000 Subject: terrain sculpting enhancements, axis locking and brush strength multiply by grid --- source/blender/makesdna/DNA_scene_types.h | 7 ++++++- source/blender/src/buttons_editing.c | 19 ++++++++++++++++--- source/blender/src/sculptmode.c | 29 +++++++++++++++++++++++------ 3 files changed, 45 insertions(+), 10 deletions(-) (limited to 'source/blender') diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index e5056e048ce..ed0ae803a0a 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -496,7 +496,8 @@ typedef struct SculptData /* Added to store if the 'Rake' setting has been set */ char rake; - char pad[3]; + char axislock; + char pad[2]; } SculptData; typedef struct Scene { @@ -772,6 +773,10 @@ typedef struct Scene { #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 diff --git a/source/blender/src/buttons_editing.c b/source/blender/src/buttons_editing.c index 04bab67a062..cba91ec4535 100644 --- a/source/blender/src/buttons_editing.c +++ b/source/blender/src/buttons_editing.c @@ -5528,11 +5528,24 @@ void sculptmode_draw_interface_tools(uiBlock *block, unsigned short cx, unsigned uiDefBut( block,LABEL,B_NOP,"Symmetry",cx,cy,90,19,NULL,0,0,0,0,""); cy-= 20; uiBlockBeginAlign(block); - uiDefButBitC(block, TOG, SYMM_X, 0, "X", cx,cy,89,19, &sd->symm, 0,0,0,0, "Mirror brush across X axis"); - uiDefButBitC(block, TOG, SYMM_Y, 0, "Y", cx+89,cy,89,19, &sd->symm, 0,0,0,0, "Mirror brush across Y axis"); - uiDefButBitC(block, TOG, SYMM_Z, 0, "Z", cx+178,cy,90,19, &sd->symm, 0,0,0,0, "Mirror brush across Z axis"); + uiDefButBitC(block, TOG, SYMM_X, 0, "X", cx,cy,40,19, &sd->symm, 0,0,0,0, "Mirror brush across X axis"); + uiDefButBitC(block, TOG, SYMM_Y, 0, "Y", cx+40,cy,40,19, &sd->symm, 0,0,0,0, "Mirror brush across Y axis"); + uiDefButBitC(block, TOG, SYMM_Z, 0, "Z", cx+80,cy,40,19, &sd->symm, 0,0,0,0, "Mirror brush across Z axis"); uiBlockEndAlign(block); + + cy+= 20; + uiBlockBeginAlign(block); + uiDefBut( block,LABEL,B_NOP,"LockAxis",cx+140,cy,90,19,NULL,0,0,0,0,""); + cy-= 20; + uiBlockBeginAlign(block); + uiDefButBitC(block, TOG, AXISLOCK_X, 0, "X", cx+140,cy,40,19, &sd->axislock, 0,0,0,0, "Constrain X axis"); + uiDefButBitC(block, TOG, AXISLOCK_Y, 0, "Y", cx+180,cy,40,19, &sd->axislock, 0,0,0,0, "Constrain Y axis"); + uiDefButBitC(block, TOG, AXISLOCK_Z, 0, "Z", cx+220,cy,40,19, &sd->axislock, 0,0,0,0, "Constrain Z axis"); + uiBlockEndAlign(block); + + + cx+= 210; } diff --git a/source/blender/src/sculptmode.c b/source/blender/src/sculptmode.c index 0bcf66a926f..3b46d79513c 100644 --- a/source/blender/src/sculptmode.c +++ b/source/blender/src/sculptmode.c @@ -390,7 +390,7 @@ float brush_strength(BrushAction *a) switch(G.scene->sculptdata.brush_type){ case DRAW_BRUSH: case LAYER_BRUSH: - return b->strength / 5000.0f * dir * pressure * flip * anchored; + return b->strength / 5000.0f * dir * pressure * flip * anchored * G.vd->grid; case SMOOTH_BRUSH: return b->strength / 50.0f * pressure * anchored; case PINCH_BRUSH: @@ -418,6 +418,15 @@ 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->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; +} + static void add_norm_if(const BrushAction *a, float out[3], float out_flip[3], const short no[3]) { float fno[3] = {no[0], no[1], no[2]}; @@ -437,7 +446,8 @@ void calc_area_normal(float out[3], const BrushAction *a, const float *outdir, c { Mesh *me = get_mesh(OBACT); ActiveData *node = active_verts->first; - const int view = sculpt_data()->brush_type==DRAW_BRUSH ? sculptmode_brush()->view : 0; + SculptData *sd = sculpt_data(); + const int view = sd->brush_type==DRAW_BRUSH ? sculptmode_brush()->view : 0; float out_flip[3]; out[0]=out[1]=out[2] = out_flip[0]=out_flip[1]=out_flip[2] = 0; @@ -462,7 +472,7 @@ void calc_area_normal(float out[3], const BrushAction *a, const float *outdir, c out[1] = outdir[1] * view + out[1] * (10-view); out[2] = outdir[2] * view + out[2] * (10-view); } - + Normalize(out); } @@ -473,7 +483,9 @@ void do_draw_brush(const BrushAction *a, const ListBase* active_verts) ActiveData *node= active_verts->first; calc_area_normal(area_normal, a, a->symm.out, active_verts); - + + sculpt_axislock(area_normal); + while(node){ float *co= me->mvert[node->Index].co; @@ -573,17 +585,22 @@ void do_grab_brush(BrushAction *a) Mesh *me= get_mesh(OBACT); ActiveData *node= a->grab_active_verts[a->symm.index].first; float add[3]; - + float grab_delta[3]; + + VecCopyf(grab_delta, a->symm.grab_delta); + sculpt_axislock(grab_delta); + while(node) { float *co= me->mvert[node->Index].co; - VecCopyf(add, a->symm.grab_delta); + VecCopyf(add, grab_delta); VecMulf(add, node->Fade); VecAddf(add, add, co); sculpt_clip(a, co, add); node= node->next; } + } void do_layer_brush(BrushAction *a, const ListBase *active_verts) -- cgit v1.2.3