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

Method UpdateVisibility

trinity/Eve/UI/EveTacticalOverlay.cpp:218–327  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

216}
217
218void EveTacticalOverlay::UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform )
219{
220 m_connectorBuffer.clear();
221 m_anchorBuffer.clear();
222 m_velocityBuffer.clear();
223
224 Vector3 up( 0, 1, 0 );
225 float distanceThreshold = ( m_ranges.x + m_ranges.y ) * m_ranges.z;
226 float requestedSegments = 0.f;
227 auto& frustum = updateContext.GetFrustum();
228
229 for( auto it = m_trackObjects.begin(); it != m_trackObjects.end(); it++ )
230 {
231 Vector3 position = ( *it )->GetPosition();
232 float radius = ( *it )->GetRadius();
233 Vector3 direction = position - m_rootPosition;
234 float distance = Length( direction );
235 if( distance > distanceThreshold )
236 {
237 continue;
238 }
239
240 direction.y = 0;
241 direction = Normalize( direction );
242 if( !( direction.x || direction.z ) )
243 {
244 direction.x = 0.01;
245 }
246 Vector3 positionPlane = m_rootPosition + direction * distance;
247 Vector4 bs;
248 BoundingSphereFromPoints( bs, position, positionPlane );
249 if( !frustum.IsSphereVisible( &bs ) )
250 {
251 continue;
252 }
253
254 float pixelDiameter = frustum.GetPixelSizeAccross( &bs );
255 float segments = GetSubdivisionCount( pixelDiameter, m_connectorSegmentsLow, m_connectorSegmentsMedium, m_connectorSegmentsHigh, updateContext );
256 if( segments != 0 )
257 {
258 Vector2 planarDiff( positionPlane.x - position.x, positionPlane.z - position.z );
259 float length = Length( planarDiff );
260 float height = std::abs( position.y - positionPlane.y );
261 // Wide arches need more segments to look good
262 segments *= 1.f + m_arcSegmentMultiplier * length / height;
263 requestedSegments += segments * m_segmentCountMultiplier;
264 if( m_requestedSegmentsLast && m_requestedSegmentsLast > m_targetSegmentCount )
265 {
266 segments *= m_targetSegmentCount / m_requestedSegmentsLast;
267 segments = max( segments, 1.f );
268 }
269 segments = m_segmentCountMultiplier * floor( segments + 0.5f );
270 }
271 float counter = radius > m_minRadiusForRange ? segments + 1 : segments;
272 float interestReducedIntensity = 0.0;
273 if( m_interestRange > 0.0001f && ( distance - radius - m_ranges.w ) > m_interestRange )
274 {
275 interestReducedIntensity = 1 - m_outsideInterestIntensity;

Callers

nothing calls this directly

Calls 12

LengthFunction · 0.85
BoundingSphereFromPointsFunction · 0.85
GetSubdivisionCountFunction · 0.85
GetFrustumMethod · 0.80
IsSphereVisibleMethod · 0.80
GetPixelSizeAccrossMethod · 0.80
sizeMethod · 0.80
Vector4Class · 0.50
beginMethod · 0.45
endMethod · 0.45
GetPositionMethod · 0.45
GetRadiusMethod · 0.45

Tested by

no test coverage detected