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)
This commit is contained in:
2008-07-24 19:12:30 +00:00
parent 059b0651de
commit d1bdd58797

View File

@@ -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);