Revision: 60952
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=60952
Author:   psy-fi
Date:     2013-10-27 03:31:19 +0000 (Sun, 27 Oct 2013)
Log Message:
-----------
Border select for sculpting, using B shortcut, warmup for more advanced
masking, like lasso selection.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/include/ED_sculpt.h
    trunk/blender/source/blender/editors/sculpt_paint/paint_intern.h
    trunk/blender/source/blender/editors/sculpt_paint/paint_mask.c
    trunk/blender/source/blender/editors/space_view3d/view3d_select.c

Modified: trunk/blender/source/blender/editors/include/ED_sculpt.h
===================================================================
--- trunk/blender/source/blender/editors/include/ED_sculpt.h    2013-10-26 
22:38:12 UTC (rev 60951)
+++ trunk/blender/source/blender/editors/include/ED_sculpt.h    2013-10-27 
03:31:19 UTC (rev 60952)
@@ -37,6 +37,8 @@
 struct RegionView3D;
 struct wmKeyConfig;
 struct wmWindowManager;
+struct ViewContext;
+struct rcti;
 
 /* sculpt.c */
 void ED_operatortypes_sculpt(void);
@@ -48,6 +50,8 @@
 int ED_sculpt_minmax(struct bContext *C, float min[3], float max[3]);
 int ED_sculpt_mask_layers_ensure(struct Object *ob,
                                   struct MultiresModifierData *mmd);
+int do_sculpt_mask_box_select(struct ViewContext *vc, struct rcti *rect, bool 
select, bool extend);
+
 enum {
        ED_SCULPT_MASK_LAYER_CALC_VERT = (1 << 0),
        ED_SCULPT_MASK_LAYER_CALC_LOOP = (1 << 1)

Modified: trunk/blender/source/blender/editors/sculpt_paint/paint_intern.h
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/paint_intern.h    
2013-10-26 22:38:12 UTC (rev 60951)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_intern.h    
2013-10-27 03:31:19 UTC (rev 60952)
@@ -264,5 +264,6 @@
 } PaintMaskFloodMode;
 
 void PAINT_OT_mask_flood_fill(struct wmOperatorType *ot);
+void PAINT_OT_mask_box_fill(struct wmOperatorType *ot);
 
 #endif /* __PAINT_INTERN_H__ */

Modified: trunk/blender/source/blender/editors/sculpt_paint/paint_mask.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/paint_mask.c      
2013-10-26 22:38:12 UTC (rev 60951)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_mask.c      
2013-10-27 03:31:19 UTC (rev 60952)
@@ -36,6 +36,10 @@
 #include "DNA_meshdata_types.h"
 #include "DNA_object_types.h"
 
+#include "BIF_glutil.h"
+
+#include "BLI_math_matrix.h"
+#include "BLI_math_geom.h"
 #include "BLI_utildefines.h"
 #include "BKE_pbvh.h"
 #include "BKE_ccg.h"
@@ -53,6 +57,7 @@
 
 #include "ED_screen.h"
 #include "ED_sculpt.h"
+#include "ED_view3d.h"
 
 #include "bmesh.h"
 
@@ -148,3 +153,69 @@
        RNA_def_float(ot->srna, "value", 0, 0, 1, "Value",
                      "Mask level to use when mode is 'Value'; zero means no 
masking and one is fully masked", 0, 1);
 }
+
+/* Box select, operator is VIEW3D_OT_select_border, defined in view3d_select.c 
*/
+
+static int is_effected(float planes[4][4], const float co[3])
+{
+       return isect_point_planes_v3(planes, 4, co);
+}
+
+int do_sculpt_mask_box_select(ViewContext *vc, rcti *rect, bool select, bool 
UNUSED(extend))
+{
+       BoundBox bb;
+       bglMats mats = {{0}};
+       float clip_planes[4][4];
+       ARegion *ar = vc->ar;
+       struct Scene *scene = vc->scene;
+       Object *ob = vc->obact;
+       struct MultiresModifierData *mmd = sculpt_multires_active(scene, ob);
+       PaintMaskFloodMode mode;
+       float value;
+       DerivedMesh *dm;
+       PBVH *pbvh;
+       PBVHNode **nodes;
+       int totnode, i;
+
+       mode = PAINT_MASK_FLOOD_VALUE;
+       value = select ? 1.0 : 0.0;
+
+       /* transform the */
+       view3d_get_transformation(vc->ar, vc->rv3d, vc->obact, &mats);
+       ED_view3d_clipping_calc(&bb, clip_planes, &mats, rect);
+       mul_m4_fl(clip_planes, -1.0f);
+
+       ED_sculpt_mask_layers_ensure(ob, mmd);
+
+       dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH);
+       pbvh = dm->getPBVH(ob, dm);
+       ob->sculpt->pbvh = pbvh;
+
+       BKE_pbvh_search_gather(pbvh, BKE_pbvh_node_planes_contain_AABB, 
clip_planes, &nodes, &totnode);
+
+       sculpt_undo_push_begin("Mask box fill");
+
+       for (i = 0; i < totnode; i++) {
+               PBVHVertexIter vi;
+
+               sculpt_undo_push_node(ob, nodes[i], SCULPT_UNDO_MASK);
+
+               BKE_pbvh_vertex_iter_begin(pbvh, nodes[i], vi, 
PBVH_ITER_UNIQUE) {
+                       if (is_effected(clip_planes, vi.co))
+                               mask_flood_fill_set_elem(vi.mask, mode, value);
+               } BKE_pbvh_vertex_iter_end;
+
+               BKE_pbvh_node_mark_update(nodes[i]);
+               if (BKE_pbvh_type(pbvh) == PBVH_GRIDS)
+                       multires_mark_as_modified(ob, MULTIRES_COORDS_MODIFIED);
+       }
+
+       sculpt_undo_push_end();
+
+       if (nodes)
+               MEM_freeN(nodes);
+
+       ED_region_tag_redraw(ar);
+
+       return OPERATOR_FINISHED;
+}

Modified: trunk/blender/source/blender/editors/space_view3d/view3d_select.c
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/view3d_select.c   
2013-10-26 22:38:12 UTC (rev 60951)
+++ trunk/blender/source/blender/editors/space_view3d/view3d_select.c   
2013-10-27 03:31:19 UTC (rev 60952)
@@ -89,6 +89,7 @@
 #include "ED_mesh.h"
 #include "ED_object.h"
 #include "ED_screen.h"
+#include "ED_sculpt.h"
 #include "ED_mball.h"
 
 #include "UI_interface.h"
@@ -272,9 +273,6 @@
                        }
                }
                else {
-                       if (ob->mode & OB_MODE_SCULPT) {
-                               return 0;
-                       }
                        if ((ob->mode & (OB_MODE_VERTEX_PAINT | 
OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)) &&
                            !paint_facesel_test(ob) && !paint_vertsel_test(ob))
                        {
@@ -2125,7 +2123,7 @@
        }
        else {  /* no editmode, unified for bones and objects */
                if (vc.obact && vc.obact->mode & OB_MODE_SCULPT) {
-                       /* pass */
+                       ret = do_sculpt_mask_box_select(&vc, &rect, select, 
extend);
                }
                else if (vc.obact && paint_facesel_test(vc.obact)) {
                        ret = do_paintface_box_select(&vc, &rect, select, 
extend);

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

Reply via email to