local function k(k,w,u)local R=blockVerts(k.CFrame,k.Size/2)if u:Dot(POSITIVEDIR)<0 then u=-u end local y={}for k=1,#R,1 do y[#y+1]=(R[k]-w):Dot(u)end local r=math.min(unpack(y))local l=math.max(unpack(y))local D=k.Position-w local P=(D-D:Dot(u)*u)+w local H=k.Size-k.Size*u local I,G if l>=.05 then I=P+(u*l)/2 G=H+l*u end local T,g if r<=-0.05 then T=P+(u*r)/2 g=H-r*u end return I,G,T,g end
-- cuts part into two based on an axis aligned plane
local function slicePart(part, origin, normal)
	local verts = blockVerts(part.CFrame, part.Size / 2)

	if normal:Dot(POSITIVEDIR) < 0 then
		normal = -normal
	end

	local distances = {}
	for i = 1, #verts do
		distances[#distances + 1] = (verts[i] - origin):Dot(normal)
	end

	local min = math.min(unpack(distances))
	local max = math.max(unpack(distances))

	local v = part.Position - origin
	local center = (v - v:Dot(normal) * normal) + origin
	local size = part.Size - part.Size * normal

	local pos1, size1
	if max >= 0.05 then
		pos1 = center + normal * max / 2
		size1 = size + max * normal
	end

	local pos2, size2
	if min <= -0.05 then
		pos2 = center + normal * min / 2
		size2 = size - min * normal
	end

	return pos1, size1, pos2, size2
end
