Revision: 14425
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=14425
Author:   campbellbarton
Date:     2008-04-14 23:37:23 +0200 (Mon, 14 Apr 2008)

Log Message:
-----------
terrain sculpting enhancements, axis locking and brush strength multiply by grid

Modified Paths:
--------------
    trunk/blender/source/blender/makesdna/DNA_scene_types.h
    trunk/blender/source/blender/src/buttons_editing.c
    trunk/blender/source/blender/src/sculptmode.c

Modified: trunk/blender/source/blender/makesdna/DNA_scene_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_scene_types.h     2008-04-14 
20:54:20 UTC (rev 14424)
+++ trunk/blender/source/blender/makesdna/DNA_scene_types.h     2008-04-14 
21:37:23 UTC (rev 14425)
@@ -496,7 +496,8 @@
 
        /* 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 @@
 #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

Modified: trunk/blender/source/blender/src/buttons_editing.c
===================================================================
--- trunk/blender/source/blender/src/buttons_editing.c  2008-04-14 20:54:20 UTC 
(rev 14424)
+++ trunk/blender/source/blender/src/buttons_editing.c  2008-04-14 21:37:23 UTC 
(rev 14425)
@@ -5528,11 +5528,24 @@
        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;
 }
 

Modified: trunk/blender/source/blender/src/sculptmode.c
===================================================================
--- trunk/blender/source/blender/src/sculptmode.c       2008-04-14 20:54:20 UTC 
(rev 14424)
+++ trunk/blender/source/blender/src/sculptmode.c       2008-04-14 21:37:23 UTC 
(rev 14425)
@@ -390,7 +390,7 @@
        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_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 @@
 {
        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 @@
                out[1] = outdir[1] * view + out[1] * (10-view);
                out[2] = outdir[2] * view + out[2] * (10-view);
        }
-
+       
        Normalize(out);
 }
 
@@ -473,7 +483,9 @@
        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 @@
        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)


_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to