Revision: 29232
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=29232
Author:   jwilkins
Date:     2010-06-05 05:14:34 +0200 (Sat, 05 Jun 2010)

Log Message:
-----------
* disabling symmetry feathering and clipping.  more research is needed before I 
can make it work right, dropping it until later
* "Lock Brush Size" takes the current brush size, and keeps it the same size no 
matter how the object is viewed.
* Zooming in and out dynamically resizes the brush retical.  This also lays the 
foundation for a fancy brush retical ala Sculptris
* commented out a couple of unused fields from struct Sculpt.  This struct adds 
so little, should be unified with Paint later
* made the hard limit for brush size 1-2000, to allow it to grow to larger than 
the screen when using lock size.  UI soft limit is still 1-200

Modified Paths:
--------------
    branches/soc-2010-jwilkins/release/scripts/ui/space_view3d_toolbar.py
    branches/soc-2010-jwilkins/source/blender/blenkernel/BKE_paint.h
    branches/soc-2010-jwilkins/source/blender/blenloader/intern/readfile.c
    
branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/paint_stroke.c
    branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/sculpt.c
    
branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/sculpt_intern.h
    branches/soc-2010-jwilkins/source/blender/makesdna/DNA_brush_types.h
    branches/soc-2010-jwilkins/source/blender/makesdna/DNA_scene_types.h
    branches/soc-2010-jwilkins/source/blender/makesrna/intern/rna_brush.c

Modified: branches/soc-2010-jwilkins/release/scripts/ui/space_view3d_toolbar.py
===================================================================
--- branches/soc-2010-jwilkins/release/scripts/ui/space_view3d_toolbar.py       
2010-06-05 00:21:26 UTC (rev 29231)
+++ branches/soc-2010-jwilkins/release/scripts/ui/space_view3d_toolbar.py       
2010-06-05 03:14:34 UTC (rev 29232)
@@ -547,7 +547,11 @@
             col.separator()
 
             row = col.row(align=True)
+            row.prop(brush, "lock_brush_size")
+
+            row = col.row(align=True)
             row.prop(brush, "size", slider=True)
+            row.active = not brush.lock_brush_size
 
             if brush.sculpt_tool != 'GRAB':
                 row.prop(brush, "use_size_pressure", toggle=True, text="")
@@ -815,7 +819,7 @@
         col.prop(sculpt, "symmetry_x", text="X")
         col.prop(sculpt, "symmetry_y", text="Y")
         col.prop(sculpt, "symmetry_z", text="Z")
-        col.prop(sculpt, "use_symmetry_feather", text="Feather")
+        #col.prop(sculpt, "use_symmetry_feather", text="Feather")
 
         col = split.column()
         col.label(text="Lock:")

Modified: branches/soc-2010-jwilkins/source/blender/blenkernel/BKE_paint.h
===================================================================
--- branches/soc-2010-jwilkins/source/blender/blenkernel/BKE_paint.h    
2010-06-05 00:21:26 UTC (rev 29231)
+++ branches/soc-2010-jwilkins/source/blender/blenkernel/BKE_paint.h    
2010-06-05 03:14:34 UTC (rev 29232)
@@ -74,7 +74,7 @@
        
        struct Scene *scene; //Mio
        struct EditMesh *em; //Mio  
-                       
+
        /* Mesh connectivity */
        struct ListBase *fmap;
 

Modified: branches/soc-2010-jwilkins/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/soc-2010-jwilkins/source/blender/blenloader/intern/readfile.c      
2010-06-05 00:21:26 UTC (rev 29231)
+++ branches/soc-2010-jwilkins/source/blender/blenloader/intern/readfile.c      
2010-06-05 03:14:34 UTC (rev 29232)
@@ -10914,8 +10914,8 @@
                for (brush= main->brush.first; brush; brush= brush->id.next) {
                        if(brush->detail == 0.0f)
                                brush->detail = 0.25f;
-               if (brush->smoothness == 0.0f)
-                       brush->smoothness = 0.25f;
+                       if (brush->smoothness == 0.0f)
+                               brush->smoothness = 0.25f;
                }
        }
 

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-06-05 00:21:26 UTC (rev 29231)
+++ 
branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/paint_stroke.c   
    2010-06-05 03:14:34 UTC (rev 29232)
@@ -49,6 +49,7 @@
 #include "ED_view3d.h"
 
 #include "paint_intern.h"
+#include "sculpt_intern.h" // XXX, for expedience in getting this working, 
refactor later (or this just shows that this needs unification)
 
 #include <float.h>
 #include <math.h>
@@ -96,14 +97,107 @@
        glDisable(GL_LINE_SMOOTH);
 }
 
