diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2018-10-22 18:36:23 +0300 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2018-10-22 19:24:10 +0300 |
commit | cadeb9991cb624bfcfa683d164e5fe000732d684 (patch) | |
tree | 3690b61c5a3091a68f5b63e00b9f4607bf2f40f7 | |
parent | 9940479d24b8352f6d151a05c4170366787bfee0 (diff) |
Rigify: Hack to make sure UI is always linked to the object
This replaces the old trick of using game controllers.
-rw-r--r-- | rigify/generate.py | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/rigify/generate.py b/rigify/generate.py index 0631cce3..12ba51ce 100644 --- a/rigify/generate.py +++ b/rigify/generate.py @@ -511,18 +511,7 @@ def generate_rig(context, metarig): create_bone_groups(obj, metarig) # Add rig_ui to logic - skip = False - ctrls = obj.game.controllers - - for c in ctrls: - if 'Python' in c.name and c.text.name == script.name: - skip = True - break - if not skip: - bpy.ops.logic.controller_add(type='PYTHON', object=obj.name) - ctrl = obj.game.controllers[-1] - ctrl.text = bpy.data.texts[script.name] - + create_persistent_rig_ui(obj, script) t.tick("The rest: ") #---------------------------------- @@ -607,6 +596,31 @@ def create_bone_groups(obj, metarig): b.bone_group = obj.pose.bone_groups[name] +def create_persistent_rig_ui(obj, script): + """Make sure the ui script always follows the rig around""" + skip = False + driver = None + + for fcurve in obj.animation_data.drivers: + if fcurve.data_path == 'pass_index': + driver = fcurve.driver + for variable in driver.variables: + if variable.name == script.name: + skip = True + break + break + + if not skip: + if not driver: + fcurve = obj.driver_add("pass_index") + driver = fcurve.driver + + variable = driver.variables.new() + variable.name = script.name + variable.targets[0].id_type = 'TEXT' + variable.targets[0].id = script + + def get_bone_rigs(obj, bone_name, halt_on_missing=False): """ Fetch all the rigs specified on a bone. """ |