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:
authorDemeter Dzadik <Mets>2021-12-14 14:44:52 +0300
committerDemeter Dzadik <demeter@blender.studio>2021-12-14 14:44:56 +0300
commitece39d809ceb27b5a06da7c4b8f25ca77016b151 (patch)
tree787ff10a2b854a36d5b756e35ec03561cc8eb9ee /rigify/utils/collections.py
parentc60fef38175ad989ee0c45e924cb27e1417c8667 (diff)
Rigify: Clean up "Rigify Buttons" panel UX
The overall goal of this patch is to improve the UI/UX of the panel previously known as "Rigify Buttons" which presumably takes its name from the old "Buttons Panel" which is now known as the Properties Editor. Before: {F10511640} After: {F10511624} - Make Rigify less reliant on name matching when it comes to maintaining the link between the metarig, the UI script, the generated rig, and the widgets collection. (Use pointers only, names shouldn't matter!) - Change the "Advanced" toggle button into a real sub-panel. - Split up the "Rigify Buttons" panels into "Rigify Generation" and "Rigify Samples" panels in non-edit and edit mode respectively, to better describe what the user will find there. Changes in the Rigify Buttons panel: - Removed the "overwrite/new" enum. - If there is a target rig object, it will be overwritten. If not, it will be created. - If a rig object with the desired name already existed, but wasn't selected as the target rig, the "overwrite" option still overwrote that rig. I don't agree with that because this meant messing with data without indicating that that data is going to be messed with. Unaware users could lose data/work. With these changes, the worst thing that can happen is that your rig ends up with a .001 suffix. - Removed the "rig name" text input field. Before this patch, this would always rename your rig object and your rig script text datablock, which I think is more frustrating than useful. Now you can simply rename them after generation yourself, and the names will be kept in subsequent generations. - Single-column layout - Changed the "Advanced Options" into a sub-panel instead. On request: - Added an info message to show the name of the successfully generated rig: {F10159079} Feedback welcome. Reviewed By: angavrilov Differential Revision: https://developer.blender.org/D11356
Diffstat (limited to 'rigify/utils/collections.py')
-rw-r--r--rigify/utils/collections.py45
1 files changed, 22 insertions, 23 deletions
diff --git a/rigify/utils/collections.py b/rigify/utils/collections.py
index a172b984..a19b9da1 100644
--- a/rigify/utils/collections.py
+++ b/rigify/utils/collections.py
@@ -19,9 +19,6 @@
# <pep8 compliant>
import bpy
-import math
-
-from .errors import MetarigError
#=============================================
@@ -65,30 +62,32 @@ def filter_layer_collections_by_object(layer_collections, obj):
return [lc for lc in layer_collections if obj in lc.collection.objects.values()]
-def ensure_widget_collection(context, wgts_collection_name):
+def ensure_collection(context, collection_name, hidden=False) -> bpy.types.Collection:
+ """Check if a collection with a certain name exists.
+ If yes, return it, if not, create it in the scene root collection.
+ """
view_layer = context.view_layer
- layer_collection = bpy.context.layer_collection
- collection = layer_collection.collection
+ active_layer_coll = bpy.context.layer_collection
+ active_collection = active_layer_coll.collection
- widget_collection = bpy.data.collections.get(wgts_collection_name)
- if not widget_collection:
- # ------------------------------------------
- # Create the widget collection
- widget_collection = bpy.data.collections.new(wgts_collection_name)
- widget_collection.hide_viewport = True
- widget_collection.hide_render = True
+ collection = bpy.data.collections.get(collection_name)
+ if not collection:
+ # Create the collection
+ collection = bpy.data.collections.new(collection_name)
+ collection.hide_viewport = hidden
+ collection.hide_render = hidden
- widget_layer_collection = None
+ layer_collection = None
else:
- widget_layer_collection = find_layer_collection_by_collection(view_layer.layer_collection, widget_collection)
+ layer_collection = find_layer_collection_by_collection(view_layer.layer_collection, collection)
- if not widget_layer_collection:
- # Add the widget collection to the tree
- collection.children.link(widget_collection)
- widget_layer_collection = [c for c in layer_collection.children if c.collection == widget_collection][0]
+ if not layer_collection:
+ # Let the new collection be a child of the active one.
+ active_collection.children.link(collection)
+ layer_collection = [c for c in active_layer_coll.children if c.collection == collection][0]
- widget_layer_collection.exclude = True
+ layer_collection.exclude = True
- # Make the widget the active collection for the upcoming added (widget) objects
- view_layer.active_layer_collection = widget_layer_collection
- return widget_collection
+ # Make the new collection active.
+ view_layer.active_layer_collection = layer_collection
+ return collection