void setHit(int x, int y, TraceSpan span) { if (x >= 0 && x < width && y >= 0 && y < height) { grid[y * width + x] = span; } }