Skip to content

Commit e37853b

Browse files
Fix func_fake_worldportal clip plane
1 parent dfee2e7 commit e37853b

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

sp/src/game/client/mapbase/c_func_fake_worldportal.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ bool C_FuncFakeWorldPortal::ShouldDraw()
6262
// Iterates through fake world portals instead of just picking one
6363
//-----------------------------------------------------------------------------
6464
C_FuncFakeWorldPortal *NextFakeWorldPortal( C_FuncFakeWorldPortal *pStart, const CViewSetup& view,
65-
Vector &vecAbsPlaneNormal, Vector &vecPlaneLocalOrigin, const Frustum_t &frustum )
65+
Vector &vecAbsPlaneNormal, float &flLocalPlaneDist, const Frustum_t &frustum )
6666
{
6767
// Early out if no cameras
6868
C_FuncFakeWorldPortal *pReflectiveGlass = NULL;
@@ -109,7 +109,7 @@ C_FuncFakeWorldPortal *NextFakeWorldPortal( C_FuncFakeWorldPortal *pStart, const
109109
if ( vecDelta.Dot( worldPlane.normal ) >= 0 ) // Backface cull
110110
continue;
111111

112-
vecPlaneLocalOrigin = vecLocalOrigin;
112+
flLocalPlaneDist = localPlane.dist;
113113
vecAbsPlaneNormal = worldPlane.normal;
114114

115115
return pReflectiveGlass;

sp/src/game/client/mapbase/c_func_fake_worldportal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class C_FuncFakeWorldPortal : public C_BaseEntity
5454
// Do we have reflective glass in view? If so, what's the reflection plane?
5555
//-----------------------------------------------------------------------------
5656
C_FuncFakeWorldPortal *NextFakeWorldPortal( C_FuncFakeWorldPortal *pStart, const CViewSetup& view,
57-
Vector &vecAbsPlaneNormal, Vector &vecPlaneOrigin, const Frustum_t &frustum );
57+
Vector &vecAbsPlaneNormal, float &flLocalPlaneDist, const Frustum_t &frustum );
5858

5959

6060
#endif // C_FUNC_FAKE_WORLDPORTAL

sp/src/game/client/viewrender.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2107,17 +2107,17 @@ void CViewRender::RenderView( const CViewSetup &view, int nClearFlags, int whatT
21072107
GeneratePerspectiveFrustum( view.origin, view.angles, view.zNear, view.zFar, view.fov, view.m_flAspectRatio, frustum );
21082108

21092109
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 );
21122112
while ( pPortalEnt != NULL )
21132113
{
21142114
ITexture *pCameraTarget = pPortalEnt->RenderTarget();
21152115
int width = pCameraTarget->GetActualWidth();
21162116
int height = pCameraTarget->GetActualHeight();
21172117

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 );
21192119

2120-
pPortalEnt = NextFakeWorldPortal( pPortalEnt, view, vecAbsPlaneNormal, vecPlaneLocalOrigin, frustum );
2120+
pPortalEnt = NextFakeWorldPortal( pPortalEnt, view, vecAbsPlaneNormal, flLocalPlaneDist, frustum );
21212121
}
21222122
#endif
21232123
}
@@ -3551,7 +3551,7 @@ bool CViewRender::DrawOneMonitor( ITexture *pRenderTarget, int cameraNum, C_Poin
35513551
//-----------------------------------------------------------------------------
35523552
bool CViewRender::DrawFakeWorldPortal( ITexture *pRenderTarget, C_FuncFakeWorldPortal *pCameraEnt, const CViewSetup &cameraView, C_BasePlayer *localPlayer,
35533553
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 )
35553555
{
35563556
#ifdef USE_MONITORS
35573557
VPROF_INCREMENT_COUNTER( "cameras rendered", 1 );
@@ -3652,15 +3652,15 @@ bool CViewRender::DrawFakeWorldPortal( ITexture *pRenderTarget, C_FuncFakeWorldP
36523652

36533653
Vector4D plane;
36543654

3655+
// target direction
36553656
MatrixGetColumn( targetToWorld, 0, plane.AsVector3D() );
36563657
VectorNormalize( plane.AsVector3D() );
36573658
VectorNegate( plane.AsVector3D() );
36583659

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;
36643664

36653665
CMatRenderContextPtr pRenderContext( materials );
36663666
pRenderContext->PushCustomClipPlane( plane.Base() );

sp/src/game/client/viewrender.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ class CViewRender : public IViewRender,
454454
#ifdef MAPBASE
455455
bool DrawFakeWorldPortal( ITexture *pRenderTarget, C_FuncFakeWorldPortal *pCameraEnt, const CViewSetup &cameraView, C_BasePlayer *localPlayer,
456456
int x, int y, int width, int height,
457-
const CViewSetup &mainView, Vector &vecAbsPlaneNormal, const Vector &vecPlaneOrigin );
457+
const CViewSetup &mainView, const Vector &vecAbsPlaneNormal, float flLocalPlaneDist );
458458
#endif
459459

460460
// Drawing primitives

0 commit comments

Comments
 (0)