Portal Gun PVS Problem

I’ll start with some video first. Mouse over the annotations in the top right.

If you moused over the annotations, it tells you that the little video monitor in the top right is a 2D render of the ORANGE portal, minus the oval shaped stencil.

When I move out of the visleaf, it stops rendering the scene. I know what you’re thinking. “DERP, DUDE. AddOriginToPVS()” Here’s my code:

hook.Add(“SetupPlayerVisibility”, “Add portalPVS”, function(ply,ve)
for k,self in pairs(ents.FindByClass(“prop_portal”))do
local other = self:GetNWEntity(“Potal:Other”)
if (not other) or (not IsValid(other)) then continue end
local origin = ply:EyePos()
local angles = ply:EyeAngles()

	local normal = self:GetForward()
	local distance = normal:Dot( self:GetPos() )

	// quick access
	local forward = angles:Forward()
	local up = angles:Up()

	// reflect origin
	local dot = origin:DotProduct( normal ) - distance
	origin = origin + ( -2 * dot ) * normal

	// reflect forward
	local dot = forward:DotProduct( normal )
	forward = forward + ( -2 * dot ) * normal

	// reflect up          
	local dot = up:DotProduct( normal )
	up = up + ( -2 * dot ) * normal
	local ViewOrigin = self:WorldToLocal( origin )
	// repair
	ViewOrigin.y = -ViewOrigin.y
	ViewOrigin = other:LocalToWorld( ViewOrigin )
	AddOriginToPVS(ViewOrigin) --Add the viewpoint of the portal to the PVS.
	AddOriginToPVS(self:GetPos()) --Add portal's location to the PVS


This is being run serverside. I know it runs and it gets as far as AddOriginToPVS because I’ve done MsgN debugging.
Thought it might not seem like a problem in the video, i.e. you can’t see the portal when it stops rendering, the video was captured in the least confusing manner possible. This is causing issues for portals which span across visleafs.

Also, I know it’s an issue with PVS because when I run r_novis 1 everything works fine. (Unfortunately this method is inefficient and requires sv_cheats).

Any reason it it’s not adding my portal to the PVS?

Alternatively, this entire issue could be skipped if I could somehow change r_novis to 1 without enabling sv_cheats.