diff options
author | Ines Almeida <britalmeida@gmail.com> | 2018-05-22 17:34:53 +0300 |
---|---|---|
committer | Ines Almeida <britalmeida@gmail.com> | 2018-05-22 17:44:34 +0300 |
commit | 8644eef5c309ee2b28f6e6935e98e88bb6732633 (patch) | |
tree | 67fe6e843e716337ae06d9242724f2aaca539034 /source/blender/blenkernel | |
parent | 397665dea3b904fe41ccceee09aeb0132c9674f1 (diff) |
COw operators: Fix VIEW3D_OT_snap_selected_to_grid
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_layer.h | 13 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/layer.c | 36 |
2 files changed, 48 insertions, 1 deletions
diff --git a/source/blender/blenkernel/BKE_layer.h b/source/blender/blenkernel/BKE_layer.h index ca6806a98c6..9daf33baf10 100644 --- a/source/blender/blenkernel/BKE_layer.h +++ b/source/blender/blenkernel/BKE_layer.h @@ -137,6 +137,10 @@ void BKE_view_layer_visible_objects_iterator_begin(BLI_Iterator *iter, void *dat void BKE_view_layer_visible_objects_iterator_next(BLI_Iterator *iter); void BKE_view_layer_visible_objects_iterator_end(BLI_Iterator *iter); +void BKE_view_layer_selected_editable_objects_iterator_begin(BLI_Iterator *iter, void *data_in); +void BKE_view_layer_selected_editable_objects_iterator_next(BLI_Iterator *iter); +void BKE_view_layer_selected_editable_objects_iterator_end(BLI_Iterator *iter); + struct ObjectsInModeIteratorData { int object_mode; struct ViewLayer *view_layer; @@ -168,6 +172,15 @@ void BKE_view_layer_visible_bases_iterator_end(BLI_Iterator *iter); #define FOREACH_SELECTED_OBJECT_END \ ITER_END +#define FOREACH_SELECTED_EDITABLE_OBJECT_BEGIN(view_layer, _instance) \ + ITER_BEGIN(BKE_view_layer_selected_editable_objects_iterator_begin, \ + BKE_view_layer_selected_editable_objects_iterator_next, \ + BKE_view_layer_selected_editable_objects_iterator_end, \ + view_layer, Object *, _instance) + +#define FOREACH_SELECTED_EDITABLE_OBJECT_END \ + ITER_END + #define FOREACH_VISIBLE_OBJECT_BEGIN(view_layer, _instance) \ ITER_BEGIN(BKE_view_layer_visible_objects_iterator_begin, \ BKE_view_layer_visible_objects_iterator_next, \ diff --git a/source/blender/blenkernel/intern/layer.c b/source/blender/blenkernel/intern/layer.c index 7bda471d3da..6d875ecb516 100644 --- a/source/blender/blenkernel/intern/layer.c +++ b/source/blender/blenkernel/intern/layer.c @@ -945,7 +945,7 @@ void BKE_view_layer_selected_objects_iterator_end(BLI_Iterator *UNUSED(iter)) /** \} */ /* -------------------------------------------------------------------- */ -/** \name BKE_view_layer_selected_objects_iterator +/** \name BKE_view_layer_visible_objects_iterator * \{ */ void BKE_view_layer_visible_objects_iterator_begin(BLI_Iterator *iter, void *data_in) @@ -966,6 +966,40 @@ void BKE_view_layer_visible_objects_iterator_end(BLI_Iterator *UNUSED(iter)) /** \} */ /* -------------------------------------------------------------------- */ +/** \name BKE_view_layer_selected_editable_objects_iterator + * \{ */ + +void BKE_view_layer_selected_editable_objects_iterator_begin(BLI_Iterator *iter, void *data_in) +{ + objects_iterator_begin(iter, data_in, BASE_SELECTED); + if (iter->valid) { + if (BKE_object_is_libdata((Object *)iter->current) == false) { + // First object is valid (selectable and not libdata) -> all good. + return; + } + else { + // Object is selectable but not editable -> search for another one. + BKE_view_layer_selected_editable_objects_iterator_next(iter); + } + } +} + +void BKE_view_layer_selected_editable_objects_iterator_next(BLI_Iterator *iter) +{ + // Search while there are objects and the one we have is not editable (editable = not libdata). + do { + objects_iterator_next(iter, BASE_SELECTED); + } while (iter->valid && BKE_object_is_libdata((Object *)iter->current) != false); +} + +void BKE_view_layer_selected_editable_objects_iterator_end(BLI_Iterator *UNUSED(iter)) +{ + /* do nothing */ +} + +/** \} */ + +/* -------------------------------------------------------------------- */ /** \name BKE_view_layer_selected_bases_iterator * \{ */ |