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

Method UpdateSourceData

trinity/Tr2ShLightingManager.cpp:394–437  ·  view source on GitHub ↗

-------------------------------------------------------------------------------------- Description: Updates packed secondary source data. --------------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

392// Updates packed secondary source data.
393// --------------------------------------------------------------------------------------
394void Tr2ShLightingManager::UpdateSourceData()
395{
396 CCP_STATS_ZONE( __FUNCTION__ );
397
398 m_sourceCount = 0;
399 size_t dataSize = sizeof( SourceData ) * ( ( m_sources.size() + m_lights.size() + 3 ) / 4 ) * 4;
400 if( m_sourceData.size() < dataSize )
401 {
402 m_sourceData.resize( "Tr2ShLightingManager.m_sourceData", dataSize );
403 }
404 if( m_sourceData.empty() )
405 {
406 return;
407 }
408 float maxLight = MaxVectorComponent( m_sunColor );
409 SourceData* data = reinterpret_cast<SourceData*>( m_sourceData.get() );
410 for( auto it = m_sources.begin(); it != m_sources.end(); ++it )
411 {
412 if( *it->radius > 0 )
413 {
414 data->position = *it->position;
415 data->radius = *it->radius;
416 data->albedo = *reinterpret_cast<const Vector3*>( it->albedo ) * m_secondaryIntensity;
417 data->cutoffMultiplier = 1;
418 data->emissive = *reinterpret_cast<const Vector3*>( it->emissive ) * m_secondaryIntensity;
419 data->maxColorComponent = std::max( MaxVectorComponent( data->albedo ) * maxLight, MaxVectorComponent( data->emissive ) );
420 ++data;
421 ++m_sourceCount;
422 }
423 }
424 for( auto it = m_lights.begin(); it != m_lights.end(); ++it )
425 {
426 Color color;
427 ( *it )->GetLight( data->position, data->radius, color );
428 data->albedo = Vector3( 0, 0, 0 );
429 data->cutoffMultiplier = 0;
430 data->emissive = *reinterpret_cast<const Vector3*>( &color ) * m_primaryIntensity;
431 data->maxColorComponent = MaxVectorComponent( data->emissive );
432 ++data;
433 ++m_sourceCount;
434 }
435 memset( data, 0, dataSize - sizeof( SourceData ) * ( m_sources.size() + m_lights.size() ) );
436 CCP_STATS_ADD( shLightingSecondarySources, m_sourceCount );
437}

Callers

nothing calls this directly

Calls 8

MaxVectorComponentFunction · 0.85
sizeMethod · 0.80
emptyMethod · 0.80
getMethod · 0.80
GetLightMethod · 0.80
Vector3Class · 0.70
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected