Skip to content

Commit

Permalink
Performance: Handling of missing materials
Browse files Browse the repository at this point in the history
If a map had many missing wall textures, it could take a very long time for the material fixer's algorithm to get through all of them. Pending a better solution, a missing top/bottom material now simply reverts at render time to the floor/ceiling texture.
  • Loading branch information
skyjake committed Dec 9, 2019
1 parent 549c090 commit 72e1a2c
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 12 deletions.
2 changes: 2 additions & 0 deletions doomsday/apps/client/src/client/clientsubsector.cpp
Expand Up @@ -1207,12 +1207,14 @@ DENG2_PIMPL(ClientSubsector)
// We may need to update one or both mapped planes.
maybeInvalidateMapping(plane.indexInSector());

/*
// We may need to fix newly revealed missing materials.
self().forAllEdgeLoops([] (ClEdgeLoop &loop)
{
loop.fixSurfacesMissingMaterials();
return LoopContinue;
});
*/

// We may need to project new decorations.
markDependentSurfacesForRedecoration(plane);
Expand Down
2 changes: 2 additions & 0 deletions doomsday/apps/client/src/dd_main.cpp
Expand Up @@ -2540,6 +2540,7 @@ DENG_EXTERN_C void R_SetupMap(dint mode, dint flags)
#endif

#ifdef __CLIENT__
/*
// Update all sectors.
/// @todo Refactor away.
map.forAllSectors([] (Sector &sector)
Expand All @@ -2553,6 +2554,7 @@ DENG_EXTERN_C void R_SetupMap(dint mode, dint flags)
});
});
});
*/
#endif

// Re-initialize polyobjs.
Expand Down
42 changes: 30 additions & 12 deletions doomsday/apps/client/src/render/rend_main.cpp
Expand Up @@ -730,8 +730,26 @@ ClientMaterial *Rend_ChooseMapSurfaceMaterial(Surface const &surface)
case 1: // Normal mode.
if (!(devNoTexFix && surface.hasFixMaterial()))
{
if (!surface.hasMaterial() && surface.parent().type() == DMU_SIDE)
{
const Line::Side &side = surface.parent().as<Line::Side>();
if (side.hasSector())
{
// Use the ceiling for missing top section, and floor for missing bottom section.
if (&surface == &side.bottom())
{
return static_cast<ClientMaterial *>(side.sector().floor().surface().materialPtr());
}
else if (&surface == &side.top())
{
return static_cast<ClientMaterial *>(side.sector().ceiling().surface().materialPtr());
}
}
}
if (surface.hasMaterial() || surface.parent().type() != DMU_PLANE)
{
return static_cast<ClientMaterial *>(surface.materialPtr());
}
}

// Use special "missing" material.
Expand Down Expand Up @@ -2700,20 +2718,20 @@ static void writeWall(WallEdge const &leftEdge, WallEdge const &rightEdge,
{
if (glowFactor > .0001f)
{
if (material == surface.materialPtr())
{
parm.glowing = matAnimator.glowStrength();
}
else
{
auto *actualMaterial =
surface.hasMaterial() ? static_cast<ClientMaterial *>(surface.materialPtr())
: &ClientMaterial::find(de::Uri("System", Path("missing")));
// if (material == surface.materialPtr())
// {
parm.glowing = matAnimator.glowStrength();
// }
// else
// {
// auto *actualMaterial =
// surface.hasMaterial() ? static_cast<ClientMaterial *>(surface.materialPtr())
// : &ClientMaterial::find(de::Uri("System", Path("missing")));

parm.glowing = actualMaterial->getAnimator(Rend_MapSurfaceMaterialSpec()).glowStrength();
}
// parm.glowing = actualMaterial->getAnimator(Rend_MapSurfaceMaterialSpec()).glowStrength();
// }

parm.glowing *= ::glowFactor;
parm.glowing *= glowFactor;
}

projectDynamics(surface, parm.glowing, *parm.topLeft, *parm.bottomRight,
Expand Down
2 changes: 2 additions & 0 deletions doomsday/apps/client/src/world/base/clientserverworld.cpp
Expand Up @@ -589,6 +589,7 @@ DENG2_PIMPL(ClientServerWorld)
});

#ifdef __CLIENT__
/*
/// @todo Refactor away:
map->forAllSectors([] (Sector &sector)
{
Expand All @@ -601,6 +602,7 @@ DENG2_PIMPL(ClientServerWorld)
});
});
});
*/
#endif

map->initPolyobjs();
Expand Down

0 comments on commit 72e1a2c

Please sign in to comment.