I was working on a plugin that helps me create symmetrical models by automatically mirroring and centering parts as I move them.
To mirror CFrames I have always used this code that I found using trial and error a few years back:
local function MirrorCFrameX(cf)
local x, y, z, xx, xy, xz, yx, yy, yz, zx, zy, zz = cf:components()
return CFrame.new(-x, y, z, xx, -xy, -xz, -yx, yy, yz, -zx, zy, zz)
end
I managed to come up with this unresolvable CSG case which seems extremely simple (the 2 red parts):
The green parts successfully union, and I obtained them by trying to tweak the mirror code.
The parts in each set are practically coplanar, and the red parts will fail to union as long as they are intersecting.
I was curious if my CFrame’s were just malformed or something, so I put together something to visualize their orientations using the components of their CFrames:
And they appear to be exactly the same…
The only difference I could find was in the mirrored part’s Rotation (which I think are still technically the same):
Broken (red):
Right: (-179.998, 44.366, 179.998)
Left: (-179.998, -44.366, -179.998)
Fixed (green):
Right: (-179.998, 44.366, 179.998)
Left: ( 179.998, -44.366, 179.998)
Also, (A little off-topic)
I made it so syncs the mirrored parts’ properties, and I think it’s a bit weird that Part.Transparency is actually set while using the rotate/translate studio tools