diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2012-01-30 23:46:15 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2012-01-30 23:46:15 +0400 |
commit | 8ec8aaf77f0c90cdfc13800a6e839fc88db07e2c (patch) | |
tree | a6cdee9c4caad0084716bbd04d27b0b92a775ae3 /source/blender/blenkernel | |
parent | 26d3b873d5a80372771e11acfb70ab79c520eabb (diff) |
Fix #30019: Copy rotation from a vertex group
It was incorrect behavior of contarget_get_mesh_mat in cases when
object's Y axis is co-linear to average vertex group normal.
Use object's X axis for plane definition in such cases.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/intern/constraint.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 8118cf64429..213a3ce9fbd 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -504,13 +504,17 @@ static void contarget_get_mesh_mat (Object *ob, const char *substring, float mat normalize_v3(normal); copy_v3_v3(plane, tmat[1]); - copy_v3_v3(tmat[2], normal); - cross_v3_v3v3(tmat[0], normal, plane); - cross_v3_v3v3(tmat[1], tmat[2], tmat[0]); - - copy_m4_m3(mat, tmat); + cross_v3_v3v3(mat[0], normal, plane); + if(len_v3(mat[0]) < 1e-3) { + copy_v3_v3(plane, tmat[0]); + cross_v3_v3v3(mat[0], normal, plane); + } + + copy_v3_v3(mat[2], normal); + cross_v3_v3v3(mat[1], mat[2], mat[0]); + normalize_m4(mat); - + /* apply the average coordinate as the new location */ mul_v3_m4v3(mat[3], ob->obmat, vec); |