Custom Workspace:JoinToOutsiders()

One of the great things about JoinToOutsiders is it ignores blocks which only share one edge or only share one vertex. The blocks have to be coplanar.


https://gyazo.com/7067079f66a1032dfe34c8f4b871f466

(Above won’t get welded by workspace:JoinToOutsiders() )

I’m wondering if anyone knows where I can find the source code of Workspace:JoinToOutsiders or help me fix the code.

I’ve been trying to do this with fuzzy number checks, but there a lot of edge cases where my code welds blocks which only share one edge. I’ve experimented with the ellipsion but these cases still occur sometimes.

local function abs(x)
	return Vector3.new(math.abs(x.x), math.abs(x.y), math.abs(x.z))
end

function fuzzyEq(a, b, epsilon)
	if epsilon == nil then epsilon = 1e-3 end
	return a == b or math.abs(a - b) <= (math.abs(a) + 1) * epsilon
end

local function n_ROUND(x, degree, base)
	base = base or 10 -- default
	degree = degree or 0 -- default
	local n = base ^ degree
	return math.floor(x * n + 0.5) / n
end


local function FuzzyAdjacentCheck(BlockToCheck, Against)
	local Offset = Against.CFrame:ToObjectSpace(BlockToCheck.CFrame)
	--warn(Offset)
	local AbsOffset = abs(Offset)
	
	local Edges = {
		X = fuzzyEq(AbsOffset.X, BlockToCheck.Size.X/2 + Against.Size.X/2),
		Y = fuzzyEq(AbsOffset.Y, BlockToCheck.Size.Y/2 + Against.Size.Y/2),
		Z = fuzzyEq(AbsOffset.Z,BlockToCheck.Size.Z/2 + Against.Size.Z/2)
	}
	
	local Bounds = {
		X = n_ROUND(AbsOffset.X, 1) <= (BlockToCheck.Size.X/2 + Against.Size.X/2) ,
		Y = n_ROUND(AbsOffset.Y, 1) <= (BlockToCheck.Size.Y/2 + Against.Size.Y/2),
		Z = n_ROUND(AbsOffset.Z, 1) <= (BlockToCheck.Size.Z/2 + Against.Size.Z/2)
	}
	
	
	
	--print(Edges)
	--print(AbsOffset)
	
	if Bounds.X == false or Bounds.Y == false or Bounds.Z == false then return false end
	
	
	
	local Result = true
	
	if Edges.X == true and (Edges.Y == true or Edges.Z == true) then
		Result = false
	elseif Edges.Y == true and (Edges.X == true or Edges.Z == true) then
		Result = false
	elseif Edges.Z == true  and (Edges.X == true or Edges.Y == true) then
		Result = false
	end
	
	return Result
end

I am not familiar with this api but did a quick look around and there are others using it or at least trying to so perhaps it would be worth you doing a search and getting the ids and DMing them to see if they have an ideas to help you.

Could you private message me anyone trying to figure this problem out, as I didn’t find anyone yet. The posts about JoinToOutsiders are pretty old (2018 - 2019).