MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/Falcor / updateLights

Method updateLights

Source/Falcor/Scene/Scene.cpp:1591–1643  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1589 }
1590
1591 IScene::UpdateFlags Scene::updateLights(bool forceUpdate)
1592 {
1593 Light::Changes combinedChanges = Light::Changes::None;
1594
1595 // Animate lights and get list of changes.
1596 for (const auto& light : mLights)
1597 {
1598 if (light->isActive() || forceUpdate)
1599 {
1600 updateAnimatable(*light, *mpAnimationController, forceUpdate);
1601 }
1602
1603 auto changes = light->beginFrame();
1604 combinedChanges |= changes;
1605 }
1606
1607 // Update changed lights.
1608 uint32_t activeLightIndex = 0;
1609 mActiveLights.clear();
1610
1611 for (const auto& light : mLights)
1612 {
1613 if (!light->isActive()) continue;
1614
1615 mActiveLights.push_back(light);
1616
1617 auto changes = light->getChanges();
1618 if (changes != Light::Changes::None || is_set(combinedChanges, Light::Changes::Active) || forceUpdate)
1619 {
1620 // TODO: This is slow since the buffer is not CPU writable. Copy into CPU buffer and upload once instead.
1621 mpLightsBuffer->setElement(activeLightIndex, light->getData());
1622 }
1623
1624 activeLightIndex++;
1625 }
1626
1627 if (combinedChanges != Light::Changes::None || forceUpdate)
1628 {
1629 mpSceneBlock->getRootVar()["lightCount"] = (uint32_t)mActiveLights.size();
1630 updateLightStats();
1631 }
1632
1633 // Compute update flags.
1634 IScene::UpdateFlags flags = IScene::UpdateFlags::None;
1635 if (is_set(combinedChanges, Light::Changes::Intensity)) flags |= IScene::UpdateFlags::LightIntensityChanged;
1636 if (is_set(combinedChanges, Light::Changes::Position)) flags |= IScene::UpdateFlags::LightsMoved;
1637 if (is_set(combinedChanges, Light::Changes::Direction)) flags |= IScene::UpdateFlags::LightsMoved;
1638 if (is_set(combinedChanges, Light::Changes::Active)) flags |= IScene::UpdateFlags::LightCountChanged;
1639 const Light::Changes otherChanges = ~(Light::Changes::Intensity | Light::Changes::Position | Light::Changes::Direction | Light::Changes::Active);
1640 if ((combinedChanges & otherChanges) != Light::Changes::None) flags |= IScene::UpdateFlags::LightPropertiesChanged;
1641
1642 return flags;
1643 }
1644
1645 void Scene::bindLights()
1646 {

Callers

nothing calls this directly

Calls 6

getRootVarMethod · 0.80
beginFrameMethod · 0.45
clearMethod · 0.45
push_backMethod · 0.45
getDataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected