function PopperCam.Update(i,h)if PopperEnabled then local i=Camera.CFrame local a=Camera.Focus.p if FFlagUserPortraitPopperFix and SubjectPart then a=SubjectPart.CFrame.p end local M={}for h,i in pairs(PlayerCharacters)do M[#M+1]=i end for h=1,#VehicleParts,1 do M[#M+1]=VehicleParts[h]end local r=Camera:GetLargestCutoffDistance(M)local H=(i.p-a).Magnitude if math_abs(H-LastZoomLevel)>.001 then LastPopAmount=0 end local v=r if LastPopAmount>v then v=LastPopAmount end if v>0 then Camera.CFrame=i+i.lookVector*v LastPopAmount=v-POP_RESTORE_RATE if LastPopAmount<0 then LastPopAmount=0 end end LastZoomLevel=H if h and(h:GetShiftLock()and not h:IsInFirstPerson())then if h:GetCameraActualZoom()<1 then local i=h.lastSubjectPosition if i then Camera.Focus=CFrame_new(i)Camera.CFrame=CFrame_new(i-MIN_CAMERA_ZOOM*h:GetCameraLook(),i)end end end end end


function PopperCam:Update(EnabledCamera)
	if PopperEnabled then
		-- First, prep some intermediate vars
		local cameraCFrame = Camera.CFrame
		local focusPoint = Camera.Focus.p

		if FFlagUserPortraitPopperFix and SubjectPart then
			focusPoint = SubjectPart.CFrame.p
		end

		local ignoreList = {}
		for _, character in pairs(PlayerCharacters) do
			ignoreList[#ignoreList + 1] = character
		end
		for i = 1, #VehicleParts do
			ignoreList[#ignoreList + 1] = VehicleParts[i]
		end
		
		-- Get largest cutoff distance
		local largest = Camera:GetLargestCutoffDistance(ignoreList)

		-- Then check if the player zoomed since the last frame,
		-- and if so, reset our pop history so we stop tweening
		local zoomLevel = (cameraCFrame.p - focusPoint).Magnitude
		if math_abs(zoomLevel - LastZoomLevel) > 0.001 then
			LastPopAmount = 0
		end
		
		-- Finally, zoom the camera in (pop) by that most-cut-off amount, or the last pop amount if that's more
		local popAmount = largest
		if LastPopAmount > popAmount then
			popAmount = LastPopAmount
		end

		if popAmount > 0 then
			Camera.CFrame = cameraCFrame + (cameraCFrame.lookVector * popAmount)
			LastPopAmount = popAmount - POP_RESTORE_RATE -- Shrink it for the next frame
			if LastPopAmount < 0 then
				LastPopAmount = 0
			end
		end

		LastZoomLevel = zoomLevel
		
		-- Stop shift lock being able to see through walls by manipulating Camera focus inside the wall
		if EnabledCamera and EnabledCamera:GetShiftLock() and not EnabledCamera:IsInFirstPerson() then
			if EnabledCamera:GetCameraActualZoom() < 1 then
				local subjectPosition = EnabledCamera.lastSubjectPosition 
				if subjectPosition then
					Camera.Focus = CFrame_new(subjectPosition)
					Camera.CFrame = CFrame_new(subjectPosition - MIN_CAMERA_ZOOM*EnabledCamera:GetCameraLook(), subjectPosition)
				end
			end
		end
	end
end
