MCPcopy Create free account
hub / github.com/carbonengine/trinity / UpdateVisibility

Method UpdateVisibility

trinity/Eve/Turret/EveTurretSet.cpp:2053–2117  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2051}
2052
2053void EveTurretSet::UpdateVisibility( const EveUpdateContext& updateContext )
2054{
2055 m_parentShLighting = nullptr;
2056
2057 // check visibility for each single turret and keep MAX on-screen pixel diameter.
2058 // The pixel diameter is reset in UpdateLOD on next frame - this is to account for
2059 // multiple views. We need to keep updating turrets as long as they're visible in any
2060 // view, not just the last one rendered.
2061 m_visibleCount = 0;
2062
2063 // display?
2064 if( !m_display )
2065 {
2066 return;
2067 }
2068 auto& frustum = updateContext.GetFrustum();
2069
2070 for( auto& turret : m_singleTurrets )
2071 {
2072 // transform bounding sphere into world space to check against frustum
2073 Vector4 transformedBoundingSphere = m_boundingSphere;
2074 GetDynamicBounds( turret, &transformedBoundingSphere, nullptr, nullptr );
2075 BoundingSphereTransform( turret.worldMatrix, transformedBoundingSphere );
2076 turret.visible = frustum.IsSphereVisible( &transformedBoundingSphere );
2077 // count visible turrets of this set, mainly for debug purposes
2078 if( turret.visible )
2079 {
2080 // one more visible turret
2081 ++m_visibleCount;
2082 // how big is it on screen? Attention: we want the max diameter, since we only have one lodlevel per multiple instanced turrets!
2083 float currentPixelDiameter = frustum.GetPixelSizeAccross( &transformedBoundingSphere );
2084 if( currentPixelDiameter > m_estimatedPixelDiameter )
2085 {
2086 m_estimatedPixelDiameter = currentPixelDiameter;
2087 }
2088 }
2089 }
2090
2091 if( m_displayEffects && m_firingEffect )
2092 {
2093 m_firingEffect->UpdateVisibility( updateContext );
2094 }
2095
2096 auto ambientEffect = GetAmbientEffectOrGeneratedEffect();
2097 if( ambientEffect )
2098 {
2099 Tr2Lod currentLod = Tr2Lod::TR2_LOD_HIGH;
2100 if( m_lodLevel == LOD::LOD_EMPTY )
2101 {
2102 currentLod = Tr2Lod::TR2_LOD_LOW;
2103 }
2104 else if( m_lodLevel == LOD::LOD_INVALID )
2105 {
2106 currentLod = Tr2Lod::TR2_LOD_UNSPECIFIED;
2107 }
2108
2109 ambientEffect->UpdateVisibility( updateContext, m_parentData.transform, currentLod );
2110 }

Callers

nothing calls this directly

Calls 4

BoundingSphereTransformFunction · 0.85
GetFrustumMethod · 0.80
IsSphereVisibleMethod · 0.80
GetPixelSizeAccrossMethod · 0.80

Tested by

no test coverage detected