| 1656 | } |
| 1657 | |
| 1658 | IScene::UpdateFlags Scene::updateGridVolumes(bool forceUpdate) |
| 1659 | { |
| 1660 | GridVolume::UpdateFlags combinedUpdates = GridVolume::UpdateFlags::None; |
| 1661 | |
| 1662 | // Update animations and get combined updates. |
| 1663 | for (const auto& pGridVolume : mGridVolumes) |
| 1664 | { |
| 1665 | if (pGridVolume->mpDevice != mpDevice) |
| 1666 | FALCOR_THROW("GridVolume '{}' was created with a different device than the Scene.", pGridVolume->getName()); |
| 1667 | updateAnimatable(*pGridVolume, *mpAnimationController, forceUpdate); |
| 1668 | combinedUpdates |= pGridVolume->getUpdates(); |
| 1669 | } |
| 1670 | |
| 1671 | // Early out if no volumes have changed. |
| 1672 | if (!forceUpdate && combinedUpdates == GridVolume::UpdateFlags::None) return IScene::UpdateFlags::None; |
| 1673 | |
| 1674 | // Upload grids. |
| 1675 | if (forceUpdate) |
| 1676 | { |
| 1677 | bindGridVolumes(); |
| 1678 | } |
| 1679 | |
| 1680 | // Upload volumes and clear updates. |
| 1681 | uint32_t volumeIndex = 0; |
| 1682 | for (const auto& pGridVolume : mGridVolumes) |
| 1683 | { |
| 1684 | if (forceUpdate || pGridVolume->getUpdates() != GridVolume::UpdateFlags::None) |
| 1685 | { |
| 1686 | // Fetch copy of volume data. |
| 1687 | auto data = pGridVolume->getData(); |
| 1688 | data.densityGrid = (pGridVolume->getDensityGrid() ? mGridIDs.at(pGridVolume->getDensityGrid()) : SdfGridID::Invalid()).getSlang(); |
| 1689 | data.emissionGrid = (pGridVolume->getEmissionGrid() ? mGridIDs.at(pGridVolume->getEmissionGrid()) : SdfGridID::Invalid()).getSlang(); |
| 1690 | // Merge grid and volume transforms. |
| 1691 | const auto& densityGrid = pGridVolume->getDensityGrid(); |
| 1692 | if (densityGrid) |
| 1693 | { |
| 1694 | data.transform = mul(data.transform, densityGrid->getTransform()); |
| 1695 | data.invTransform = mul(densityGrid->getInvTransform(), data.invTransform); |
| 1696 | } |
| 1697 | mpGridVolumesBuffer->setElement(volumeIndex, data); |
| 1698 | } |
| 1699 | pGridVolume->clearUpdates(); |
| 1700 | volumeIndex++; |
| 1701 | } |
| 1702 | |
| 1703 | IScene::UpdateFlags flags = IScene::UpdateFlags::None; |
| 1704 | if (is_set(combinedUpdates, GridVolume::UpdateFlags::TransformChanged)) flags |= IScene::UpdateFlags::GridVolumesMoved; |
| 1705 | if (is_set(combinedUpdates, GridVolume::UpdateFlags::PropertiesChanged)) flags |= IScene::UpdateFlags::GridVolumePropertiesChanged; |
| 1706 | if (is_set(combinedUpdates, GridVolume::UpdateFlags::GridsChanged)) flags |= IScene::UpdateFlags::GridVolumeGridsChanged; |
| 1707 | if (is_set(combinedUpdates, GridVolume::UpdateFlags::BoundsChanged)) flags |= IScene::UpdateFlags::GridVolumeBoundsChanged; |
| 1708 | |
| 1709 | return flags; |
| 1710 | } |
| 1711 | |
| 1712 | void Scene::bindGridVolumes() |
| 1713 | { |
nothing calls this directly
no test coverage detected