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:
authorDalai Felinto <dfelinto@gmail.com>2018-11-09 19:26:58 +0300
committerDalai Felinto <dfelinto@gmail.com>2018-11-09 21:40:43 +0300
commit221d07864128687858634aebcfb27798a494557a (patch)
tree98b2dd0bafce927616716b8a0c33f0c9ca0612e9 /source/blender/editors/space_view3d/view3d_select.c
parent983a928e1d481dd91c36f597e2c39daba6d0f8ad (diff)
Multi-Objects Metaball: Selection refactor - fix pick and box selection
This is inspired/based on the code we use for armature bone selection. Both pick selection, and box selection should be working now.
Diffstat (limited to 'source/blender/editors/space_view3d/view3d_select.c')
-rw-r--r--source/blender/editors/space_view3d/view3d_select.c46
1 files changed, 35 insertions, 11 deletions
diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c
index 230bbd11450..c421c96e530 100644
--- a/source/blender/editors/space_view3d/view3d_select.c
+++ b/source/blender/editors/space_view3d/view3d_select.c
@@ -2169,7 +2169,8 @@ static int do_meta_box_select(
ViewContext *vc,
const rcti *rect, const eSelectOp sel_op)
{
- MetaBall *mb = (MetaBall *)vc->obedit->data;
+ Object *ob = vc->obedit;
+ MetaBall *mb = (MetaBall *)ob->data;
MetaElem *ml;
int a;
@@ -2184,27 +2185,50 @@ static int do_meta_box_select(
BKE_mball_deselect_all(mb);
}
- for (ml = mb->editelems->first; ml; ml = ml->next) {
- bool is_inside_1 = false;
- bool is_inside_2 = false;
+ int metaelem_id = 0;
+ for (ml = mb->editelems->first; ml; ml = ml->next, metaelem_id += 0x10000) {
+ bool is_inside_radius = false;
+ bool is_inside_stiff = false;
+
for (a = 0; a < hits; a++) {
- if (ml->selcol1 == buffer[(4 * a) + 3]) {
- is_inside_1 = true;
+ int hitresult = buffer[(4 * a) + 3];
+
+ if (hitresult == -1) {
+ continue;
+ }
+ else if (hitresult & MBALL_NOSEL) {
+ continue;
+ }
+
+ const uint hit_object = hitresult & 0xFFFF;
+ if (vc->obedit->select_color != hit_object) {
+ continue;
+ }
+
+ if (metaelem_id != (hitresult & 0xFFFF0000 & ~(MBALLSEL_ANY))) {
+ continue;
+ }
+
+ if (hitresult & MBALLSEL_RADIUS) {
+ is_inside_radius = true;
break;
}
- if (ml->selcol2 == buffer[(4 * a) + 3]) {
- is_inside_2 = true;
+
+ if (hitresult & MBALLSEL_STIFF) {
+ is_inside_stiff = true;
break;
}
}
- if (is_inside_1) {
+ if (is_inside_radius) {
ml->flag |= MB_SCALE_RAD;
}
- if (is_inside_2) {
+ if (is_inside_stiff) {
ml->flag &= ~MB_SCALE_RAD;
}
+
const bool is_select = (ml->flag & SELECT);
- const bool is_inside = is_inside_1 || is_inside_2;
+ const bool is_inside = is_inside_radius || is_inside_stiff;
+
const int sel_op_result = ED_select_op_action_deselected(sel_op, is_select, is_inside);
if (sel_op_result != -1) {
SET_FLAG_FROM_TEST(ml->flag, sel_op_result, SELECT);