Skip to content

Commit

Permalink
- expose visibility of terrain for editor
Browse files Browse the repository at this point in the history
  • Loading branch information
kaffeewolf committed Nov 9, 2024
1 parent d1b73f4 commit 6bbff1a
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
19 changes: 19 additions & 0 deletions code/render/terrain/terraincontext.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2405,6 +2405,25 @@ TerrainContext::UpdateLOD(const Ptr<Graphics::View>& view, const Graphics::Frame
terrainState.updateShadowMap = true;
}


//------------------------------------------------------------------------------
/**
*/
bool
TerrainContext::GetVisible()
{
return terrainState.renderToggle;
}

//------------------------------------------------------------------------------
/**
*/
void
TerrainContext::SetVisible(bool visible)
{
terrainState.renderToggle = visible;
}

//------------------------------------------------------------------------------
/**
*/
Expand Down
5 changes: 5 additions & 0 deletions code/render/terrain/terraincontext.h
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,11 @@ class TerrainContext : public Graphics::GraphicsContext
/// clear the tile cache (use when we need to force update the terrain)
static void ClearCache();

///
static void SetVisible(bool visible);
///
static bool GetVisible();

#ifndef PUBLIC_DEBUG
/// debug rendering
static void OnRenderDebug(uint32_t flags);
Expand Down
6 changes: 6 additions & 0 deletions toolkit/editor/editor/ui/windows/environment.cc
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ Environment::Run(SaveMode save)
{
LightContext::SetAmbient(globalLight, ambient);
}

bool visible = Terrain::TerrainContext::GetVisible();
if (ImGui::Checkbox("Render terrain", &visible))
{
Terrain::TerrainContext::SetVisible(visible);
}
}

} // namespace Presentation

0 comments on commit 6bbff1a

Please sign in to comment.