hdist: fix misuse of counter affecting calculations with variable point density