diff --git a/doomsday/client/include/map/hedge.h b/doomsday/client/include/map/hedge.h index 43e530ef27..4d2b1afe89 100644 --- a/doomsday/client/include/map/hedge.h +++ b/doomsday/client/include/map/hedge.h @@ -378,6 +378,17 @@ class HEdge : public de::MapElement return pointOnSide(point); } + /** + * Determines the side relative sectors for producing wall section geometry. + * + * @pre A map line side is attributed (@ref hasLineSide()). + * + * Return values: + * @param frontSec Front sector for the wall section is written here. Can be @c 0. + * @param backSec Back sector for the wall section is written here. Can be @c 0. + */ + void wallSectionSectors(Sector **frontSec = 0, Sector **backSec = 0) const; + /** * Retrieve the bias surface for specified geometry @a groupId * diff --git a/doomsday/client/include/render/rend_fakeradio.h b/doomsday/client/include/render/rend_fakeradio.h index 1918f53a09..f28728632a 100644 --- a/doomsday/client/include/render/rend_fakeradio.h +++ b/doomsday/client/include/render/rend_fakeradio.h @@ -158,7 +158,7 @@ struct RendRadioWallSectionParms coord_t segOffset; coord_t segLength; Line const *line; - Sector const *frontSec, *backSec; + Sector *frontSec, *backSec; SectionEdge const *leftEdge; SectionEdge const *rightEdge; }; diff --git a/doomsday/client/src/map/hedge.cpp b/doomsday/client/src/map/hedge.cpp index 1022749a88..c93c9f3c24 100644 --- a/doomsday/client/src/map/hedge.cpp +++ b/doomsday/client/src/map/hedge.cpp @@ -174,6 +174,31 @@ coord_t HEdge::length() const return _length; } +void HEdge::wallSectionSectors(Sector **frontSec, Sector **backSec) const +{ + if(!d->lineSide) + /// @throw MissingLineError Attempted with no line attributed. + throw MissingLineSideError("HEdge::wallSectionSectors", "No line.side is attributed"); + + if(d->lineSide->line().isFromPolyobj()) + { + if(frontSec) *frontSec = bspLeaf().sectorPtr(); + if(backSec) *backSec = 0; + return; + } + + if(!d->lineSide->line().isSelfReferencing()) + { + if(frontSec) *frontSec = bspLeaf().sectorPtr(); + if(backSec) *backSec = hasTwin()? twin().bspLeaf().sectorPtr() : 0; + return; + } + + // Special case: so called "self-referencing" lines use the sector's of the map line. + if(frontSec) *frontSec = d->lineSide->sectorPtr(); + if(backSec) *backSec = d->lineSide->sectorPtr(); +} + biassurface_t &HEdge::biasSurfaceForGeometryGroup(uint groupId) { if(groupId <= Line::Side::Top) diff --git a/doomsday/client/src/render/rend_main.cpp b/doomsday/client/src/render/rend_main.cpp index e84b454511..340974c516 100644 --- a/doomsday/client/src/render/rend_main.cpp +++ b/doomsday/client/src/render/rend_main.cpp @@ -1715,14 +1715,14 @@ static bool writeWallSection(SectionEdge const &leftEdge, SectionEdge const &rig // Dynamic Lights? if(flags & WSF_ADD_DYNLIGHTS) { - lightListIdx = projectSurfaceLights(side.middle(), glowStrength, texTL, texBR, + lightListIdx = projectSurfaceLights(surface, glowStrength, texTL, texBR, (section == Line::Side::Middle && isTwoSided)); } // Dynamic shadows? if(flags & WSF_ADD_DYNSHADOWS) { - shadowListIdx = projectSurfaceShadows(side.middle(), glowStrength, texTL, texBR); + shadowListIdx = projectSurfaceShadows(surface, glowStrength, texTL, texBR); } if(glowStrength > 0) @@ -1748,7 +1748,8 @@ static bool writeWallSection(SectionEdge const &leftEdge, SectionEdge const &rig deltaL += (sectionOffset / lineLength) * deltaDiff; } - if(section == Line::Side::Middle && isTwoSided) + if(section == Line::Side::Middle && isTwoSided && + side.sectorPtr() != currentBspLeaf->sectorPtr()) { // Temporarily modify the draw state. currentSectorLightColor = R_GetSectorLightColor(side.sector()); @@ -1840,7 +1841,8 @@ static bool writeWallSection(SectionEdge const &leftEdge, SectionEdge const &rig radioParms.segOffset = leftEdge.offset(); radioParms.segLength = width; - radioParms.frontSec = bspLeaf->sectorPtr(); + + leftEdge.hedge().wallSectionSectors(&radioParms.frontSec); radioParms.leftEdge = parm.wall.leftEdge; radioParms.rightEdge = parm.wall.rightEdge; @@ -1899,7 +1901,8 @@ static bool writeWallSection(SectionEdge const &leftEdge, SectionEdge const &rig } } - if(section == Line::Side::Middle && isTwoSided) + if(section == Line::Side::Middle && isTwoSided && + side.sectorPtr() != currentBspLeaf->sectorPtr()) { // Undo temporary draw state changes. currentSectorLightColor = R_GetSectorLightColor(currentBspLeaf->sector()); @@ -1911,40 +1914,6 @@ static bool writeWallSection(SectionEdge const &leftEdge, SectionEdge const &rig return opaque && !didNearBlend; } -/** - * Determines the side relative sectors for producing wall section geometry. - * - * @pre @a hedge has an attributed map line side. - * - * @param hedge Half-edge describing the map line segment. - * - * Return values: - * @param frontSec Front sector for the wall section is written here. Can be @c 0. - * @param backSec Back sector for the wall section is written here. Can be @c 0. - */ -static void wallSectionSectors(HEdge &hedge, Sector **frontSec, Sector **backSec) -{ - DENG_ASSERT(hedge.hasLineSide()); - - if(hedge.line().isFromPolyobj()) - { - if(frontSec) *frontSec = hedge.bspLeaf().sectorPtr(); - if(backSec) *backSec = 0; - return; - } - - if(!hedge.line().isSelfReferencing()) - { - if(frontSec) *frontSec = hedge.bspLeafSectorPtr(); - if(backSec) *backSec = hedge.hasTwin()? hedge.twin().bspLeafSectorPtr() : 0; - return; - } - - // Special case: so called "self-referencing" lines use the sector's of the map line. - if(frontSec) *frontSec = hedge.lineSide().sectorPtr(); - if(backSec) *backSec = hedge.lineSide().sectorPtr(); -} - /** * Prepare wall section edge data for a map line segment. * @@ -1962,7 +1931,7 @@ static bool prepareWallSectionEdges(SectionEdge &leftEdge, SectionEdge &rightEdg int const section = leftEdge.section(); Sector *frontSec, *backSec; - wallSectionSectors(hedge, &frontSec, &backSec); + hedge.wallSectionSectors(&frontSec, &backSec); coord_t bottom, top; bool visible = R_SideSectionCoords(hedge.lineSide(), section, frontSec, backSec,