Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local center = cellsize / 2
- function align(x)
- return math.floor(x + 0.5) + center
- end
- function getCellsWithinRadius(Point, Radius)
- local Point = Point * cellsize
- local HalfRadius = (Radius * cellsize) / 2
- local near = {}
- for x = Point.X - HalfRadius, Point.X + HalfRadius do
- local fx = align(x)
- for y = Point.Y - HalfRadius, Point.Y + HalfRadius do
- local fy = align(y)
- for z = Point.Z - HalfRadius, Point.Z + HalfRadius do
- local v3p = Vector3.new(fx, fy, align(z))
- if ((Point - v3p).magnitude < Radius) then
- table.insert(near, v3p)
- end
- end
- end
- end
- return near
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement