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

Method AddPointLight

trinity/Tr2LightManager.cpp:297–332  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

295}
296
297void Tr2LightManager::AddPointLight( const Vector3& position, float radius, const Color& color, Float_16 innerRadius, uint16_t flags )
298{
299 if( !AreLightFlagsValid( flags ) )
300 {
301 return;
302 }
303 PerLightData data;
304 data.position = position;
305 data.radius = radius;
306 float brightness = std::max( std::max( color.r, color.g ), color.b );
307 if( brightness <= 0 )
308 {
309 return;
310 }
311 if( !m_frustum.IsSphereVisible( reinterpret_cast<Vector4*>( &data.position ) ) )
312 {
313 return;
314 }
315
316 float size = m_frustum.GetPixelSizeAccross( reinterpret_cast<Vector4*>( &data.position ) );
317
318 if( size > m_adjustedCutoff )
319 {
320 float dimming = std::min( ( size - m_adjustedCutoff ) / FADE_SIZE, 1.f );
321 data.color = reinterpret_cast<const Vector3&>( color );
322 data.color.x *= radius * dimming;
323 data.color.y *= radius * dimming;
324 data.color.z *= radius * dimming;
325 data.innerRadius = innerRadius;
326 data.flags = flags;
327 data.direction = Vector3_16( Vector3( 1.f, 0.f, 0.f ) );
328 data.outerAngle = Float_16( 0.f );
329 data.innerAngle = Float_16( 0.f );
330 m_tlsLightData.local().push_back( data );
331 }
332}
333
334void Tr2LightManager::AddLight( PerLightData& data )
335{

Callers 2

GetLightsMethod · 0.80
AddLightMethod · 0.80

Calls 3

IsSphereVisibleMethod · 0.80
GetPixelSizeAccrossMethod · 0.80
Vector3Class · 0.70

Tested by

no test coverage detected