diff --git a/doomsday/apps/client/src/client/cledgeloop.cpp b/doomsday/apps/client/src/client/cledgeloop.cpp index 8c5b3dc18d..a23ea4d51a 100644 --- a/doomsday/apps/client/src/client/cledgeloop.cpp +++ b/doomsday/apps/client/src/client/cledgeloop.cpp @@ -255,46 +255,42 @@ void ClEdgeLoop::fixSurfacesMissingMaterials() { if (it->hasMapElement()) // BSP errors may fool the circulator wrt interior edges -ds { - if (hasBackSubsector()) + LineSide &lineSide = it->mapElementAs().lineSide(); + if (lineSide.hasSections()) // Not a "one-way window" -ds { - auto const &backSubsec = backSubsector().as(); - - // A potential bottom section fix? - if (!d->owner.hasSkyFloor() && !backSubsec.hasSkyFloor()) + if (hasBackSubsector()) { - if (d->owner.visFloor().height() < backSubsec.visFloor().height()) - { - d->fixMissingMaterial(*it, LineSide::Bottom); - } - else - { - Surface &surface = it->mapElementAs().lineSide().bottom(); - if (surface.hasFixMaterial()) - surface.setMaterial(nullptr); - } - } + auto const &backSubsec = backSubsector().as(); - // A potential top section fix? - if (!d->owner.hasSkyCeiling() && !backSubsec.hasSkyCeiling()) - { - if (d->owner.visCeiling().height() > backSubsec.visCeiling().height()) + // Potential bottom section fix? + if (!d->owner.hasSkyFloor() && !backSubsec.hasSkyFloor()) { - d->fixMissingMaterial(*it, LineSide::Top); + if (d->owner.visFloor().height() < backSubsec.visFloor().height()) + { + d->fixMissingMaterial(*it, LineSide::Bottom); + } + else if (lineSide.bottom().hasFixMaterial()) + { + lineSide.bottom().setMaterial(nullptr); + } } - else + + // Potential top section fix? + if (!d->owner.hasSkyCeiling() && !backSubsec.hasSkyCeiling()) { - Surface &surface = it->mapElementAs().lineSide().top(); - if (surface.hasFixMaterial()) - surface.setMaterial(nullptr); + if (d->owner.visCeiling().height() > backSubsec.visCeiling().height()) + { + d->fixMissingMaterial(*it, LineSide::Top); + } + else if (lineSide.top().hasFixMaterial()) + { + lineSide.top().setMaterial(nullptr); + } } } - } - else - { - LineSide &side = it->mapElementAs().lineSide(); - if (!side.back().hasSector()) + // Potential middle section fix? + else if (!lineSide.back().hasSector()) { - // A potential middle section fix. d->fixMissingMaterial(*it, LineSide::Middle); } }