public void CalculateNeighbours () {
neighbours.Clear();
neighbourDists.Clear();
float rangeSq;
if (locked) return;
//watch1.Start ();
if (MaxNeighbours > 0) {
rangeSq = neighbourDist*neighbourDist;
//simulator.KDTree.GetAgentNeighbours (this, rangeSq);
simulator.Quadtree.Query(new Vector2(position.x, position.z), neighbourDist, this);
}
//watch1.Stop ();
obstacles.Clear();
obstacleDists.Clear();
rangeSq = (obstacleTimeHorizon * maxSpeed + radius);
rangeSq *= rangeSq;
// Obstacles disabled at the moment
//simulator.KDTree.GetObstacleNeighbours (this, rangeSq);
}