Skip to content

Commit

Permalink
Hotfix: Fixed Rescaling of Avatar
Browse files Browse the repository at this point in the history
  • Loading branch information
Menithal committed Jun 24, 2019
1 parent 1a79403 commit eb52350
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion hifi_tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
bl_info = {
"name": "HiFi Blender Add-on",
"author": "Matti 'Menithal' Lahtinen",
"version": (1, 4, 2),
"version": (1, 4, 3),
"blender": (2, 80, 0),
"location": "File > Import-Export, Materials, Armature",
"description": "Blender tools to allow for easier Content creation for Metaverses, such as High Fidelity",
Expand Down
7 changes: 4 additions & 3 deletions hifi_tools/utils/bones/bones_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ def reset_scale_rotation(obj):
bpy.ops.object.select_all(action="DESELECT")

obj.select_set(state=True)
bpy.context.view_layer.objects.active = obj

bpy.ops.object.origin_set(type="ORIGIN_CURSOR")
bpy.ops.object.transform_apply(location=False, rotation=True, scale=True)

Expand All @@ -551,7 +551,9 @@ def correct_scale_rotation(obj, rotation):
str_angle = -90 * pi/180
if rotation:
obj.rotation_euler = Euler((str_angle, 0, 0), "XYZ")
bpy.ops.object.transform_apply(location=False, rotation=True, scale=True)

reset_scale_rotation(obj)

obj.scale = Vector((0.01, 0.01, 0.01))
if rotation:
obj.rotation_euler = Euler((-str_angle, 0, 0), "XYZ")
Expand Down Expand Up @@ -610,7 +612,6 @@ def clear_pose(selected):


def retarget_armature(options, selected, selected_only=False):

armature = find_armature(selected)
if armature is not None:
# Center Children First
Expand Down
8 changes: 6 additions & 2 deletions hifi_tools/utils/ui/panels.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,13 @@ class OBJECT_OT_METAV_TOOLSET_Fix_Scale_Operator(bpy.types.Operator):
bl_category = "High Fidelity"

def execute(self, context):

for selected in context.selected_objects:
selected_objects = bpy.context.selected_objects
for selected in selected_objects:
bones_builder.correct_scale_rotation(selected, True)

bpy.ops.object.select_all(action="DESELECT")
for selected in selected_objects:
selected.select_set(state=True)

return {'FINISHED'}

Expand Down
3 changes: 2 additions & 1 deletion package.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@
f = os.path.join(path,f)
zip.write(os.path.realpath(f),f)

zip.close()
zip.close()
print("Packaged into Projects Folder")

0 comments on commit eb52350

Please sign in to comment.