Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntony Riakiotakis <kalast@gmail.com>2013-10-27 07:31:19 +0400
committerAntony Riakiotakis <kalast@gmail.com>2013-10-27 07:31:19 +0400
commitaed672ac1e1363b3fd4a7b5cbd415f5eda167306 (patch)
tree31c612ef317c627811a8e9d004c31d259623ef59 /source/blender/editors/sculpt_paint
parent01da2c0e53e8a3faf08375027ced7e7fb153726b (diff)
Border select for sculpting, using B shortcut, warmup for more advanced
masking, like lasso selection.
Diffstat (limited to 'source/blender/editors/sculpt_paint')
-rw-r--r--source/blender/editors/sculpt_paint/paint_intern.h1
-rw-r--r--source/blender/editors/sculpt_paint/paint_mask.c71
2 files changed, 72 insertions, 0 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h
index 2545328ec65..86b223ec2a0 100644
--- a/source/blender/editors/sculpt_paint/paint_intern.h
+++ b/source/blender/editors/sculpt_paint/paint_intern.h
@@ -264,5 +264,6 @@ typedef enum {
} PaintMaskFloodMode;
void PAINT_OT_mask_flood_fill(struct wmOperatorType *ot);
+void PAINT_OT_mask_box_fill(struct wmOperatorType *ot);
#endif /* __PAINT_INTERN_H__ */
diff --git a/source/blender/editors/sculpt_paint/paint_mask.c b/source/blender/editors/sculpt_paint/paint_mask.c
index 8767b080355..13f11c8a816 100644
--- a/source/blender/editors/sculpt_paint/paint_mask.c
+++ b/source/blender/editors/sculpt_paint/paint_mask.c
@@ -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 @@ void PAINT_OT_mask_flood_fill(struct wmOperatorType *ot)
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;
+}