Camera:GetLargestCutOffDistance() clipping into parts slightly

In the attached image the section with the red squiggle is actually supposed to be a part, hence my camera system is clipping slightly through the part.

camera.Focus is set to the player’s head.
The CFrame I calculate the GetLargestCutOffDistance from is the camera CFrame that it would be with no obstructions.

If the distance returned is greater than zero I move the camera the returned distance towards the camera focus.

Hence I am confused as to why this is not working!

Edit: I should say that it is “working” in that it moves the camera in the correct direction and mostly the correct distance however the issue is why it isn’t moving it the “full” distance needed to prevent this clipping.

Code:

local function UpdateCamera(mousedelta)
    local crX = currentrotation.X
    local crY = currentrotation.Y
    if player.Character ~= nil then
	crX = crX - math.rad(mousedelta.X)*sensitivity
	crY = crY - math.rad(mousedelta.Y)*sensitivity
	
	crX = crX % (2*math.pi)
	if crY > math.rad(70) then
		crY = math.rad(70)
	elseif crY < math.rad(-70) then
		crY = math.rad(-70)
	end
	currentrotation = Vector2.new(crX,crY)
	local goalCFrame = CFrame.new(player.Character.HumanoidRootPart.CFrame.Position)
	* CFrame.Angles(0,currentrotation.X + recoil.X,0) -- possibly consider moving these recoil factors into the crX and crY system
	* CFrame.Angles(currentrotation.Y + recoil.Y,0,0)
	*CFrame.new(0,0,zoom)
	* CFrame.new(2.5,2.5,0) -- offset
	cam.Focus = player.Character.HumanoidRootPart.CFrame * CFrame.new(0,2,0)
	cam.CFrame = goalCFrame
	local popdistance = cam:GetLargestCutoffDistance({player.Character}) -- ignore list is simply the character for now
	cam.CFrame = cam.CFrame - ((popdistance) * (cam.CFrame.Position - cam.Focus.Position).unit)
    end
end

I know very little about the specifics of game cameras, but I assume GetLargestCutoffDistance isn’t accounting for the offset of the Near culling plane from the Camera’s location.

I.e. as far as the math is concerned - that invisible section of wall is there, it’s just not getting rendered!

The only method I know of to fix this (beyond yell at the Lua API team about this bug) is to make all your walls two Parts deep, with about 0.2-0.5 studs of “thickness” on the outer wall. That way, even if the outer veneer gets clipped out, as in your screenshot, the inner portion will still get rendered.

Thanks for the reply. I’ve found a fix in just increasing the distance the camera is moved towards the focus by an arbitrary constant (0.15 studs I think is what I set it at).

I appreciate your solution but it feels like too much hassle to implement especially when dealing with terrain.

Hopefully this issue is fixed at some point, I will try posting a bug report.