mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-16 05:13:58 -07:00
Only render the minimap texture if it'll be displayed
This patch implements a way for minimap-type GUI objects to request the rendering of the minimap texture each frame. If it wasn't requested the minimap texture isn't rendered at all and the objects only request it while they are being displayed. This saves unnecessary work and fixes a bug where the minimap briefly showed the revealed map after a cinema path ended playing, since it isn't updated every frame (only 2x per second).
This commit is contained in:
parent
67c96094f0
commit
01476b9836
4 changed files with 23 additions and 4 deletions
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 2025 Wildfire Games.
|
||||
/* Copyright (C) 2026 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
|
|
@ -354,6 +354,11 @@ CMiniMapTexture::~CMiniMapTexture()
|
|||
DestroyTextures();
|
||||
}
|
||||
|
||||
void CMiniMapTexture::RequestRendering()
|
||||
{
|
||||
m_RenderingRequested = true;
|
||||
}
|
||||
|
||||
void CMiniMapTexture::Update(const float /*deltaRealTime*/)
|
||||
{
|
||||
if (m_WaterHeight != g_Renderer.GetSceneRenderer().GetWaterManager().m_WaterHeight)
|
||||
|
|
@ -367,6 +372,9 @@ void CMiniMapTexture::Render(
|
|||
Renderer::Backend::IDeviceCommandContext* deviceCommandContext,
|
||||
CLOSTexture& losTexture, CTerritoryTexture& territoryTexture)
|
||||
{
|
||||
if (!std::exchange(m_RenderingRequested, false))
|
||||
return;
|
||||
|
||||
const CTerrain& terrain = g_Game->GetWorld()->GetTerrain();
|
||||
if (!m_TerrainTexture)
|
||||
CreateTextures(deviceCommandContext, terrain);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 2025 Wildfire Games.
|
||||
/* Copyright (C) 2026 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
|
|
@ -50,6 +50,8 @@ public:
|
|||
CMiniMapTexture(Renderer::Backend::IDevice* device, CSimulation2& simulation);
|
||||
~CMiniMapTexture();
|
||||
|
||||
void RequestRendering();
|
||||
|
||||
/**
|
||||
* Marks the texture as dirty if it's old enough to redraw it on Render.
|
||||
*/
|
||||
|
|
@ -101,6 +103,8 @@ private:
|
|||
|
||||
CSimulation2& m_Simulation;
|
||||
|
||||
bool m_RenderingRequested = false;
|
||||
|
||||
bool m_TerrainTextureDirty = true;
|
||||
bool m_FinalTextureDirty = true;
|
||||
double m_LastFinalTextureUpdate = 0.0;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 2025 Wildfire Games.
|
||||
/* Copyright (C) 2026 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
|
|
@ -119,6 +119,11 @@ CMiniMap::CMiniMap(CGUI& pGUI) :
|
|||
m_MouseHovering = false;
|
||||
}
|
||||
|
||||
void CMiniMap::Tick()
|
||||
{
|
||||
g_Game->GetView()->GetMiniMapTexture().RequestRendering();
|
||||
}
|
||||
|
||||
void CMiniMap::HandleMessage(SGUIMessage& Message)
|
||||
{
|
||||
IGUIObject::HandleMessage(Message);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 2025 Wildfire Games.
|
||||
/* Copyright (C) 2026 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
|
|
@ -52,6 +52,8 @@ protected:
|
|||
double time;
|
||||
};
|
||||
|
||||
virtual void Tick();
|
||||
|
||||
virtual void Draw(CCanvas2D& canvas);
|
||||
|
||||
virtual void CreateJSObject();
|
||||
|
|
|
|||
Loading…
Reference in a new issue