diff --git a/doomsday/client/include/map/r_world.h b/doomsday/client/include/map/r_world.h index 38c7901f23..989c0b2c39 100644 --- a/doomsday/client/include/map/r_world.h +++ b/doomsday/client/include/map/r_world.h @@ -160,19 +160,25 @@ coord_t R_VisOpenRange(Line const &line, int side, coord_t *bottom, coord_t *top * * @return @c true iff Line::Side @a front has a "middle" Material which completely * covers the open range defined by sectors @a frontSec and @a backSec. + * + * @note Anything calling this is likely working at the wrong level (should work with + * half-edges instead). */ -boolean R_MiddleMaterialCoversOpening(int lineFlags, Sector const *frontSec, +bool R_MiddleMaterialCoversOpening(int lineFlags, Sector const *frontSec, Sector const *backSec, Line::Side const *front, Line::Side const *back, - boolean ignoreOpacity = true); + bool ignoreOpacity = false); /** - * Same as @ref R_MiddleMaterialCoversOpening except all arguments are derived from - * the specified line @a line. - * - * @note Anything calling this is likely working at the wrong level (should work with - * hedges instead). + * Same as @ref R_MiddleMaterialCoversOpening() except all arguments are derived from + * the specified line @a side. */ -boolean R_MiddleMaterialCoversLineOpening(Line const *line, int side, boolean ignoreOpacity); +inline bool R_MiddleMaterialCoversLineOpening(Line::Side const &side, + bool ignoreOpacity = false) +{ + return R_MiddleMaterialCoversOpening(side.line().flags(), side.sectorPtr(), side.back().sectorPtr(), + &side, &side.back(), ignoreOpacity); +} + #endif // __CLIENT__ void R_UpdateSector(Sector §or, bool forceUpdate = false); diff --git a/doomsday/client/src/map/p_objlink.cpp b/doomsday/client/src/map/p_objlink.cpp index 712089dbab..a20eddae37 100644 --- a/doomsday/client/src/map/p_objlink.cpp +++ b/doomsday/client/src/map/p_objlink.cpp @@ -384,8 +384,7 @@ static void processSeg(HEdge *hedge, void *parameters) if(backSec && !back.hasSections()) return; // One-sided window. - if(R_MiddleMaterialCoversOpening(line.flags(), frontSec, backSec, &front, &back, - false /*do not ignore material opacity*/)) return; + if(R_MiddleMaterialCoversOpening(line.flags(), frontSec, backSec, &front, &back)) return; } // During next step, obj will continue spreading from there. diff --git a/doomsday/client/src/map/r_world.cpp b/doomsday/client/src/map/r_world.cpp index a93eeea8ce..0373c9df13 100644 --- a/doomsday/client/src/map/r_world.cpp +++ b/doomsday/client/src/map/r_world.cpp @@ -316,9 +316,9 @@ coord_t R_VisOpenRange(Line const &line, int side, coord_t *bottom, coord_t *top } #ifdef __CLIENT__ -boolean R_MiddleMaterialCoversOpening(int lineFlags, Sector const *frontSec, +bool R_MiddleMaterialCoversOpening(int lineFlags, Sector const *frontSec, Sector const *backSec, Line::Side const *front, Line::Side const *back, - boolean ignoreOpacity) + bool ignoreOpacity) { if(!frontSec || !front || !front->hasSections()) return false; // Never. @@ -332,7 +332,8 @@ boolean R_MiddleMaterialCoversOpening(int lineFlags, Sector const *frontSec, coord_t openRange, openBottom, openTop; // Stretched middles always cover the opening. - if(front->isFlagged(SDF_MIDDLE_STRETCH)) return true; + if(front->isFlagged(SDF_MIDDLE_STRETCH)) + return true; // Might the material cover the opening? openRange = R_VisOpenRange(frontSec, backSec, &openBottom, &openTop); @@ -351,16 +352,6 @@ boolean R_MiddleMaterialCoversOpening(int lineFlags, Sector const *frontSec, return false; } -boolean R_MiddleMaterialCoversLineOpening(Line const *line, int side, boolean ignoreOpacity) -{ - DENG_ASSERT(line != 0); - Sector const *frontSec = line->sectorPtr(side); - Sector const *backSec = line->sectorPtr(side ^ 1); - Line::Side const &front = line->side(side); - Line::Side const &back = line->side(side ^ 1); - return R_MiddleMaterialCoversOpening(line->flags(), frontSec, backSec, &front, &back, ignoreOpacity); -} - Line *R_FindLineNeighbor(Sector const *sector, Line const *line, LineOwner const *own, bool antiClockwise, binangle_t *diff) { @@ -442,7 +433,7 @@ Line *R_FindSolidLineNeighbor(Sector const *sector, Line const *line, oFCeil > sector->floor().visHeight()))) ) { - if(!R_MiddleMaterialCoversLineOpening(other, side, false)) + if(!R_MiddleMaterialCoversLineOpening(other->side(side))) return 0; } } diff --git a/doomsday/client/src/render/rend_fakeradio.cpp b/doomsday/client/src/render/rend_fakeradio.cpp index 98468c8781..f2646b0341 100644 --- a/doomsday/client/src/render/rend_fakeradio.cpp +++ b/doomsday/client/src/render/rend_fakeradio.cpp @@ -385,7 +385,7 @@ static void scanNeighbors(shadowcorner_t top[2], shadowcorner_t bottom[2], for(uint i = 0; i < 2; ++i) { - shadowcorner_t *corner = (i == 0 ? &bottom[!toLeft] : &top[(int)!toLeft]); + shadowcorner_t *corner = (i == 0 ? &bottom[(int)!toLeft] : &top[(int)!toLeft]); edge_t *edge = &edges[i]; edgespan_t *span = &spans[i]; @@ -1224,7 +1224,7 @@ static uint radioEdgeHackType(Line const *line, Sector const *front, Sector cons // Check for unmasked midtextures on twosided lines that completely // fill the gap between floor and ceiling (we don't want to give away // the location of any secret areas (false walls)). - if(R_MiddleMaterialCoversLineOpening(const_cast(line), backside, false)) + if(R_MiddleMaterialCoversLineOpening(line->side(backside))) return 1; // Consider it fully closed. return 0; @@ -1372,10 +1372,10 @@ static void processEdgeShadow(BspLeaf const &bspLeaf, Line const *line, } else if(!(neighbor == line || !neighbor->hasBackSections())) { - byte otherSide = (&line->vertex(i^side) == &neighbor->v1()? i : i^1); + int otherSide = (&line->vertex(i ^ side) == &neighbor->v1()? i : i ^ 1); Sector *othersec = neighbor->sectorPtr(otherSide); - if(R_MiddleMaterialCoversLineOpening(neighbor, otherSide^1, false)) + if(R_MiddleMaterialCoversLineOpening(neighbor->side(otherSide ^ 1))) { sideOpen[i] = 0; } diff --git a/doomsday/client/src/render/rend_main.cpp b/doomsday/client/src/render/rend_main.cpp index 202c0b6b59..31fc9156f9 100644 --- a/doomsday/client/src/render/rend_main.cpp +++ b/doomsday/client/src/render/rend_main.cpp @@ -1545,20 +1545,15 @@ static void writePlane(Plane::Type type, coord_t height, } } -static float calcLightLevelDelta(Vector3f const &normal) -{ - return (1.0f / 255) * (normal.x * 18) * rendLightWallAngle; -} - /** * @param side Line::Side instance. * @param ignoreOpacity @c true= do not consider Material opacity. - * @return @c true if this Line's side is considered "closed" (i.e., - * there is no opening through which the back Sector can be seen). - * Tests consider all Planes which interface with this and the "middle" - * Material used on the relative front side (if any). + * + * @return @c true if this side is considered "closed" (i.e., there is no opening + * through which the relative back Sector can be seen). Tests consider all Planes + * which interface with this and the "middle" Material used on the "this" side. */ -static bool sideBackClosedForBlend(Line::Side const &side, bool ignoreOpacity = true) +static bool sideBackClosed(Line::Side const &side, bool ignoreOpacity = true) { if(!side.hasSections()) return false; if(!side.back().hasSections()) return true; @@ -1566,23 +1561,28 @@ static bool sideBackClosedForBlend(Line::Side const &side, bool ignoreOpacity = if(side.hasSector() && side.back().hasSector()) { - Sector const *frontSec = side.sectorPtr(); - Sector const *backSec = side.back().sectorPtr(); + Sector const &frontSec = side.sector(); + Sector const &backSec = side.back().sector(); - if(backSec->floor().visHeight() >= backSec->ceiling().visHeight()) return true; - if(backSec->ceiling().visHeight() <= frontSec->floor().visHeight()) return true; - if(backSec->floor().visHeight() >= frontSec->ceiling().visHeight()) return true; + if(backSec.floor().visHeight() >= backSec.ceiling().visHeight()) return true; + if(backSec.ceiling().visHeight() <= frontSec.floor().visHeight()) return true; + if(backSec.floor().visHeight() >= frontSec.ceiling().visHeight()) return true; } - return R_MiddleMaterialCoversLineOpening(&side.line(), side.lineSideId(), ignoreOpacity); + return R_MiddleMaterialCoversLineOpening(side, ignoreOpacity); +} + +static float calcLightLevelDelta(Vector3f const &normal) +{ + return (1.0f / 255) * (normal.x * 18) * rendLightWallAngle; } static Line::Side *findSideBlendNeighbor(Line::Side const &side, bool right, binangle_t *diff = 0) { - LineOwner const *farVertOwner = side.line().vertexOwner((int)right ^ side.lineSideId()); + LineOwner const *farVertOwner = side.line().vertexOwner(side.lineSideId() ^ (int)right); Line *neighbor; - if(sideBackClosedForBlend(side)) + if(sideBackClosed(side)) { neighbor = R_FindSolidLineNeighbor(side.sectorPtr(), &side.line(), farVertOwner, right, diff); } @@ -2244,36 +2244,6 @@ static void skyFixZCoords(HEdge *hedge, int skyCap, coord_t *bottom, coord_t *to } } -/** - * @return @c true if this half-edge is considered "closed" (i.e., - * there is no opening through which the back Sector can be seen). - * Tests consider all Planes which interface with this and the "middle" - * Material used on the relative front side (if any). - */ -static bool hedgeBackClosedForSkyFix(HEdge const &hedge) -{ - Line const &line = hedge.line(); - Line::Side const &front = line.side(hedge.lineSideId()); - Line::Side const &back = line.side(hedge.lineSideId()^1); - Sector const *frontSec = line.sectorPtr(hedge.lineSideId()); - Sector const *backSec = line.sectorPtr(hedge.lineSideId()^1); - - if(!front.hasSections()) return false; - if(!back.hasSections()) return true; - - if(frontSec == backSec) return false; // Never. - - if(frontSec && backSec) - { - if(backSec->floor().visHeight() >= backSec->ceiling().visHeight()) return true; - if(backSec->ceiling().visHeight() <= frontSec->floor().visHeight()) return true; - if(backSec->floor().visHeight() >= frontSec->ceiling().visHeight()) return true; - } - - return R_MiddleMaterialCoversOpening(line.flags(), frontSec, backSec, &front, &back, - false/*don't ignore opacity*/); -} - /** * Determine which sky fixes are necessary for the specified @a hedge. * @param hedge HEdge to be evaluated. @@ -2296,7 +2266,7 @@ static int chooseHEdgeSkyFixes(HEdge *hedge, int skyCap) if(hasSkyFloor || hasSkyCeiling) { - bool const hasClosedBack = hedgeBackClosedForSkyFix(*hedge); + bool const hasClosedBack = sideBackClosed(hedge->lineSide()); // Lower fix? if(hasSkyFloor && (skyCap & SKYCAP_LOWER))