With[{
f = Compile[{{point, _Real, 1}, {r, _Real, 0}},
If[point.point <= r^2, 1, 0],
RuntimeAttributes -> {Listable},
Parallelization -> True]},
dm3d[n_Integer, r_Integer] := With[{dn = Max[1, Floor[n/2]]},
f[Outer[List, #, #, #] &[Range[-dn, dn]], r]
]
]