Camera:GetLargestCutoffDistance Source?

Since Camera:GetLargestCutoffDistance is deprecated (Camera | Roblox Creator Documentation), I have to create my own method to get the “Largest Cutoff Distance”.
For some reason even though I managed to achieve identical results there seems to be some imprecision on the x-axis. If somebody has the source of the original camera method or has achieved 100% identical results please share it with me.

function SCamera:GetLargestCutOffDistance(CameraCFrame: CFrame,Focus: CFrame)
	local Origin = Focus.Position
	local Direction = CameraCFrame.Position - Focus.Position 
	local RaycastResult: RaycastResult = workspace:Raycast(Origin,Direction,self.RayParams)
	
	if RaycastResult then
		return (RaycastResult.Position - CameraCFrame.Position).Magnitude 
	else
		return 0 
	end
end 
1 Like

Hello,

I just found this post from searching up this topic myself while trying to implement my own occulsion

Quote from the GetLargestCutoffDistance() documentation,

This function is used by ‘PopperCam’ in the default camera scripts to ensure obstructions do not come between the Camera and the Camera’s subject.

The replacement for this deprecated method seems to be implemented in the Roblox default camera modules as a function.

The new function can be found in PlayerModule.CameraModule.ZoomControler.Popper
Make a copy of the PlayerModule during runtime and paste it back into StarterPlayerScripts ,
then from there you can access the Popper by requiring the module.

From my limited testing, the Popper() function seems to returns the same as GetLargestCutoffDistance().
i.e. “the distance that the Camera needs to be pushed towards its Camera.Focus to ensure there are no obstructions between the Camera.Focus and Camera.CFrame of the Camera.”

Hope this will help you

3 Likes

Thank you for taking the time to share this with me. I took a quick look at the Popper module it seems to serve the same purpose. I will test to confirm as soon I can and mark your reply as the solution.

1 Like

Apologies for the very late response but it seems the Popper function returns another kind of distance. If somebody has found the GetLargestCutoffDistance source feel free to enlighten me.

Edit: It seems like the Popper returns the maximum distance from the focus point. (while factoring occlusion)

1 Like