+/* Convert a point in model coordinates to 2D screen coordinates. */
+// XXX duplicated from sculpt.c, deal with this later.
+static void projectf(bglMats *mats, const float v[3], float p[2])
+{
+       double ux, uy, uz;
+
+       gluProject(v[0],v[1],v[2], mats->modelview, mats->projection,
+                  (GLint *)mats->viewport, &ux, &uy, &uz);
+       p[0]= ux;
+       p[1]= uy;
+}
+
+static int project_brush_radius(RegionView3D* rv3d, float radius, float 
location[3], bglMats* mats)
+{
+       float view[3], nonortho[3], ortho[3], offset[3], p1[2], p2[2];
+
+       viewvector(rv3d, location, view);
+
+       // create a vector that is not orthogonal to view
+
+       if (fabsf(view[0]) < 0.1) {
+               nonortho[0] = view[0] + 1;
+               nonortho[1] = view[1];
+               nonortho[2] = view[2];
+       }
+       else if (fabsf(view[1]) < 0.1) {
+               nonortho[0] = view[0];
+               nonortho[1] = view[1] + 1;
+               nonortho[2] = view[2];
+       }
+       else {
+               nonortho[0] = view[0];
+               nonortho[1] = view[1];
+               nonortho[2] = view[2] + 1;
+       }
+
+       // get a vector in the plane of the view
+       cross_v3_v3v3(ortho, nonortho, view);
+       normalize_v3(ortho);
+
+       // make a point on the surface of the brush tagent to the view
+       mul_v3_fl(ortho, radius);
+       add_v3_v3v3(offset, location, ortho);
+
+       // project the center of the brush, and the tagent point to the view 
onto the screen
+       projectf(mats, location, p1);
+       projectf(mats, offset, p2);
+
+       // the distance between these points is the size of the projected brush 
in pixels
+       return len_v2v2(p1, p2);
+}
+
+static void sculpt_set_brush_radius(Brush *brush, int value)
+{
+       PointerRNA brushptr;
+       PropertyRNA *size;
+
+       /* brush.size = value */
+
+       RNA_id_pointer_create(&brush->id, &brushptr);
+
+       size= RNA_struct_find_property(&brushptr, "size");
+       RNA_property_int_set(&brushptr, size, value);
+}
+
+static int sculpt_get_brush_radius(bContext* C, int mouse[2])
+{
+       int radius;
+       struct PaintStroke *stroke;
+       float location[3], window[2];
+
+       stroke = paint_stroke_new(C, NULL, NULL, NULL, NULL);
+
+       window[0] = mouse[0] + stroke->vc.ar->winrct.xmin;
+       window[1] = mouse[1] + stroke->vc.ar->winrct.ymin;
+
+       if (stroke->vc.obact->sculpt->pbvh && sculpt_stroke_get_location(C, 
stroke, location, window)) {
+               radius = project_brush_radius(stroke->vc.rv3d, 
stroke->brush->unprojected_radius, location, &stroke->mats);
+       }
+       else {
+               Sculpt* sd    = CTX_data_tool_settings(C)->sculpt;
+               Brush*  brush = paint_brush(&sd->paint);
+
+               radius = brush->size;
+       }
+
+       paint_stroke_free(stroke);
+
+       return radius;
+}
+
 static void paint_draw_cursor(bContext *C, int x, int y, void *customdata)
 {
+       int mouse[3] = { x, y };
        Paint *paint = paint_get_active(CTX_data_scene(C));
        Brush *brush = paint_brush(paint);
 
-       if(!(paint->flags & PAINT_SHOW_BRUSH))
-               return;
+       if(!(paint->flags & PAINT_SHOW_BRUSH)) return;
 
+       if (brush->flag & BRUSH_LOCK_SIZE) sculpt_set_brush_radius(brush, 
sculpt_get_brush_radius(C, mouse));
+
        glColor4ubv(paint_get_active(CTX_data_scene(C))->paint_cursor_col);
        glEnable(GL_LINE_SMOOTH);
        glEnable(GL_BLEND);

Modified: 
branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/sculpt.c
===================================================================
--- branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/sculpt.c     
2010-06-05 00:21:26 UTC (rev 29231)
+++ branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/sculpt.c     
2010-06-05 03:14:34 UTC (rev 29232)
@@ -541,51 +541,62 @@
        float location[3];
 
        float dist;
+
+       //float true_location[3];
+       //int symmetry;
+       //int symmetry_pass;
 } SculptBrushTest;
 
 static void sculpt_brush_test_init(SculptSession *ss, SculptBrushTest *test)
 {
        test->radius_squared= ss->cache->radius*ss->cache->radius;
        copy_v3_v3(test->location, ss->cache->location);
+
+       //copy_v3_v3(test->true_location, ss->cache->true_location);
+       //test->symmetry = ss->cache->symmetry;
+       //test->symmetry_pass = ss->cache->symmetry_pass;
 }
 
