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

Method UpdateVisibility

trinity/Eve/SpaceObject/EveMissileWarhead.cpp:109–158  ·  view source on GitHub ↗

--------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

107
108// --------------------------------------------------------------------------------
109void EveMissileWarhead::UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform )
110{
111 m_isVisible = false;
112
113 // don't give out renderables until this warhead has valid data
114 if( !m_startDataValid || m_state == STATE_DEAD )
115 {
116 return;
117 }
118
119 m_lodLevel = TR2_LOD_LOW;
120
121 // is this one here enabled?
122 if( ( m_hideOnLowQuality && Tr2Renderer::IsLowQuality() ) || !m_display )
123 {
124 return;
125 }
126 auto& frustum = updateContext.GetFrustum();
127 m_isVisible = true;
128 UpdateViewDependentData( frustum, parentTransform );
129
130 if( m_mesh )
131 {
132 Vector4 boundingSphere;
133 if( GetBoundingSphere( boundingSphere ) )
134 {
135 // check visibility with camera or, if threshold set to negative, no culling
136 if( frustum.IsSphereVisible( &boundingSphere ) )
137 {
138 float estimatedSize = frustum.GetPixelSizeAccross( &boundingSphere );
139 if( estimatedSize >= updateContext.GetMediumDetailThreshold() )
140 {
141 m_lodLevel = TR2_LOD_HIGH;
142 }
143 // we use VisibilityThreshold instead of LowDetailThreshold because we
144 // completely hide warhead mesh on low LOD
145 else if( estimatedSize >= updateContext.GetVisibilityThreshold() )
146 {
147 m_lodLevel = TR2_LOD_MEDIUM;
148 }
149 }
150 }
151 }
152
153 // update stats if we see it
154 if( m_isVisible )
155 {
156 CCP_STATS_INC( eveVisibleWarheadObjects );
157 }
158}
159
160// --------------------------------------------------------------------------------
161bool EveMissileWarhead::GetBoundingSphere( Vector4& sphere, BoundingSphereQuery ) const

Callers

nothing calls this directly

Calls 6

GetBoundingSphereFunction · 0.85
GetFrustumMethod · 0.80
IsSphereVisibleMethod · 0.80
GetPixelSizeAccrossMethod · 0.80

Tested by

no test coverage detected