コード例 #1
0
void AppGUI::UpdateScene(RenderEngine& engine)
{
    UpdateCamera();

    m_cache->FramesPerSec.Set(m_timer.GetFPS());
    m_cache->DeltaTime.Set(m_timer.GetDeltaTime());
    m_cache->Timer.Set(m_timer.GetTotalTime());

    if (m_cache->ReloadScene.Get())
    {
        m_cache->ReloadScene.Set(false);
        m_scene.Reload();

        const auto maxTextures = m_cache->Textures.Get().size();
        for (unsigned int i = 0; i < maxTextures; ++i)
        {
            engine.ReloadTexture(m_data.proceduralTextures[i]);
        }

        const auto maxTerrain = m_cache->Terrains.Get().size();
        for (unsigned int i = 0; i < maxTerrain; ++i)
        {
            engine.ReloadTerrain(i);
        }
    }

    if (m_cache->ReloadEngine.Get())
    {
        m_reloadEngine();
        m_cache->ReloadEngine.Set(false);
    }

    if (m_cache->ReloadPlacement.Get())
    {
        m_scene.ReloadPlacement();
        m_cache->ReloadPlacement.Set(false);
    }
}
コード例 #2
0
void AppGUI::UpdateTerrain(RenderEngine& engine)
{
    const int selectedTerrain = m_cache->TerrainSelected.Get();
    if(selectedTerrain != m_selectedTerrain)
    {
        m_selectedTerrain = selectedTerrain;
        m_data.terrain[m_selectedTerrain]->Write(*m_cache);
    }
    else if(m_selectedTerrain >= 0 && 
            m_selectedTerrain < static_cast<int>(m_scene.Terrains().size()))
    {
        auto& terrain = *m_data.terrain[m_selectedTerrain];
        terrain.Read(*m_cache);
        m_cache->TerrainInstances.SetUpdated(terrain.GetRenderedInstances());
    }

    if (m_cache->ReloadTerrain.Get())
    {
        m_cache->ReloadTerrain.Set(false);
        m_scene.ReloadTerrain(m_selectedTerrain);
        engine.ReloadTerrain(m_selectedTerrain);
    }
}