- return x >= pos.x_
- && x <= pos.x_ + dim.wid
- && y >= pos.y_ - dim.asc
- && y <= pos.y_ + dim.des;
+ return x >= pos.x_ && x < pos.x_ + dim.wid
+ && y >= pos.y_ - dim.asc && y <= pos.y_ + dim.des;
+ }
+
+ int squareDistance(int x, int y) const
+ {
+ int xx = 0;
+ int yy = 0;
+
+ if (x < pos.x_)
+ xx = pos.x_ - x;
+ else if (x > pos.x_ + dim.wid)
+ xx = x - pos.x_ - dim.wid;
+
+ if (y < pos.y_ - dim.asc)
+ yy = pos.y_ - dim.asc - y;
+ else if (y > pos.y_ + dim.des)
+ yy = y - pos.y_ - dim.des;
+
+ // Optimisation: We avoid to compute the sqrt on purpose.
+ return xx*xx + yy*yy;