function region3.castPoint(u,F)local A=u.centroid-F return gjk(u.input,{F},u.support,support.point,A)end function region3.castPart(u,F)local A=classify(F)local l=u.centroid-A.centroid return gjk(u.input,A.input,u.support,A.support,l)end function region3.cast(A,F,u)local l=type(F)=="\116\097\098\108\101"and F or{F}local I=u or 1000 local H,i={},{}for F,u in next,{Enum.NormalId.Right;Enum.NormalId.Top;Enum.NormalId.Back}do local l=Vector3.FromNormalId(u)insert(H,A.support(-l,unpack(A.input)))insert(i,A.support(l,unpack(A.input)))end H,i=v3(H[1].x,H[2].y,H[3].z),v3(i[1].x,i[2].y,i[3].z)local o=R3(H,i)local Y=game.Workspace:FindPartsInRegion3WithIgnoreList(o,l,I)local D={}for F=1,#Y,1 do local u=Y[F]if A:castPart(u)then insert(D,u)end end return D end
-- public methods

function region3:castPoint(point)
	local direction = self.centroid - point
	return gjk(self.input, { point }, self.support, support.point, direction)
end

function region3:castPart(part)
	local against = classify(part)
	local direction = self.centroid - against.centroid
	return gjk(self.input, against.input, self.support, against.support, direction)
end

function region3:cast(ignore, maxParts)
	local ignore = type(ignore) == "table" and ignore or { ignore }
	local maxParts = maxParts or 1000

	local min, max = {}, {}
	for _, enum in next, { Enum.NormalId.Right, Enum.NormalId.Top, Enum.NormalId.Back } do
		local direction = Vector3.FromNormalId(enum)
		insert(min, self.support(-direction, unpack(self.input)))
		insert(max, self.support(direction, unpack(self.input)))
	end
	min, max = v3(min[1].x, min[2].y, min[3].z), v3(max[1].x, max[2].y, max[3].z)

	local allignedR3 = R3(min, max)
	local parts = game.Workspace:FindPartsInRegion3WithIgnoreList(allignedR3, ignore, maxParts)

	-- debug stuff
	--game.Workspace.CurrentCamera:ClearAllChildren();
	--draw.line(min, max, game.Workspace.CurrentCamera);

	local inRegion = {}
	for i = 1, #parts do
		local part = parts[i]
		if self:castPart(part) then
			insert(inRegion, part)
		end
	end
	return inRegion
end
