diff options
author | Habib Gahbiche <habibgahbiche@gmail.com> | 2018-11-07 04:36:50 +0300 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2018-11-07 05:15:39 +0300 |
commit | 5f8d3694958a8ff8ea08d5df60155dfa5796e1fa (patch) | |
tree | 6492b450e4fd9b801e916fc929bc80e0fc01a86d /source/blender/blenkernel | |
parent | ad3a2415fc8c8b6a0b57039096f4d37379975712 (diff) |
Multi-Objects: MBALL_OT_select_similar
Compared to previous implementation, the following has been changed:
* Threshold: is now an absolute value. This allows a comparison with e.g. radii
that are much larger than selected radius. This is also consistent with
`CURVE_OT_select_similar`
* Radius in world space is the average of the radius scaled in x, y and z
directions
* Since MetaBalls are symmetrical, rotation is only considered from 0 to π/2.
So for example rotations of 90° and -90° are considered equal.
This is also consistent with the way `CURVE_OT_select_similar` works.
Fix/changes from committer (Dalai Felinto):
* Drawing not updating after changes. (see original patch for details).
Reviewers: dfelinto
Differential Revision: https://developer.blender.org/D3895
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_mball.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/mball.c | 23 |
2 files changed, 25 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_mball.h b/source/blender/blenkernel/BKE_mball.h index ae86d978cb7..c09d3f3fba1 100644 --- a/source/blender/blenkernel/BKE_mball.h +++ b/source/blender/blenkernel/BKE_mball.h @@ -71,6 +71,8 @@ void BKE_mball_translate(struct MetaBall *mb, const float offset[3]); struct MetaElem *BKE_mball_element_add(struct MetaBall *mb, const int type); +int BKE_mball_select_count(struct MetaBall *mb); +int BKE_mball_select_count_multi(struct Object **objects, int objects_len); void BKE_mball_select_all(struct MetaBall *mb); void BKE_mball_select_all_multi(struct Object **objects, int objects_len); void BKE_mball_deselect_all(struct MetaBall *mb); diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index 5b1accd955d..4c634ed9140 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -561,6 +561,29 @@ void BKE_mball_translate(MetaBall *mb, const float offset[3]) } /* *** select funcs *** */ +int BKE_mball_select_count(struct MetaBall *mb) { + int sel = 0; + MetaElem *ml; + + for (ml = mb->editelems->first; ml; ml = ml->next) { + if (ml->flag & SELECT) { + sel++; + } + } + return sel; +} + +int BKE_mball_select_count_multi(Object **objects, int objects_len) { + + int sel = 0; + for (uint ob_index = 0; ob_index < objects_len; ob_index++) { + Object *obedit = objects[ob_index]; + MetaBall *mb = (MetaBall *)obedit->data; + sel += BKE_mball_select_count(mb); + } + return sel; +} + void BKE_mball_select_all(struct MetaBall *mb) { MetaElem *ml; |