diff options
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_mball.h | 17 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/mball.c | 67 |
2 files changed, 52 insertions, 32 deletions
diff --git a/source/blender/blenkernel/BKE_mball.h b/source/blender/blenkernel/BKE_mball.h index fc065279aa3..0c2a3c28da9 100644 --- a/source/blender/blenkernel/BKE_mball.h +++ b/source/blender/blenkernel/BKE_mball.h @@ -22,6 +22,7 @@ /** \file * \ingroup bke */ +struct Base; struct BoundBox; struct Depsgraph; struct Main; @@ -39,7 +40,7 @@ struct MetaBall *BKE_mball_copy(struct Main *bmain, const struct MetaBall *mb); void BKE_mball_make_local(struct Main *bmain, struct MetaBall *mb, const bool lib_local); bool BKE_mball_is_any_selected(const struct MetaBall *mb); -bool BKE_mball_is_any_selected_multi(struct Object **objects, int objects_len); +bool BKE_mball_is_any_selected_multi(struct Base **bases, int bases_len); bool BKE_mball_is_any_unselected(const struct MetaBall *mb); bool BKE_mball_is_basis_for(struct Object *ob1, struct Object *ob2); bool BKE_mball_is_basis(struct Object *ob); @@ -63,13 +64,13 @@ 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(const 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); -void BKE_mball_deselect_all_multi(struct Object **objects, int objects_len); -void BKE_mball_select_swap(struct MetaBall *mb); -void BKE_mball_select_swap_multi(struct Object **objects, int objects_len); +int BKE_mball_select_count_multi(struct Base **bases, int bases_len); +bool BKE_mball_select_all(struct MetaBall *mb); +bool BKE_mball_select_all_multi_ex(struct Base **bases, int bases_len); +bool BKE_mball_deselect_all(struct MetaBall *mb); +bool BKE_mball_deselect_all_multi_ex(struct Base **bases, int bases_len); +bool BKE_mball_select_swap(struct MetaBall *mb); +bool BKE_mball_select_swap_multi_ex(struct Base **bases, int bases_len); /* **** Depsgraph evaluation **** */ diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index d8aabcb6258..6a28c341fac 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -331,10 +331,10 @@ bool BKE_mball_is_any_selected(const MetaBall *mb) } -bool BKE_mball_is_any_selected_multi(Object **objects, int objects_len) +bool BKE_mball_is_any_selected_multi(Base **bases, int bases_len) { - for (uint ob_index = 0; ob_index < objects_len; ob_index++) { - Object *obedit = objects[ob_index]; + for (uint base_index = 0; base_index < bases_len; base_index++) { + Object *obedit = bases[base_index]->object; MetaBall *mb = (MetaBall *)obedit->data; if (BKE_mball_is_any_selected(mb)) { return true; @@ -559,64 +559,83 @@ int BKE_mball_select_count(const MetaBall *mb) return sel; } -int BKE_mball_select_count_multi(Object **objects, int objects_len) +int BKE_mball_select_count_multi(Base **bases, int bases_len) { int sel = 0; - for (uint ob_index = 0; ob_index < objects_len; ob_index++) { - const Object *obedit = objects[ob_index]; + for (uint ob_index = 0; ob_index < bases_len; ob_index++) { + const Object *obedit = bases[ob_index]->object; const MetaBall *mb = (MetaBall *)obedit->data; sel += BKE_mball_select_count(mb); } return sel; } -void BKE_mball_select_all(MetaBall *mb) +bool BKE_mball_select_all(MetaBall *mb) { + bool changed = false; for (MetaElem *ml = mb->editelems->first; ml; ml = ml->next) { - ml->flag |= SELECT; + if ((ml->flag & SELECT) == 0) { + ml->flag |= SELECT; + changed = true; + } } + return changed; } -void BKE_mball_select_all_multi(Object **objects, int objects_len) +bool BKE_mball_select_all_multi_ex(Base **bases, int bases_len) { - for (uint ob_index = 0; ob_index < objects_len; ob_index++) { - Object *obedit = objects[ob_index]; + bool changed_multi = false; + for (uint ob_index = 0; ob_index < bases_len; ob_index++) { + Object *obedit = bases[ob_index]->object; MetaBall *mb = obedit->data; - BKE_mball_select_all(mb); + changed_multi |= BKE_mball_select_all(mb); } + return changed_multi; } -void BKE_mball_deselect_all(MetaBall *mb) +bool BKE_mball_deselect_all(MetaBall *mb) { + bool changed = false; for (MetaElem *ml = mb->editelems->first; ml; ml = ml->next) { - ml->flag &= ~SELECT; + if ((ml->flag & SELECT) != 0) { + ml->flag &= ~SELECT; + changed = true; + } } + return changed; } -void BKE_mball_deselect_all_multi(Object **objects, int objects_len) +bool BKE_mball_deselect_all_multi_ex(Base **bases, int bases_len) { - for (uint ob_index = 0; ob_index < objects_len; ob_index++) { - Object *obedit = objects[ob_index]; + bool changed_multi = false; + for (uint ob_index = 0; ob_index < bases_len; ob_index++) { + Object *obedit = bases[ob_index]->object; MetaBall *mb = obedit->data; - - BKE_mball_deselect_all(mb); + changed_multi |= BKE_mball_deselect_all(mb); + DEG_id_tag_update(&mb->id, ID_RECALC_SELECT); } + return changed_multi; } -void BKE_mball_select_swap(MetaBall *mb) +bool BKE_mball_select_swap(MetaBall *mb) { + bool changed = false; for (MetaElem *ml = mb->editelems->first; ml; ml = ml->next) { ml->flag ^= SELECT; + changed = true; } + return changed; } -void BKE_mball_select_swap_multi(Object **objects, int objects_len) +bool BKE_mball_select_swap_multi_ex(Base **bases, int bases_len) { - for (uint ob_index = 0; ob_index < objects_len; ob_index++) { - Object *obedit = objects[ob_index]; + bool changed_multi = false; + for (uint ob_index = 0; ob_index < bases_len; ob_index++) { + Object *obedit = bases[ob_index]->object; MetaBall *mb = (MetaBall *)obedit->data; - BKE_mball_select_swap(mb); + changed_multi |= BKE_mball_select_swap(mb); } + return changed_multi; } /* **** Depsgraph evaluation **** */ |