@@ -2107,17 +2107,17 @@ void CViewRender::RenderView( const CViewSetup &view, int nClearFlags, int whatT
2107
2107
GeneratePerspectiveFrustum ( view.origin , view.angles , view.zNear , view.zFar , view.fov , view.m_flAspectRatio , frustum );
2108
2108
2109
2109
Vector vecAbsPlaneNormal;
2110
- Vector vecPlaneLocalOrigin ;
2111
- C_FuncFakeWorldPortal *pPortalEnt = NextFakeWorldPortal ( NULL , view, vecAbsPlaneNormal, vecPlaneLocalOrigin , frustum );
2110
+ float flLocalPlaneDist ;
2111
+ C_FuncFakeWorldPortal *pPortalEnt = NextFakeWorldPortal ( NULL , view, vecAbsPlaneNormal, flLocalPlaneDist , frustum );
2112
2112
while ( pPortalEnt != NULL )
2113
2113
{
2114
2114
ITexture *pCameraTarget = pPortalEnt->RenderTarget ();
2115
2115
int width = pCameraTarget->GetActualWidth ();
2116
2116
int height = pCameraTarget->GetActualHeight ();
2117
2117
2118
- DrawFakeWorldPortal ( pCameraTarget, pPortalEnt, viewMiddle, C_BasePlayer::GetLocalPlayer (), 0 , 0 , width, height, view, vecAbsPlaneNormal, vecPlaneLocalOrigin );
2118
+ DrawFakeWorldPortal ( pCameraTarget, pPortalEnt, viewMiddle, C_BasePlayer::GetLocalPlayer (), 0 , 0 , width, height, view, vecAbsPlaneNormal, flLocalPlaneDist );
2119
2119
2120
- pPortalEnt = NextFakeWorldPortal ( pPortalEnt, view, vecAbsPlaneNormal, vecPlaneLocalOrigin , frustum );
2120
+ pPortalEnt = NextFakeWorldPortal ( pPortalEnt, view, vecAbsPlaneNormal, flLocalPlaneDist , frustum );
2121
2121
}
2122
2122
#endif
2123
2123
}
@@ -3551,7 +3551,7 @@ bool CViewRender::DrawOneMonitor( ITexture *pRenderTarget, int cameraNum, C_Poin
3551
3551
// -----------------------------------------------------------------------------
3552
3552
bool CViewRender::DrawFakeWorldPortal ( ITexture *pRenderTarget, C_FuncFakeWorldPortal *pCameraEnt, const CViewSetup &cameraView, C_BasePlayer *localPlayer,
3553
3553
int x, int y, int width, int height,
3554
- const CViewSetup &mainView, const Vector &vecAbsPlaneNormal, const Vector &vecPlaneLocalOrigin )
3554
+ const CViewSetup &mainView, const Vector &vecAbsPlaneNormal, float flLocalPlaneDist )
3555
3555
{
3556
3556
#ifdef USE_MONITORS
3557
3557
VPROF_INCREMENT_COUNTER ( " cameras rendered" , 1 );
@@ -3652,15 +3652,15 @@ bool CViewRender::DrawFakeWorldPortal( ITexture *pRenderTarget, C_FuncFakeWorldP
3652
3652
3653
3653
Vector4D plane;
3654
3654
3655
+ // target direction
3655
3656
MatrixGetColumn ( targetToWorld, 0 , plane.AsVector3D () );
3656
3657
VectorNormalize ( plane.AsVector3D () );
3657
3658
VectorNegate ( plane.AsVector3D () );
3658
3659
3659
- // The portal plane's distance from the actual brush's origin
3660
- float flPlaneDist = vecPlaneLocalOrigin.Length ();
3661
-
3662
- // The target's distance from world origin
3663
- plane.w = -((pCameraEnt->m_hTargetPlane ->GetAbsOrigin () * plane.AsVector3D ()).Length () + flPlaneDist) + 0 .1f ;
3660
+ plane.w =
3661
+ MatrixColumnDotProduct ( targetToWorld, 3 , plane.AsVector3D () ) // target clip plane distance
3662
+ - flLocalPlaneDist // portal plane distance on the brush. This distance needs to be accounted for while placing the exit target
3663
+ - 0.1 ;
3664
3664
3665
3665
CMatRenderContextPtr pRenderContext ( materials );
3666
3666
pRenderContext->PushCustomClipPlane ( plane.Base () );
0 commit comments