Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Poirier <theeth@yahoo.com>2008-07-24 23:12:30 +0400
committerMartin Poirier <theeth@yahoo.com>2008-07-24 23:12:30 +0400
commitd1bdd587970cf80fb6bd9b9e916e7945b6a304b8 (patch)
tree8bb0e5f59226f1096fcc00720ec4ea93a701acc2 /source/blender/blenlib
parent059b0651de98ca3ea4be28dc857643a406e66930 (diff)
Axial symmetry stability bug fix.
Axial symmetry tagging was depending on the order of the nodes, so it might tag left side as right and vice versa depending on the order. Stability test ensures the tagging is order independant (what it tags as right and left might not be the real right and left, but at least they are consistant between mesh graph and armature graph, so it doesn't flip limbs)
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r--source/blender/blenlib/intern/graph.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/source/blender/blenlib/intern/graph.c b/source/blender/blenlib/intern/graph.c
index 32d9f3b91b7..abdf2969e49 100644
--- a/source/blender/blenlib/intern/graph.c
+++ b/source/blender/blenlib/intern/graph.c
@@ -714,15 +714,28 @@ static void testAxialSymmetry(BGraph *graph, BNode* root_node, BNode* node1, BNo
{
float nor[3], vec[3], p[3];
- VecSubf(vec, node1->p, root_node->p);
- Normalize(vec);
- VecSubf(p, root_node->p, node2->p);
- Normalize(p);
- VecAddf(p, p, vec);
+ VecSubf(p, node1->p, root_node->p);
+ Crossf(nor, p, axis);
+ VecSubf(p, root_node->p, node2->p);
Crossf(vec, p, axis);
+ VecAddf(vec, vec, nor);
+
Crossf(nor, vec, axis);
+ if (abs(nor[0]) > abs(nor[1]) && abs(nor[0]) > abs(nor[2]) && nor[0] < 0)
+ {
+ VecMulf(nor, -1);
+ }
+ else if (abs(nor[1]) > abs(nor[0]) && abs(nor[1]) > abs(nor[2]) && nor[1] < 0)
+ {
+ VecMulf(nor, -1);
+ }
+ else if (abs(nor[2]) > abs(nor[1]) && abs(nor[2]) > abs(nor[0]) && nor[2] < 0)
+ {
+ VecMulf(nor, -1);
+ }
+
/* mirror node2 along axis */
VECCOPY(p, node2->p);
BLI_mirrorAlongAxis(p, root_node->p, nor);