Skip to content

Commit cb53c81

Browse files
committed
fix bone prop ui lag
1 parent c273e5b commit cb53c81

File tree

3 files changed

+21
-14
lines changed

3 files changed

+21
-14
lines changed

rig_lists.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
2424
def get_rig_list(path):
2525
""" Recursively searches for rig types, and returns a list.
2626
"""
27+
rigs_dict = dict()
2728
rigs = []
29+
implementation_rigs = []
2830
MODULE_DIR = os.path.dirname(__file__)
2931
RIG_DIR_ABS = os.path.join(MODULE_DIR, utils.RIG_DIR)
3032
SEARCH_DIR_ABS = os.path.join(RIG_DIR_ABS, path)
@@ -50,17 +52,24 @@ def get_rig_list(path):
5052
rigs += [f]
5153
else:
5254
# Check for sub-rigs
53-
ls = get_rig_list(os.path.join(path, f, "")) # "" adds a final slash
54-
rigs.extend(["%s.%s" % (f, l) for l in ls])
55+
sub_dict = get_rig_list(os.path.join(path, f, "")) # "" adds a final slash
56+
rigs.extend(["%s.%s" % (f, l) for l in sub_dict['rig_list']])
57+
implementation_rigs.extend(["%s.%s" % (f, l) for l in sub_dict['implementation_rigs']])
5558
elif f.endswith(".py"):
5659
# Check straight-up python files
5760
t = f[:-3]
5861
module_name = os.path.join(path, t).replace(os.sep, ".")
5962
rig = utils.get_rig_type(module_name)
6063
if hasattr(rig, "Rig"):
6164
rigs += [t]
65+
if hasattr(rig, 'IMPLEMENTATION') and rig.IMPLEMENTATION:
66+
implementation_rigs += [t]
6267
rigs.sort()
63-
return rigs
68+
69+
rigs_dict['rig_list'] = rigs
70+
rigs_dict['implementation_rigs'] = implementation_rigs
71+
72+
return rigs_dict
6473

6574

6675
def get_collection_list(rig_list):
@@ -73,6 +82,8 @@ def get_collection_list(rig_list):
7382

7483

7584
# Public variables
76-
rig_list = get_rig_list("")
85+
rigs_dict = get_rig_list("")
86+
rig_list = rigs_dict['rig_list']
87+
implementation_rigs = rigs_dict['implementation_rigs']
7788
collection_list = get_collection_list(rig_list)
7889
col_enum_list = [("All", "All", ""), ("None", "None", "")] + [(c, c, "") for c in collection_list]

ui.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -567,12 +567,9 @@ class BONE_PT_rigify_buttons(bpy.types.Panel):
567567

568568
@classmethod
569569
def poll(cls, context):
570-
if not context.armature or not context.active_pose_bone:
571-
return False
572-
obj = context.object
573-
if obj:
574-
return obj.mode == 'POSE' and context.active_object.data.get("rig_id") is None
575-
return False
570+
571+
return context.object.type == 'ARMATURE' and context.active_pose_bone\
572+
and context.active_object.data.get("rig_id") is None
576573

577574
def draw(self, context):
578575
C = context
@@ -588,8 +585,7 @@ def draw(self, context):
588585
id_store.rigify_types.remove(0)
589586

590587
for r in rig_lists.rig_list:
591-
rig = get_rig_type(r)
592-
if hasattr(rig, 'IMPLEMENTATION') and rig.IMPLEMENTATION:
588+
if r in rig_lists.implementation_rigs:
593589
continue
594590
# collection = r.split('.')[0] # UNUSED
595591
if collection_name == "All":

utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -909,7 +909,7 @@ def get_rig_type(rig_type):
909909
"""
910910
name = ".%s.%s" % (RIG_DIR, rig_type)
911911
submod = importlib.import_module(name, package=MODULE_NAME)
912-
imp.reload(submod)
912+
importlib.reload(submod)
913913
return submod
914914

915915

@@ -919,7 +919,7 @@ def get_metarig_module(metarig_name, path=METARIG_DIR):
919919

920920
name = ".%s.%s" % (path, metarig_name)
921921
submod = importlib.import_module(name, package=MODULE_NAME)
922-
imp.reload(submod)
922+
importlib.reload(submod)
923923
return submod
924924

925925

0 commit comments

Comments
 (0)