//----------------------------------------------------------------------------- // Computes the surrounding collision bounds from the current sequence box //----------------------------------------------------------------------------- void CCollisionProperty::ComputeRotationExpandedSequenceBounds( Vector *pVecWorldMins, Vector *pVecWorldMaxs ) { CBaseAnimating *pAnim = GetOuter()->GetBaseAnimating(); if ( !pAnim ) { ComputeOBBBounds( pVecWorldMins, pVecWorldMaxs ); return; } Vector mins, maxs; pAnim->ExtractBbox( pAnim->GetSequence(), mins, maxs ); float flRadius = MAX( MAX( FloatMakePositive( mins.x ), FloatMakePositive( maxs.x ) ), MAX( FloatMakePositive( mins.y ), FloatMakePositive( maxs.y ) ) ); mins.x = mins.y = -flRadius; maxs.x = maxs.y = flRadius; // Add bloat to account for gesture sequences Vector vecBloat( 6, 6, 0 ); mins -= vecBloat; maxs += vecBloat; // NOTE: This is necessary because the server doesn't know how to blend // animations together. Therefore, we have to just pick a box that can // surround all of our potential sequences. This should be something we // should be able to compute @ tool time instead, however. VectorMin( mins, m_vecSurroundingMins, mins ); VectorMax( maxs, m_vecSurroundingMaxs, maxs ); VectorAdd( mins, GetCollisionOrigin(), *pVecWorldMins ); VectorAdd( maxs, GetCollisionOrigin(), *pVecWorldMaxs ); }
void CLightingManager::SortLights() { #if DEBUG for ( int i = 0; i < LSORT_COUNT; i++ ) Assert( m_hPreSortedLights[ i ].Count() == 0 ); #endif m_bDrawVolumetrics = false; float zNear = m_flzNear + 2; Vector vecBloat( zNear, zNear, zNear ); Vector camMins( m_vecViewOrigin - vecBloat ); Vector camMaxs( m_vecViewOrigin + vecBloat ); #if DEFCFG_USE_SSE fltx4 zNearX4 = ReplicateX4( zNear ); for( int i = 0; i < m_uiSortDataCount; i++ ) { def_light_presortdatax4_t& s = m_pSortDataX4[i]; fltx4 adjustedMins[3] = { SubSIMD( s.bounds_min_naive[0], zNearX4 ), SubSIMD( s.bounds_min_naive[1], zNearX4 ), SubSIMD( s.bounds_min_naive[2], zNearX4 ) }; fltx4 adjustedMaxs[3] = { AddSIMD( s.bounds_max_naive[0], zNearX4 ), AddSIMD( s.bounds_max_naive[1], zNearX4 ), AddSIMD( s.bounds_max_naive[2], zNearX4 ) }; fltx4 needsFullscreen = IsPointInBoundsX4( m_vecViewOrigin, adjustedMins, adjustedMaxs ); //Jack: this is terrible I know for( int i = 0; i < s.count; i++ ) { if( s.lights[i]->IsSpot() ) { if( _isnan( SubFloat( needsFullscreen, i ) ) ) { if( !s.lights[i]->spotFrustum.CullBox( camMins, camMaxs ) ) { m_hPreSortedLights[LSORT_SPOT_FULLSCREEN].AddToTail( s.lights[i] ); } else { m_hPreSortedLights[LSORT_SPOT_WORLD].AddToTail( s.lights[i] ); } } else { m_hPreSortedLights[LSORT_SPOT_WORLD].AddToTail( s.lights[i] ); } } else { if( _isnan( SubFloat( needsFullscreen, i ) ) ) { m_hPreSortedLights[LSORT_POINT_FULLSCREEN].AddToTail( s.lights[i] ); } else { m_hPreSortedLights[LSORT_POINT_WORLD].AddToTail( s.lights[i] ); } } } fltx4 volume = AndSIMD( s.hasVolumetrics, s.hasVolumetrics ); m_bDrawVolumetrics = m_bDrawVolumetrics || !IsAllZeros( volume ); } #else FOR_EACH_VEC_FAST( def_light_t*, m_hRenderLights, l ) { bool bNeedsFullscreen = IsPointInBounds( m_vecViewOrigin, l->bounds_min_naive - vecBloat, l->bounds_max_naive + vecBloat ); if ( bNeedsFullscreen && l->IsSpot() ) { bNeedsFullscreen = !l->spotFrustum.CullBox( camMins, camMaxs ); } const bool bVolume = ( l->HasShadow() && l->HasVolumetrics() ); m_bDrawVolumetrics = m_bDrawVolumetrics || bVolume; Assert( l->iLighttype * 2 + 1 < LSORT_COUNT ); m_hPreSortedLights[ l->iLighttype * 2 + (int)bNeedsFullscreen ].AddToTail( l ); }