commit 51562c331a25a3c3548fb5d4d84cd9fd31aeafb2
parent b945d8df203f585a48e1e83d51c98be53ea9f99d
Author: lostd <lostd@2f30.org>
Date: Thu, 11 Jun 2015 20:39:33 +0100
Fix comparison function
Two points having the same distance from the center of the cluster does
not mean they are unique.
Diffstat:
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/colors.c b/colors.c
@@ -56,9 +56,11 @@ distance(struct point *p1, struct point *p2)
int
pointcmp(struct point *p1, struct point *p2)
{
- struct point center = { 0 };
+ unsigned int a, b;
- return distance(¢er, p1) - distance(¢er, p2);
+ a = p1->x << 16 | p1->y << 8 | p1->z;
+ b = p2->x << 16 | p2->y << 8 | p2->z;
+ return a - b;
}
RB_PROTOTYPE(pointtree, point, rb_e, pointcmp)
RB_GENERATE(pointtree, point, rb_e, pointcmp)