[Bf-extensions-cvs] [2b25d94] master: Fix T42416: Mocap addon: auto-scale doesn't work.
Sybren Stüvel
noreply at git.blender.org
Wed Oct 29 12:34:15 CET 2014
Commit: 2b25d94bbd57906d4cd58b5aeb03916714b289f6
Author: Sybren Stüvel
Date: Wed Oct 29 12:31:14 2014 +0100
Branches: master
https://developer.blender.org/rBA2b25d94bbd57906d4cd58b5aeb03916714b289f6
Fix T42416: Mocap addon: auto-scale doesn't work.
Also simplified the code. There were a few things that were explicitly coded
while there are Python builtins that perform the same operation (and do it faster).
Reviewed by mont29 (Bastien Montagne).
===================================================================
M mocap/mocap_tools.py
===================================================================
diff --git a/mocap/mocap_tools.py b/mocap/mocap_tools.py
index 5d85205..8ecd3c0 100644
--- a/mocap/mocap_tools.py
+++ b/mocap/mocap_tools.py
@@ -635,22 +635,19 @@ def scale_fix_armature(performer_obj, enduser_obj):
end_bones = enduser_obj.data.bones
def calculateBoundingRadius(bones):
- center = Vector()
- for bone in bones:
- center += bone.head_local
+ # Calculate the average position of each bone
+ center = sum((bone.head_local for bone in bones), Vector())
center /= len(bones)
- radius = 0
- for bone in bones:
- dist = (bone.head_local - center).length
- if dist > radius:
- radius = dist
+
+ # The radius is defined as the max distance from the center.
+ radius = max((bone.head_local - center).length for bone in bones)
return radius
perf_rad = calculateBoundingRadius(performer_obj.data.bones)
end_rad = calculateBoundingRadius(enduser_obj.data.bones)
- #end_avg = enduser_obj.dimensions
- factor = end_rad / perf_rad * 1.2
- performer_obj.scale *= factor
+
+ factor = end_rad / perf_rad
+ performer_obj.scale = factor * Vector((1, 1, 1))
#Guess Mapping
More information about the Bf-extensions-cvs
mailing list