function region3.castPoint(R,u)local X=R.centroid-u return gjk(R.input,{u},R.support,support.point,X)end function region3.castPart(R,u)local X=classify(u)local S=R.centroid-X.centroid return gjk(R.input,X.input,R.support,X.support,S)end function region3.cast(X,u,R)local S=type(u)=="\116\097\098\108\101"and u or{u}local V=R or 100 local Q,A={},{}for u,R in next,{Enum.NormalId.Right,Enum.NormalId.Top,Enum.NormalId.Back}do local S=Vector3.FromNormalId(R)insert(Q,X.support(-S,unpack(X.input)))insert(A,X.support(S,unpack(X.input)))end Q,A=v3(Q[1].x,Q[2].y,Q[3].z),v3(A[1].x,A[2].y,A[3].z)local i=R3(Q,A)local F=game.Workspace:FindPartsInRegion3WithIgnoreList(i,S,V)local v={}for u=1,#F,1 do local R=F[u]if X:castPart(R)then insert(v,R)end end return v 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 100;
	
	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;
