Permalink
Browse files

Refactored get_closest_torso_node

  • Loading branch information...
1 parent fea0bc2 commit 88c59d5a19edeaa0badf65d61d79a8142fb893a7 @joaquimrocha committed Oct 3, 2012
Showing with 7 additions and 13 deletions.
  1. +7 −13 skeltrack/skeltrack-util.c
View
@@ -184,21 +184,15 @@ get_closest_torso_node (GList *node_list, Node *from, Node *head)
Node *node;
gint current_distance;
node = (Node *) current_node->data;
- if (closest == NULL &&
- node->z >= head->z &&
+ if (node->z >= head->z &&
node->y >= from->y)
{
- closest = node;
- distance = get_distance (node, from);
- continue;
- }
- current_distance = get_distance (node, from);
- if (current_distance < distance &&
- node->z >= head->z &&
- node->y >= from->y)
- {
- closest = node;
- distance = current_distance;
+ current_distance = get_distance (node, from);
+ if (closest == NULL || current_distance < distance)
+ {
+ closest = node;
+ distance = current_distance;
+ }
}
}
return closest;

0 comments on commit 88c59d5

Please sign in to comment.