Revision: 29869
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=29869
Author:   jwilkins
Date:     2010-07-02 12:25:46 +0200 (Fri, 02 Jul 2010)

Log Message:
-----------
* Bug Fix: brush angle corrections

Modified Paths:
--------------
    
branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/paint_stroke.c
    branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/sculpt.c

Modified: 
branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/paint_stroke.c
===================================================================
--- 
branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/paint_stroke.c   
    2010-07-02 09:51:38 UTC (rev 29868)
+++ 
branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/paint_stroke.c   
    2010-07-02 10:25:46 UTC (rev 29869)
@@ -239,9 +239,8 @@
                        /* it is probably worth optimizing for those cases 
where 
                           the texture is not rotated by skipping the calls to
                           atan2, sqrtf, sin, and cos. */
-                       /* epsilon good as long as precision of angle control 
is 0.001 */
                        if (rotation > 0.001 || rotation < -0.001) {
-                               const float angle    = atan2(x, y) - rotation;
+                               const float angle    = atan2(y, x) + rotation;
                                const float flen     = sqrtf(x*x + y*y);
 
                                x = flen * cos(angle);

Modified: 
branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/sculpt.c
===================================================================
--- branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/sculpt.c     
2010-07-02 09:51:38 UTC (rev 29868)
+++ branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/sculpt.c     
2010-07-02 10:25:46 UTC (rev 29869)
@@ -613,7 +613,6 @@
                        return alpha * flip * pressure * overlap;
 
                case SCULPT_TOOL_CREASE:
-               case SCULPT_TOOL_BLOB:
                        return alpha * flip * pressure * overlap;
 
                case SCULPT_TOOL_INFLATE:
@@ -803,9 +802,8 @@
                /* it is probably worth optimizing for those cases where 
                   the texture is not rotated by skipping the calls to
                   atan2, sqrtf, sin, and cos. */
-               /* epsilon good as long as precision of angle control is 0.001 
*/
                if (rotation > 0.001 || rotation < -0.001) {
-                       const float angle    = atan2(x, y) - rotation;
+                       const float angle    = atan2(y, x) + rotation;
                        const float flen     = sqrtf(x*x + y*y);
 
                        x = flen * cos(angle);
@@ -1291,7 +1289,7 @@
        Brush *brush = paint_brush(&sd->paint);
        float offset[3], area_normal[3];
        float bstrength= ss->cache->bstrength;
-       float flippedbstrength, crease_correction;
+       float flippedbstrength;
        int n;
        
        calc_area_normal(sd, ss, area_normal, nodes, totnode);
@@ -1299,20 +1297,11 @@
        /* offset with as much as possible factored in already */
        mul_v3_v3fl(offset, area_normal, ss->cache->radius);
        mul_v3_v3(offset, ss->cache->scale);
-       mul_v3_fl(offset, bstrength);
-       
-       /* we divide out the squared alpha and multiply by the squared crease 
to give us the pinch strength */
-       
-       if(brush->alpha > 0.0f)
-               crease_correction = 
brush->crease_pinch_factor*brush->crease_pinch_factor/(brush->alpha*brush->alpha);
-       else
-               crease_correction = 
brush->crease_pinch_factor*brush->crease_pinch_factor;
+       mul_v3_fl(offset, bstrength*(1-brush->crease_pinch_factor));
 
-       /* we always want crease to pinch or blob to relax even when draw is 
negative */
-       flippedbstrength = (bstrength < 0) ? -crease_correction*bstrength : 
crease_correction*bstrength;
+       /* we always want crease to pinch even when draw is negative also 
crease we want stronger than the draw effect*/
+       flippedbstrength = (bstrength < 0) ? 
-brush->crease_pinch_factor*bstrength : brush->crease_pinch_factor*bstrength;
 
-       if(brush->sculpt_tool == SCULPT_TOOL_BLOB) flippedbstrength *= -1.0f;
-       
        /* threaded loop over nodes */
        #pragma omp parallel for schedule(guided) if (sd->flags & 
SCULPT_USE_OPENMP)
        for(n=0; n<totnode; n++) {
@@ -2346,9 +2335,6 @@
                case SCULPT_TOOL_CREASE:
                        do_crease_brush(sd, ss, nodes, totnode);
                        break;
-               case SCULPT_TOOL_BLOB:
-                       do_crease_brush(sd, ss, nodes, totnode);
-                       break;
                case SCULPT_TOOL_PINCH:
                        do_pinch_brush(sd, ss, nodes, totnode);
                        break;
@@ -2449,7 +2435,6 @@
                case SCULPT_TOOL_DRAW:
                case SCULPT_TOOL_CLAY:
                case SCULPT_TOOL_CREASE:
-               case SCULPT_TOOL_BLOB:
                case SCULPT_TOOL_FILL:
                case SCULPT_TOOL_FLATTEN:
                case SCULPT_TOOL_INFLATE:
@@ -2630,8 +2615,6 @@
                return "Smooth Brush"; break;
        case SCULPT_TOOL_CREASE:
                return "Crease Brush"; break;
-       case SCULPT_TOOL_BLOB:
-               return "Blob Brush"; break;
        case SCULPT_TOOL_PINCH:
                return "Pinch Brush"; break;
        case SCULPT_TOOL_INFLATE:
@@ -2848,7 +2831,7 @@
                cache->original = 1;
        }
 
-       if(ELEM7(brush->sculpt_tool, SCULPT_TOOL_DRAW,  SCULPT_TOOL_CREASE, 
SCULPT_TOOL_BLOB, SCULPT_TOOL_LAYER, SCULPT_TOOL_INFLATE, SCULPT_TOOL_CLAY, 
SCULPT_TOOL_WAX))
+       if(ELEM6(brush->sculpt_tool, SCULPT_TOOL_DRAW,  SCULPT_TOOL_CREASE, 
SCULPT_TOOL_LAYER, SCULPT_TOOL_INFLATE, SCULPT_TOOL_CLAY, SCULPT_TOOL_WAX))
                if(!(brush->flag & BRUSH_ACCUMULATE))
                        cache->original = 1;
 


_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to