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

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Gavrilov <angavrilov@gmail.com>2019-03-24 16:12:50 +0300
committerAlexander Gavrilov <angavrilov@gmail.com>2019-03-24 16:12:50 +0300
commit51ceed0bfbd22e8270028b593c6832505d4c49e1 (patch)
tree773db97138214201c6c8103773e6a04955751fad /rigify/utils
parentcb0a9902f57b0a5802c92be6a5a24d810e2259dc (diff)
Rigify: fix generation if a hidden collection is selected.
Only visible and selectable collections can be used for temporary objects during generation due to the way operators work.
Diffstat (limited to 'rigify/utils')
-rw-r--r--rigify/utils/collections.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/rigify/utils/collections.py b/rigify/utils/collections.py
index 25596905..5682ec64 100644
--- a/rigify/utils/collections.py
+++ b/rigify/utils/collections.py
@@ -39,6 +39,32 @@ def find_layer_collection_by_collection(layer_collection, collection):
return layer_collection
+def list_layer_collections(layer_collection, visible=False, selectable=False):
+ """Returns a list of the collection and its children, with optional filtering by settings."""
+
+ if layer_collection.exclude:
+ return []
+
+ collection = layer_collection.collection
+ is_visible = not (layer_collection.hide_viewport or collection.hide_viewport)
+ is_selectable = is_visible and not collection.hide_select
+
+ if (selectable and not is_selectable) or (visible and not is_visible):
+ return []
+
+ found = [layer_collection]
+
+ for child in layer_collection.children:
+ found += list_layer_collections(child, visible, selectable)
+
+ return found
+
+
+def filter_layer_collections_by_object(layer_collections, obj):
+ """Returns a subset of collections that contain the given object."""
+ return [lc for lc in layer_collections if obj in lc.collection.objects.values()]
+
+
def ensure_widget_collection(context):
wgts_collection_name = "Widgets"