-//static int sculpt_brush_test_clip(SculptBrushTest* test, float co[3])
-//{
-//     if (test->symmetry) {
-//             int i;
-//
-//             for (i = 0; i < 3; i++) {
-//                     if (test->symmetry & (1<<i)) {
-//                             if (test->symmetry_pass & (1<<i)) {
-//                                     if (test->true_location[i] > 0) {
-//                                             if (co[i] > 0) return 0;
-//                                     }
-//                                     else if (test->true_location[i] < 0) {
-//                                             if (co[i] < 0) return 0;
-//                                     }
-//                             }
-//                             else {
-//                                     if (test->true_location[i] > 0) {
-//                                             if (co[i] < 0) return 0;
-//                                     }
-//                                     else if (test->true_location[i] < 0) {
-//                                             if (co[i] > 0) return 0;
-//                                     }
-//                             }
-//                     }
-//             }
-//     }
-//
-//     return 1;
-//}
+static int sculpt_brush_test_clip(SculptBrushTest* test, float co[3])
+{
+       //if (test->symmetry) {
+       //      int i;
 
+       //      for (i = 0; i < 3; i++) {
+       //              if (test->symmetry_pass & (1<<i)) {
+       //                      if (test->true_location[i] >= 0) {
+       //                              if (co[i] >= 0) return 0;
+       //                      }
+       //                      else if (test->true_location[i] < 0) {
+       //                              if (co[i] < 0) return 0;
+       //                      }
+       //              }
+       //              else {
+       //                      if (test->true_location[i] >= 0) {
+       //                              if (co[i] < 0) return 0;
+       //                      }
+       //                      else if (test->true_location[i] < 0) {
+       //                              if (co[i] >= 0) return 0;
+       //                      }
+       //              }
+       //      }
+       //}
+
+       return 1;
+}
+
 static int sculpt_brush_test(SculptBrushTest *test, float co[3])
 {
-       float distsq = len_squared_v3v3(co, test->location);
+       if (sculpt_brush_test_clip(test, co)) {
+               float distsq = len_squared_v3v3(co, test->location);
 
-       if(distsq < test->radius_squared) {
-               test->dist = sqrt(distsq);
-               return 1;
+               if(distsq < test->radius_squared) {
+                       test->dist = sqrt(distsq);
+                       return 1;
+               }
+               else {
+                       return 0;
+               }
        }
        else {
                return 0;
@@ -594,11 +605,16 @@
 
 static int sculpt_brush_test_sq(SculptBrushTest *test, float co[3])
 {
-       float distsq = len_squared_v3v3(co, test->location);
+       if (sculpt_brush_test_clip(test, co)) {
+               float distsq = len_squared_v3v3(co, test->location);
 
-       if(distsq < test->radius_squared) {
-               test->dist = distsq;
-               return 1;
+               if(distsq < test->radius_squared) {
+                       test->dist = distsq;
+                       return 1;
+               }
+               else {
+                       return 0;
+               }
        }
        else {
                return 0;
@@ -607,7 +623,12 @@
 
 static int sculpt_brush_test_fast(SculptBrushTest *test, float co[3])
 {
-       return len_squared_v3v3(co, test->location) < test->radius_squared;
+       if (sculpt_brush_test_clip(test, co)) {
+               return len_squared_v3v3(co, test->location) < 
test->radius_squared;
+       }
+       else {
+               return 0;
+       }
 }
 
 /* area of overlap of two circles of radius 1 seperated by d units from their 
centers */
@@ -1090,16 +1111,16 @@
        calc_area_normal(sd, ss, area_normal, nodes, totnode);
        
        /* offset with as much as possible factored in already */
-       offset[0]= 
area_normal[0]*ss->cache->radius*ss->cache->scale[0]*bstrength;
-       offset[1]= 
area_normal[1]*ss->cache->radius*ss->cache->scale[1]*bstrength;
-       offset[2]= 
area_normal[2]*ss->cache->radius*ss->cache->scale[2]*bstrength;
+       mul_v3_v3fl(offset, area_normal, ss->cache->radius);
+       mul_v3_v3(offset, ss->cache->scale);
+       mul_v3_fl(offset, bstrength);
 
        /* threaded loop over nodes */
        //#pragma omp parallel for private(n) schedule(static)
        for(n=0; n<totnode; n++) {
                PBVHVertexIter vd;
                SculptBrushTest test;
-               
+
                sculpt_undo_push_node(ss, nodes[n]);
                sculpt_brush_test_init(ss, &test);
 
@@ -2035,15 +2056,15 @@
                case SCULPT_TOOL_CLAY:
                        do_clay_brush(sd, ss, nodes, totnode);
                        break;
-                case SCULPT_TOOL_FILL:
-                        do_fill_brush(sd, ss, nodes, totnode);
-                        break;
-                case SCULPT_TOOL_SCRAPE:
-                        do_scrape_brush(sd, ss, nodes, totnode);

@@ Diff output truncated at 10240 characters. @@

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

Reply via email to