| 1838 | } |
| 1839 | |
| 1840 | IScene::UpdateFlags Scene::update(RenderContext* pRenderContext, double currentTime) |
| 1841 | { |
| 1842 | mUpdates = IScene::UpdateFlags::None; |
| 1843 | |
| 1844 | // Perform updates that may affect the scene defines. |
| 1845 | updateGeometryTypes(); |
| 1846 | mUpdates |= updateMaterials(false); |
| 1847 | |
| 1848 | // Update scene defines. |
| 1849 | // These are currently assumed not to change beyond this point. |
| 1850 | updateSceneDefines(); |
| 1851 | if (mSceneDefines != mPrevSceneDefines) |
| 1852 | { |
| 1853 | mUpdates |= IScene::UpdateFlags::SceneDefinesChanged; |
| 1854 | mPrevSceneDefines = mSceneDefines; |
| 1855 | mpSceneBlock = nullptr; |
| 1856 | } |
| 1857 | |
| 1858 | // Recreate scene parameter block if scene defines changed, as the defines may affect resource declarations. |
| 1859 | // All access to the (new) scene parameter block should be placed after this point. |
| 1860 | if (!mpSceneBlock) |
| 1861 | { |
| 1862 | logDebug("Recreating scene parameter block"); |
| 1863 | createParameterBlock(); |
| 1864 | bindParameterBlock(); |
| 1865 | } |
| 1866 | |
| 1867 | if (mpAnimationController->animate(pRenderContext, currentTime)) |
| 1868 | { |
| 1869 | mUpdates |= IScene::UpdateFlags::SceneGraphChanged; |
| 1870 | if (mpAnimationController->hasSkinnedMeshes()) mUpdates |= IScene::UpdateFlags::MeshesChanged; |
| 1871 | |
| 1872 | for (const auto& inst : mGeometryInstanceData) |
| 1873 | { |
| 1874 | if (mpAnimationController->isMatrixChanged(NodeID{ inst.globalMatrixID })) |
| 1875 | { |
| 1876 | mUpdates |= IScene::UpdateFlags::GeometryMoved; |
| 1877 | } |
| 1878 | } |
| 1879 | |
| 1880 | // We might end up setting the flag even if curves haven't changed (if looping is disabled for example). |
| 1881 | if (mpAnimationController->hasAnimatedCurveCaches()) mUpdates |= IScene::UpdateFlags::CurvesMoved; |
| 1882 | if (mpAnimationController->hasAnimatedMeshCaches()) mUpdates |= IScene::UpdateFlags::MeshesChanged; |
| 1883 | } |
| 1884 | |
| 1885 | for (const auto& pGridVolume : mGridVolumes) |
| 1886 | { |
| 1887 | pGridVolume->updatePlayback(currentTime); |
| 1888 | } |
| 1889 | |
| 1890 | mUpdates |= updateSelectedCamera(false); |
| 1891 | mUpdates |= updateLights(false); |
| 1892 | mUpdates |= updateGridVolumes(false); |
| 1893 | mUpdates |= updateEnvMap(false); |
| 1894 | mUpdates |= updateGeometry(pRenderContext, false); |
| 1895 | mUpdates |= updateSDFGrids(pRenderContext); |
| 1896 | pRenderContext->submit(); |
| 1897 | |