Skip to content

Commit

Permalink
Fixed|Renderer: "texreset" breaks decoration halos
Browse files Browse the repository at this point in the history
IssueID #2366
  • Loading branch information
skyjake committed Dec 10, 2019
1 parent 8aea604 commit 143e236
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 20 deletions.
7 changes: 6 additions & 1 deletion doomsday/apps/client/include/world/map.h
Expand Up @@ -206,6 +206,11 @@ class Map : public world::BaseMap

void restoreObjects(de::Info const &objState, IThinkerMapping const &thinkerMapping) const;

/**
* Force an update on all decorated surfaces.
*/
void redecorate();

public: //- Light sources --------------------------------------------------------------

#if 0
Expand Down Expand Up @@ -527,7 +532,7 @@ class Map : public world::BaseMap
*
* @param callback Function to call for each Sector.
*/
de::LoopResult forAllSectors(std::function<de::LoopResult (Sector &)> callback) const;
de::LoopResult forAllSectors(const std::function<de::LoopResult (Sector &)> &callback) const;

/**
* Increment validCount before calling this routine. The callback function will be
Expand Down
4 changes: 0 additions & 4 deletions doomsday/apps/client/src/gl/gl_main.cpp
Expand Up @@ -457,12 +457,8 @@ void GL_TotalReset()
{
if(isDedicated) return;

// Update the secondary title and the game status.
//Rend_ConsoleUpdateTitle();

// Release all texture memory.
resSys().releaseAllGLTextures();
resSys().pruneUnusedTextureSpecs();
GL_LoadLightingSystemTextures();
GL_LoadFlareTextures();
Rend_ParticleLoadSystemTextures();
Expand Down
38 changes: 25 additions & 13 deletions doomsday/apps/client/src/gl/gl_texmanager.cpp
Expand Up @@ -97,6 +97,7 @@ void GL_InitTextureManager()
initedOk = true;
}

/*
static int reloadTextures(void *context)
{
bool const usingBusyMode = *static_cast<bool *>(context);
Expand All @@ -113,30 +114,41 @@ static int reloadTextures(void *context)
Con_SetProgress(200);
}
return 0;
}
}*/

void GL_TexReset()
{
if (!initedOk) return;

DENG2_ASSERT(!BusyMode_Active());

Rend_ResetLookups();

App_Resources().releaseAllGLTextures();
LOG_GL_VERBOSE("Released all GL textures");

bool useBusyMode = !BusyMode_Active();
if (useBusyMode)
{
BusyMode_FreezeGameForBusyMode();
// bool useBusyMode = !BusyMode_Active();
// if (useBusyMode)
// {
// BusyMode_FreezeGameForBusyMode();

Con_InitProgress(200);
BusyMode_RunNewTaskWithName(BUSYF_ACTIVITY | BUSYF_PROGRESS_BAR| (verbose? BUSYF_CONSOLE_OUTPUT : 0),
reloadTextures, &useBusyMode, "Reseting textures...");
}
else
{
reloadTextures(&useBusyMode);
}
// Con_InitProgress(200);
// BusyMode_RunNewTaskWithName(BUSYF_ACTIVITY | BUSYF_PROGRESS_BAR | (verbose? BUSYF_CONSOLE_OUTPUT : 0),
// reloadTextures, &useBusyMode, "Reseting textures...");
// }
// else
// {
// reloadTextures(&useBusyMode);
// }

GL_LoadLightingSystemTextures();
GL_LoadFlareTextures();

Rend_ParticleLoadSystemTextures();
Rend_ParticleLoadExtraTextures();

GL_ReleaseReservedNames();
GL_ReserveNames();
}

void GL_LoadLightingSystemTextures()
Expand Down
2 changes: 1 addition & 1 deletion doomsday/apps/client/src/render/rend_halo.cpp
Expand Up @@ -205,7 +205,7 @@ bool H_RenderHalo(Vector3d const &origin, float size, DGLuint tex,
H_SetupState(true);

DENG2_ASSERT_IN_RENDER_THREAD();
DENG_ASSERT_GL_CONTEXT_ACTIVE();
DENG_ASSERT_GL_CONTEXT_ACTIVE();

// Prepare the texture rotation matrix.
DGL_MatrixMode(DGL_TEXTURE);
Expand Down
5 changes: 5 additions & 0 deletions doomsday/apps/client/src/render/rend_main.cpp
Expand Up @@ -6179,6 +6179,11 @@ D_CMD(TexReset)
// Reset everything.
GL_TexReset();
}
if (auto *map = App_World().mapPtr())
{
// Texture IDs are cached in Lumobjs, so have to redo all of them.
map->redecorate();
}
return true;
}

Expand Down
13 changes: 12 additions & 1 deletion doomsday/apps/client/src/world/base/map.cpp
Expand Up @@ -2306,7 +2306,7 @@ Sector *Map::sectorPtr(dint index) const
return nullptr;
}

LoopResult Map::forAllSectors(std::function<LoopResult (Sector &)> func) const
LoopResult Map::forAllSectors(const std::function<LoopResult (Sector &)> &func) const
{
for (Sector *sec : d->sectors)
{
Expand Down Expand Up @@ -3298,6 +3298,17 @@ void Map::deserializeInternalState(Reader &from, IThinkerMapping const &thinkerM
}
}

void Map::redecorate()
{
forAllSectors([](Sector &sector) {
sector.forAllSubsectors([](Subsector &subsec) {
subsec.as<ClientSubsector>().markForDecorationUpdate();
return LoopContinue;
});
return LoopContinue;
});
}

void Map::worldSystemFrameBegins(bool resetNextViewer)
{
DENG2_ASSERT(&App_World().map() == this); // Sanity check.
Expand Down

0 comments on commit 143e236

Please sign in to comment.