@@ -302,6 +302,8 @@ class CClientLeafSystem : public IClientLeafSystem, public ISpatialLeafEnumerato
302302
303303 void CalcRenderableWorldSpaceAABB_Bloated ( const RenderableInfo_t &info, Vector &absMin, Vector &absMax );
304304
305+ bool ShouldRenderableBeIgnored (IClientRenderable* pRenderable);
306+
305307 // Methods associated with the various bi-directional sets
306308 static unsigned short & FirstRenderableInLeaf ( int leaf )
307309 {
@@ -2455,8 +2457,6 @@ void CClientLeafSystem::AddDependentRenderables( const SetupRenderInfo_t &info )
24552457 }
24562458}
24572459
2458-
2459-
24602460// -----------------------------------------------------------------------------
24612461// Adds renderables into their final lists
24622462// -----------------------------------------------------------------------------
@@ -2544,6 +2544,69 @@ void CClientLeafSystem::AddRenderablesToRenderLists( const SetupRenderInfo_t &in
25442544
25452545static ConVar r_drawallrenderables ( " r_drawallrenderables" , " 0" , FCVAR_CHEAT, " Draw all renderables, even ones inside solid leaves." );
25462546
2547+ // -----------------------------------------------------------------------------
2548+ // Ignore renderables based on 16:9 aspect ratio and alien entities
2549+ // -----------------------------------------------------------------------------
2550+ bool CClientLeafSystem::ShouldRenderableBeIgnored (IClientRenderable* pRenderable)
2551+ {
2552+ // check for screen aspect ratio
2553+ if (((float )ScreenWidth ()) / ((float )ScreenHeight ()) <= 16 .0f / 9 .0f )
2554+ {
2555+ return false ;
2556+ }
2557+
2558+ // check if it is an alien entity
2559+ IClientUnknown* pUnknown = pRenderable->GetIClientUnknown ();
2560+ if (!pUnknown)
2561+ {
2562+ return false ;
2563+ }
2564+ C_BaseEntity* pEntity = pUnknown->GetBaseEntity ();
2565+ if (!pEntity || !pEntity->IsAlien ())
2566+ {
2567+ return false ;
2568+ }
2569+
2570+ // calculate the left and right bounds of the 16:9 area
2571+ int left = (ScreenWidth () >> 1 ) - ((ScreenHeight () << 3 ) / 9 );
2572+ int right = (ScreenWidth () >> 1 ) + ((ScreenHeight () << 3 ) / 9 );
2573+
2574+ // get the world space AABB of the alien's collision box
2575+ Vector vecMins, vecMaxs;
2576+ pEntity->CollisionProp ()->WorldSpaceAABB (&vecMins, &vecMaxs);
2577+
2578+ // check the 8 corners of the AABB
2579+ Vector corners[8 ] = {
2580+ Vector (vecMins.x , vecMins.y , vecMins.z ),
2581+ Vector (vecMins.x , vecMins.y , vecMaxs.z ),
2582+ Vector (vecMins.x , vecMaxs.y , vecMins.z ),
2583+ Vector (vecMins.x , vecMaxs.y , vecMaxs.z ),
2584+ Vector (vecMaxs.x , vecMins.y , vecMins.z ),
2585+ Vector (vecMaxs.x , vecMins.y , vecMaxs.z ),
2586+ Vector (vecMaxs.x , vecMaxs.y , vecMins.z ),
2587+ Vector (vecMaxs.x , vecMaxs.y , vecMaxs.z )
2588+ };
2589+
2590+ // check if any of the corners are in the 16:9 area
2591+ for (int i = 0 ; i < 8 ; i++)
2592+ {
2593+ Vector screenPos;
2594+ // ScreenPosition: returns 0 if the point is on screen, 1 if off screen
2595+ if (debugoverlay->ScreenPosition (corners[i], screenPos) == 0 )
2596+ {
2597+ // if the screen x pos is in the 16:9 area
2598+ if (screenPos.x >= left && screenPos.x <= right)
2599+ {
2600+ // return the base result
2601+ return false ;
2602+ }
2603+ }
2604+ }
2605+
2606+ // none of the corners are in the 16:9 area, so don't draw
2607+ return true ;
2608+ }
2609+
25472610// -----------------------------------------------------------------------------
25482611// Main entry point to build renderable lists
25492612// -----------------------------------------------------------------------------
@@ -2569,6 +2632,12 @@ void CClientLeafSystem::BuildRenderablesList( const SetupRenderInfo_t &info )
25692632
25702633 for ( int i = m_Renderables.Head (); i != m_Renderables.InvalidIndex (); i = m_Renderables.Next ( i ) )
25712634 {
2635+ RenderableInfo_t& renderableInfo = m_Renderables[i];
2636+ // ignore aliens outside 16:9 area - only for main view
2637+ if (info.m_nViewID == VIEW_MAIN && ShouldRenderableBeIgnored (renderableInfo.m_pRenderable ))
2638+ {
2639+ continue ; // skip this renderable
2640+ }
25722641 orderedList.AddToTail ( &m_Renderables[ i ] );
25732642 }
25742643 }
@@ -2584,6 +2653,12 @@ void CClientLeafSystem::BuildRenderablesList( const SetupRenderInfo_t &info )
25842653 unsigned short idx = m_RenderablesInLeaf.FirstElement (leaf);
25852654 for ( ; idx != m_RenderablesInLeaf.InvalidIndex (); idx = m_RenderablesInLeaf.NextElement ( idx ) )
25862655 {
2656+ RenderableInfo_t& renderableInfo = m_Renderables[m_RenderablesInLeaf.Element (idx)];
2657+ // ignore aliens outside 16:9 area - only for main view
2658+ if (info.m_nViewID == VIEW_MAIN && ShouldRenderableBeIgnored (renderableInfo.m_pRenderable ))
2659+ {
2660+ continue ; // skip this renderable
2661+ }
25872662 orderedList.AddToTail ( &m_Renderables[ m_RenderablesInLeaf.Element (idx) ] );
25882663 }
25892664 }
0 commit comments