function region3.castPoint(c,F)local t=c.centroid-F return gjk(c.input,{F},c.support,support.point,t)end function region3.castPart(c,F)local t=classify(F)local D=c.centroid-t.centroid return gjk(c.input,t.input,c.support,t.support,D)end function region3.cast(t,F,c)local D=type(F)=="\116\097\098\108\101"and F or{F}local C=c or 1000 local U,m={},{}for F,c in next,{Enum.NormalId.Right;Enum.NormalId.Top;Enum.NormalId.Back}do local D=Vector3.FromNormalId(c)insert(U,t.support(-D,unpack(t.input)))insert(m,t.support(D,unpack(t.input)))end U,m=v3(U[1].x,U[2].y,U[3].z),v3(m[1].x,m[2].y,m[3].z)local O=R3(U,m)local S=game.Workspace:FindPartsInRegion3WithIgnoreList(O,D,C)local B={}for F=1,#S,1 do local c=S[F]if t:castPart(c)then insert(B,c)end end return B end


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;
