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:
authorDalai Felinto <dfelinto@gmail.com>2018-10-22 18:13:13 +0300
committerDalai Felinto <dfelinto@gmail.com>2018-10-22 19:24:10 +0300
commit816407649aedfaa7836e3aca7629842db732e279 (patch)
tree201c08308821382d6847f10a0c03902faeb88870 /rigify/legacy
parent0e0e8de0de6022c23729e2d139b9aa47324d7122 (diff)
Rigify: More updates for 2.8 API
With those changes the addon is working in some functional state. Thus I'm bumping its version to 2.80. TODOS: * Handle collections (put all the new objects in a collection). * We should also replace the old WGT_LAYERS with subcollections. * Move toolshelf operators out of there (make tools or move to sidebar).
Diffstat (limited to 'rigify/legacy')
-rw-r--r--rigify/legacy/generate.py32
-rw-r--r--rigify/legacy/rigs/pitchipoy/limbs/limb_utils.py4
-rw-r--r--rigify/legacy/rigs/pitchipoy/super_torso_turbo.py4
-rw-r--r--rigify/legacy/utils.py5
4 files changed, 24 insertions, 21 deletions
diff --git a/rigify/legacy/generate.py b/rigify/legacy/generate.py
index eb3c3112..4cc725b1 100644
--- a/rigify/legacy/generate.py
+++ b/rigify/legacy/generate.py
@@ -71,6 +71,8 @@ def generate_rig(context, metarig):
bpy.ops.object.mode_set(mode='OBJECT')
scene = context.scene
+ view_layer = context.view_layer
+ collection = scene.collection
#------------------------------------------
# Create/find the rig object and set it up
@@ -89,7 +91,7 @@ def generate_rig(context, metarig):
except KeyError:
obj = bpy.data.objects.new(name, bpy.data.armatures.new(name))
obj.display_type = 'WIRE'
- scene.objects.link(obj)
+ collection.objects.link(obj)
obj.data.pose_position = 'POSE'
@@ -98,9 +100,9 @@ def generate_rig(context, metarig):
obj.animation_data_clear()
# Select generated rig object
- metarig.select = False
- obj.select = True
- scene.objects.active = obj
+ metarig.select_set('DESELECT')
+ obj.select_set('SELECT')
+ view_layer.objects.active = obj
# Remove all bones from the generated rig armature.
bpy.ops.object.mode_set(mode='EDIT')
@@ -111,18 +113,18 @@ def generate_rig(context, metarig):
# Create temporary duplicates for merging
temp_rig_1 = metarig.copy()
temp_rig_1.data = metarig.data.copy()
- scene.objects.link(temp_rig_1)
+ collection.objects.link(temp_rig_1)
temp_rig_2 = metarig.copy()
temp_rig_2.data = obj.data
- scene.objects.link(temp_rig_2)
+ collection.objects.link(temp_rig_2)
# Select the temp rigs for merging
for objt in scene.objects:
- objt.select = False # deselect all objects
- temp_rig_1.select = True
- temp_rig_2.select = True
- scene.objects.active = temp_rig_2
+ objt.select_set('DESELECT') # deselect all objects
+ temp_rig_1.select_set('SELECT')
+ temp_rig_2.select_set('SELECT')
+ view_layer.objects.active = temp_rig_2
# Merge the temporary rigs
bpy.ops.object.join()
@@ -132,9 +134,9 @@ def generate_rig(context, metarig):
# Select the generated rig
for objt in scene.objects:
- objt.select = False # deselect all objects
- obj.select = True
- scene.objects.active = obj
+ objt.select_set('DESELECT') # deselect all objects
+ obj.select_set('SELECT')
+ view_layer.objects.active = obj
# Copy over bone properties
for bone in metarig.data.bones:
@@ -277,8 +279,8 @@ def generate_rig(context, metarig):
for rig in rigs:
# Go into editmode in the rig armature
bpy.ops.object.mode_set(mode='OBJECT')
- context.scene.objects.active = obj
- obj.select = True
+ context.view_layer.objects.active = obj
+ obj.select_set('SELECT')
bpy.ops.object.mode_set(mode='EDIT')
scripts = rig.generate()
if scripts is not None:
diff --git a/rigify/legacy/rigs/pitchipoy/limbs/limb_utils.py b/rigify/legacy/rigs/pitchipoy/limbs/limb_utils.py
index b0b62d79..69449bb7 100644
--- a/rigify/legacy/rigs/pitchipoy/limbs/limb_utils.py
+++ b/rigify/legacy/rigs/pitchipoy/limbs/limb_utils.py
@@ -11,11 +11,11 @@ def orient_bone( cls, eb, axis, scale = 1.0, reverse = False ):
setattr(v,axis,scale)
if reverse:
- tail_vec = v * cls.obj.matrix_world
+ tail_vec = v @ cls.obj.matrix_world
eb.head[:] = eb.tail
eb.tail[:] = eb.head + tail_vec
else:
- tail_vec = v * cls.obj.matrix_world
+ tail_vec = v @ cls.obj.matrix_world
eb.tail[:] = eb.head + tail_vec
eb.roll = 0.0
diff --git a/rigify/legacy/rigs/pitchipoy/super_torso_turbo.py b/rigify/legacy/rigs/pitchipoy/super_torso_turbo.py
index 38d5887b..d9645adb 100644
--- a/rigify/legacy/rigs/pitchipoy/super_torso_turbo.py
+++ b/rigify/legacy/rigs/pitchipoy/super_torso_turbo.py
@@ -99,11 +99,11 @@ class Rig:
setattr(v,axis,scale)
if reverse:
- tail_vec = v * self.obj.matrix_world
+ tail_vec = v @ self.obj.matrix_world
eb.head[:] = eb.tail
eb.tail[:] = eb.head + tail_vec
else:
- tail_vec = v * self.obj.matrix_world
+ tail_vec = v @ self.obj.matrix_world
eb.tail[:] = eb.head + tail_vec
diff --git a/rigify/legacy/utils.py b/rigify/legacy/utils.py
index e3927ac3..35bbd7b9 100644
--- a/rigify/legacy/utils.py
+++ b/rigify/legacy/utils.py
@@ -416,11 +416,12 @@ def create_widget(rig, bone_name, bone_transform_name=None):
# Create mesh object
mesh = bpy.data.meshes.new(obj_name)
obj = bpy.data.objects.new(obj_name, mesh)
- scene.objects.link(obj)
+ collection.objects.link(obj)
# Move object to bone position and set layers
obj_to_bone(obj, rig, bone_transform_name)
- obj.layers = WGT_LAYERS
+ # TODO move colleciton to all the WGT_LAYERS collections
+ # obj.layers = WGT_LAYERS
return obj