| 1962 | } |
| 1963 | |
| 1964 | void AddTarget (Vec<3> x) |
| 1965 | { |
| 1966 | // if (childs[0]) |
| 1967 | if (have_childs) // quick check without locking |
| 1968 | { |
| 1969 | // directly send to childs: |
| 1970 | int childnum = GetChildNum(x); |
| 1971 | childs[childnum] -> AddTarget( x ); |
| 1972 | return; |
| 1973 | } |
| 1974 | |
| 1975 | lock_guard<mutex> guard(node_mutex); |
| 1976 | |
| 1977 | if (have_childs) // test again after locking |
| 1978 | { |
| 1979 | // directly send to childs: |
| 1980 | int childnum = GetChildNum(x); |
| 1981 | childs[childnum] -> AddTarget(x); |
| 1982 | return; |
| 1983 | } |
| 1984 | |
| 1985 | targets.Append( x ); |
| 1986 | |
| 1987 | // if (r*mp.Kappa() < 1e-8) return; |
| 1988 | if (level > params.maxlevel) return; |
| 1989 | if (targets.Size() < params.maxdirect && r*abs(mp.Kappa()) < params.split_kr) |
| 1990 | return; |
| 1991 | |
| 1992 | CreateChilds(); |
| 1993 | |
| 1994 | for (auto t : targets) |
| 1995 | AddTarget (t); |
| 1996 | for (auto [x,r] : vol_targets) |
| 1997 | AddVolumeTarget (x,r); |
| 1998 | |
| 1999 | targets.SetSize0(); |
| 2000 | vol_targets.SetSize0(); |
| 2001 | } |
| 2002 | |
| 2003 | |
| 2004 | void AddVolumeTarget (Vec<3> x, double tr) |