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
path: root/mocap
diff options
context:
space:
mode:
authorSybren Stüvel <sybren@stuvel.eu>2014-10-29 14:31:14 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2014-10-29 14:31:14 +0300
commit2b25d94bbd57906d4cd58b5aeb03916714b289f6 (patch)
tree2cb9fedcf425eeb7768511ad05636fc723d685c4 /mocap
parent51b6f00666d2b44bc5f978bb6cea515b0695e5f2 (diff)
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).
Diffstat (limited to 'mocap')
-rw-r--r--mocap/mocap_tools.py19
1 files changed, 8 insertions, 11 deletions
diff --git a/mocap/mocap_tools.py b/mocap/mocap_tools.py
index 5d852052..8ecd3c08 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