From 5155fc0a610789029085ed7deaabc792b91bf4cd Mon Sep 17 00:00:00 2001 From: danij Date: Wed, 13 Jul 2016 14:04:00 +0100 Subject: [PATCH] Cleanup|World: world::Line accessors, const correctness, pimpl conformance --- doomsday/apps/client/include/world/line.h | 424 +++++++--------- doomsday/apps/client/include/world/vertex.h | 4 +- .../apps/client/src/render/blockmapvisual.cpp | 4 +- doomsday/apps/client/src/render/rend_main.cpp | 14 +- .../apps/client/src/render/rend_particle.cpp | 88 ++-- .../apps/client/src/render/shadowedge.cpp | 70 +-- doomsday/apps/client/src/render/wallspec.cpp | 30 +- .../apps/client/src/world/bsp/partitioner.cpp | 4 +- doomsday/apps/client/src/world/generator.cpp | 10 +- .../apps/client/src/world/interceptor.cpp | 12 +- doomsday/apps/client/src/world/line.cpp | 472 ++++++++++-------- .../apps/client/src/world/linesighttest.cpp | 4 +- doomsday/apps/client/src/world/map.cpp | 41 +- doomsday/apps/client/src/world/maputil.cpp | 32 +- doomsday/apps/client/src/world/polyobj.cpp | 8 +- doomsday/apps/client/src/world/reject.cpp | 6 +- doomsday/apps/client/src/world/sector.cpp | 6 +- doomsday/apps/client/src/world/vertex.cpp | 2 +- doomsday/apps/server/src/server/sv_pool.cpp | 8 +- doomsday/apps/server/src/shelluser.cpp | 8 +- 20 files changed, 622 insertions(+), 625 deletions(-) diff --git a/doomsday/apps/client/include/world/line.h b/doomsday/apps/client/include/world/line.h index 2c7ff17d8a..ec5caa1b0a 100644 --- a/doomsday/apps/client/include/world/line.h +++ b/doomsday/apps/client/include/world/line.h @@ -67,15 +67,12 @@ class Line : public world::MapElement DENG2_NO_ASSIGN(Line) public: - /// Required sector attribution is missing. @ingroup errors - DENG2_ERROR(MissingSectorError); + /// The given side section identifier is invalid. @ingroup errors + DENG2_ERROR(InvalidSectionIdError); /// Required polyobj attribution is missing. @ingroup errors DENG2_ERROR(MissingPolyobjError); - /// The given side section identifier is invalid. @ingroup errors - DENG2_ERROR(InvalidSectionIdError); - /// Notified whenever the flags change. DENG2_DEFINE_AUDIENCE(FlagsChange, void lineFlagsChanged(Line &line, de::dint oldFlags)) @@ -94,6 +91,9 @@ class Line : public world::MapElement DENG2_NO_ASSIGN(Side) public: + /// Required sector attribution is missing. @ingroup errors + DENG2_ERROR(MissingSectorError); + // Section identifiers: enum { Middle, @@ -132,24 +132,25 @@ class Line : public world::MapElement Segment(Side &lineSide, de::HEdge &hedge); /** - * Returns the line side owner of the segment. + * Returns the half-edge for the segment. */ - inline Side &lineSide() { return parent().as(); } - inline Side const &lineSide() const { return parent().as(); } + de::HEdge &hedge() const; /** - * Convenient accessor method for returning the line of the owning - * line side. + * Returns the Side owner of the segment. * - * @see lineSide() + * @see line() */ - inline Line &line() { return lineSide().line(); } - inline Line const &line() const { return lineSide().line(); } + Side &lineSide(); + Side const &lineSide() const; /** - * Returns the half-edge for the segment. + * Accessor. Returns the Line attributed to the Side owner of the segment. + * + * @see lineSide() */ - de::HEdge &hedge() const; + inline Line &line() { return lineSide().line(); } + inline Line const &line() const { return lineSide().line(); } #ifdef __CLIENT__ @@ -208,65 +209,60 @@ class Line : public world::MapElement /** * Returns the Line owner of the side. */ - inline Line &line() { return parent().as(); } - inline Line const &line() const { return parent().as(); } + Line &line(); + Line const &line() const; /** - * Returns the logical identifier for the side (Front or Back). + * Returns the logical side identifier for the side (Front or Back), according to + * the "face" of the owning Line. + * + * @see line() */ de::dint sideId() const; /** - * Returns @c true iff this is the front side of the owning line. + * Returns @c true if the side is the @ref Front of the owning Line. * - * @see lineSideId() + * @see sideId(), isBack() */ - inline bool isFront() const { return sideId() == Front; } + bool isFront() const; /** - * Returns @c true iff this is the back side of the owning line. + * Returns @c true if the side is the @ref Back of the owning Line. * - * @see lineSideId(), isFront() + * @see sideId(), isFront() */ inline bool isBack() const { return !isFront(); } /** - * Returns the relative back Side from the Line owner. + * Determines whether "this" side of the owning Line should be handled as if there + * were no back Sector, irrespective of whether a Sector is attributed to both. * - * @see lineSideId(), line(), Line::side(), - */ - inline Side &back() { return line().side(sideId() ^ 1); } - inline Side const &back() const { return line().side(sideId() ^ 1); } - - /** - * Determines whether "this" side of the respective line should be - * considered as though there were no back sector. Primarily for use - * with id Tech 1 format maps (which, supports partial suppression of - * the back sector, for use with special case drawing and playsim - * functionality). + * Primarily for use with id Tech 1 format maps (which, supports partial suppression + * of the back sector, for use with special case drawing and playsim functionality). */ bool considerOneSided() const; /** - * Returns the specified relative vertex from the Line owner. + * Returns @c true if a Sector is attributed to the side. * - * @see lineSideId(), line(), Line::vertex(), + * @see sectorPtr(), sector(), considerOneSided() */ - inline Vertex &vertex(de::dint to) const { return line().vertex(sideId() ^ to); } + bool hasSector() const; /** - * Returns the relative From Vertex for the side, from the Line owner. + * Returns the Sector attributed to the side. * - * @see vertex(), to() + * @see hasSector(), sectorPtr() */ - inline Vertex &from() const { return vertex(From); } + Sector §or() const; /** - * Returns the relative To Vertex for the side, from the Line owner. + * Returns a pointer to the Sector attributed to the side; otherwise @c nullptr. * - * @see vertex(), from() + * @see hasSector(), sector() */ - inline Vertex &to () const { return vertex(To); } + Sector *sectorPtr() const; /** * Returns @c true iff Sections are defined for the side. @@ -387,27 +383,6 @@ class Line : public world::MapElement */ void updateAllSoundEmitterOrigins(); - /** - * Returns @c true iff a Sector is attributed to the side. - * - * @see considerOneSided() - */ - bool hasSector() const; - - /** - * Returns the Sector attributed to the side. - * - * @see hasSector() - */ - Sector §or() const; - - /** - * Returns a pointer to the Sector attributed to the side; otherwise @c nullptr. - * - * @see hasSector() - */ - inline Sector *sectorPtr() const { return hasSector()? §or() : nullptr; } - /** * Clears (destroys) all segments for the side. */ @@ -511,6 +486,40 @@ class Line : public world::MapElement #endif // __CLIENT__ + //- Line Accessors (side relative) -------------------------------------------------- + + /** + * Returns the relative back Side from the Line owner. + * + * @see sideId(), line() + */ + inline Side &back() { return line().side(sideId() ^ 1); } + inline Side const &back() const { return line().side(sideId() ^ 1); } + + /** + * Returns the relative From Vertex for the side, from the Line owner. + * + * @see vertex(), to() + */ + inline Vertex &from() { return vertex(From); } + inline Vertex const &from() const { return vertex(From); } + + /** + * Returns the relative To Vertex for the side, from the Line owner. + * + * @see vertex(), from() + */ + inline Vertex &to() { return vertex(To); } + inline Vertex const &to() const { return vertex(To); } + + /** + * Returns the specified relative vertex from the Line owner. + * + * @see from(), to(), + */ + inline Vertex &vertex(de::dint to) { return line().vertex(sideId() ^ to); } + inline Vertex const &vertex(de::dint to) const { return line().vertex(sideId() ^ to); } + protected: de::dint property(world::DmuArgs &args) const; de::dint setProperty(world::DmuArgs const &args); @@ -535,182 +544,137 @@ class Line : public world::MapElement Sector *backSector = nullptr); /** - * Returns the specified logical side of the line. - * - * @param back If not @c 0 return the Back side; otherwise the Front side. + * Returns the public DDLF_* flags for the line. */ - Side &side(de::dint back); - Side const &side(de::dint back) const; + de::dint flags() const; /** - * Returns the logical Front side of the line. + * Change the line's flags. The FlagsChange audience is notified whenever the flags + * are changed. + * + * @param flagsToChange Flags to change the value of. + * @param operation Logical operation to perform on the flags. */ - inline Side &front() { return side(Front); } - inline Side const &front() const { return side(Front); } + void setFlags(de::dint flagsToChange, de::FlagOp operation = de::SetFlags); /** - * Returns the logical Back side of the line. + * Returns @c true iff the line is flagged @a flagsToTest. */ - inline Side &back() { return side(Back); } - inline Side const &back() const { return side(Back); } + inline bool isFlagged(de::dint flagsToTest) const { + return (flags() & flagsToTest) != 0; + } /** - * Iterate through the Sides of the line. + * Returns @c true if the line is considered to be "self referencing" (term originates + * from the DOOM modding community), meaning that @em both Sides are attributed to/with + * the same (valid) Sector. * - * @param func Callback to make for each Side (front then back). + * @see isBspWindow() */ - de::LoopResult forAllSides(std::function func) const; + bool isSelfReferencing() const; /** - * Returns @c true iff Side::Sections are defined for the specified side - * of the line. + * Returns @c true if the line resulted in the creation of a BSP window effect when + * partitioning the map. * - * @param back If not @c 0 test the Back side; otherwise the Front side. - */ - inline bool hasSections(de::dint back) const { return side(back).hasSections(); } - - /** - * Returns @c true iff Side::Sections are defined for the Front side of the line. - */ - inline bool hasFrontSections() const { return hasSections(Front); } - - /** - * Returns @c true iff Side::Sections are defined for the Back side of the line. + * @todo Refactor away. The prescence of a BSP window effect can now be trivially determined + * through inspection of the tree elements. */ - inline bool hasBackSections() const { return hasSections(Back); } + bool isBspWindow() const; /** - * Returns @c true iff a sector is attributed to the specified side of the line. - * - * @param back If not @c 0 test the Back side; otherwise the Front side. + * Returns @c true if the line is marked as @em mapped for @a playerNum. */ - inline bool hasSector(de::dint back) const { return side(back).hasSector(); } + bool isMappedByPlayer(de::dint playerNum) const; /** - * Returns @c true iff a sector is attributed to the Front side of the line. + * Change the @em mapped by player state of the line. */ - inline bool hasFrontSector() const { return hasSector(Front); } + void setMappedByPlayer(de::dint playerNum, bool yes = true); /** - * Returns @c true iff a sector is attributed to the Back side of the line. + * Returns @c true if the line defines a section of some Polyobj. */ - inline bool hasBackSector() const { return hasSector(Back); } + bool definesPolyobj() const; /** - * Convenient accessor method for returning the sector attributed to the - * specified side of the line. + * Returns the Polyobj for which the line is a defining section. * - * @param back If not @c 0 return the sector for the Back side; otherwise - * the sector of the Front side. + * @see definesPolyobj() */ - inline Sector §or(de::dint back) const { return side(back).sector(); } + Polyobj &polyobj() const; /** - * Convenient accessor method for returning a pointer to the sector attributed - * to the specified side of the line. + * Change the polyobj attributed to the line. * - * @param back If not @c 0 return the sector for the Back side; otherwise - * the sector of the Front side. - */ - inline Sector *sectorPtr(de::dint back) const { return side(back).sectorPtr(); } - - /** - * Returns the sector attributed to the Front side of the line. - */ - inline Sector &frontSector() const { return sector(Front); } - - /** - * Returns the sector attributed to the Back side of the line. - */ - inline Sector &backSector() const { return sector(Back); } - - /** - * Convenient accessor method for returning a pointer to the sector attributed - * to the front side of the line. + * @param newPolyobj New polyobj to attribute the line to. Can be @c nullptr, to clear + * the attribution. (Note that the polyobj may also represent this relationship, so + * the relevant method(s) of Polyobj will also need to be called to complete the job + * of clearing this relationship.) */ - inline Sector *frontSectorPtr() const { return sectorPtr(Front); } + void setPolyobj(Polyobj *newPolyobj); - /** - * Convenient accessor method for returning a pointer to the sector attributed - * to the back side of the line. - */ - inline Sector *backSectorPtr() const { return sectorPtr(Back); } +//- Sides ------------------------------------------------------------------------------- /** - * Returns @c true iff the line is considered @em self-referencing. In this context, - * self-referencing (a term whose origins stem from the DOOM modding community) means - * a two-sided line (which is to say that a Sector is attributed to both logical sides - * of the line) where the attributed sectors for each logical side are the same. + * Returns the @em Front side of the line. */ - inline bool isSelfReferencing() const { - return hasFrontSector() && frontSectorPtr() == backSectorPtr(); - } + Side &front(); + Side const &front() const; /** - * Returns the specified edge vertex of the line. - * - * @param to If not @c 0 return the To vertex; otherwise the From vertex. + * Returns the @em Back side of the line. */ - Vertex &vertex(de::dint to) const; + Side &back(); + Side const &back() const; /** - * Iterate through the edge Vertexs for the line. + * Returns the logical side of the line by it's fixed index. * - * @param func Callback to make for each Vertex. + * @param back If not @c 0 return the Back side; otherwise the Front side. */ - de::LoopResult forAllVertexs(std::function func) const; + Side &side(de::dint back); + Side const &side(de::dint back) const; /** - * Convenient accessor method for returning the origin of the specified edge vertex - * for the line. + * Iterate through the Sides of the line. * - * @see vertex() - */ - inline de::Vector2d const &vertexOrigin(de::dint to) const { - return vertex(to).origin(); - } - - /** - * Returns the From/Start vertex for the line. + * @param func Callback to make for each Side (front then back). */ - inline Vertex &from() const { return vertex(From); } + de::LoopResult forAllSides(std::function func) const; - /** - * Returns the To/End vertex for the line. - */ - inline Vertex &to() const { return vertex(To); } +//- Geometry ---------------------------------------------------------------------------- /** - * Convenient accessor method for returning the origin of the From/Start vertex for - * the line. - * - * @see from() + * Returns the axis-aligned bounding box which encompases both vertex origin points, + * in map coordinate space units. */ - inline de::Vector2d const &fromOrigin() const { return from().origin(); } + AABoxd const &aaBox() const; /** - * Convenient accessor method for returning the origin of the To/End vertex for the line. + * Returns the binary angle of the line (which, is derived from the direction vector). * - * @see to() + * @see direction() */ - inline de::Vector2d const &toOrigin() const { return to().origin(); } + binangle_t angle() const; /** - * Returns the point on the line which lies at the exact center of the two vertexes. + * Returns the map space point (on the line) which lies at the center of the line's + * two Vertexs. */ - inline de::Vector2d center() const { return fromOrigin() + direction() / 2; } + de::Vector2d center() const; /** - * Returns the binary angle of the line (which, is derived from the direction vector). + * Returns a direction vector for the line from Start to End vertex. * - * @see direction() + * @see angle() */ - binangle_t angle() const; + de::Vector2d const &direction() const; /** - * Returns a direction vector for the line from Start to End vertex. + * Returns the accurate length of the line from Start to End vertex. */ - de::Vector2d const &direction() const; + de::ddouble length() const; /** * Returns the logical @em slopetype for the line (which, is determined according to @@ -722,20 +686,31 @@ class Line : public world::MapElement slopetype_t slopeType() const; /** - * Returns the accurate length of the line from Start to End vertex. + * Returns the @em From Vertex for the line. */ - de::ddouble length() const; + Vertex &from(); + Vertex const &from() const; /** - * Returns @c true iff the line has a length equivalent to zero. + * Returns the @em To Vertex for the line. */ - inline bool hasZeroLength() const { return de::abs(length()) < 1.0 / 128.0; } + Vertex &to(); + Vertex const &to() const; /** - * Returns the axis-aligned bounding box which encompases both vertex origin points, - * in map coordinate space units. + * Returns the specified Vertex of the line. + * + * @param to If not @c 0 return the To vertex; otherwise the From vertex. */ - AABoxd const &aaBox() const; + Vertex &vertex(de::dint to); + Vertex const &vertex(de::dint to) const; + + /** + * Iterate through the edge Vertexs for the line. + * + * @param func Callback to make for each Vertex. + */ + de::LoopResult forAllVertexs(std::function func) const; /** * On which side of the line does the specified box lie? @@ -781,67 +756,17 @@ class Line : public world::MapElement */ de::ddouble pointOnSide(de::Vector2d const &point) const; - /** - * Returns @c true iff the line defines a section of some Polyobj. - */ - bool definesPolyobj() const; - - /** - * Returns the Polyobj for which the line is a defining section. - * - * @see definesPolyobj() - */ - Polyobj &polyobj() const; - - /** - * Change the polyobj attributed to the line. - * - * @param newPolyobj New polyobj to attribute the line to. Can be @c nullptr, to clear - * the attribution. (Note that the polyobj may also represent this - * relationship, so the relevant method(s) of Polyobj will also need - * to be called to complete the job of clearing this relationship.) - */ - void setPolyobj(Polyobj *newPolyobj); - - /** - * Returns @c true iff the line resulted in the creation of a BSP window effect when - * partitioning the map. - * - * @todo Refactor away. The prescence of a BSP window effect can now be trivially determined - * through inspection of the tree elements. - */ - bool isBspWindow() const; - - /** - * Returns the public DDLF_* flags for the line. - */ - de::dint flags() const; - - /** - * Change the line's flags. The FlagsChange audience is notified whenever the flags - * are changed. - * - * @param flagsToChange Flags to change the value of. - * @param operation Logical operation to perform on the flags. - */ - void setFlags(de::dint flagsToChange, de::FlagOp operation = de::SetFlags); - - /** - * Returns @c true iff the line is flagged @a flagsToTest. - */ - inline bool isFlagged(de::dint flagsToTest) const { - return (flags() & flagsToTest) != 0; - } - - /** - * Returns @c true if the line is marked as @em mapped for @a playerNum. - */ - bool isMappedByPlayer(de::dint playerNum) const; +protected: + de::dint property(world::DmuArgs &args) const; + de::dint setProperty(world::DmuArgs const &args); +public: +#ifdef __CLIENT__ /** - * Change the @em mapped by player state of the line. - */ - void markMappedByPlayer(de::dint playerNum, bool yes = true); + * Returns @c true if the line qualifies for FakeRadio shadow casting (on planes). + */ + bool isShadowCaster() const; +#endif /** * Returns the @em validCount of the line. Used by some legacy iteration algorithms @@ -864,21 +789,6 @@ class Line : public world::MapElement */ void replaceVertex(de::dint to, Vertex &newVertex); - inline void replaceFrom(Vertex &newVertex) { replaceVertex(From, newVertex); } - inline void replaceTo (Vertex &newVertex) { replaceVertex(To , newVertex); } - -#ifdef __CLIENT__ - /** - * Returns @c true if the line qualifies for FakeRadio shadow casting (on planes). - */ - bool castsShadow() const; -#endif - -protected: - de::dint property(world::DmuArgs &args) const; - de::dint setProperty(world::DmuArgs const &args); - -public: /** * Returns a pointer to the line owner node for the specified edge vertex of the line. * diff --git a/doomsday/apps/client/include/world/vertex.h b/doomsday/apps/client/include/world/vertex.h index 61e9950dc5..0565afd052 100644 --- a/doomsday/apps/client/include/world/vertex.h +++ b/doomsday/apps/client/include/world/vertex.h @@ -68,12 +68,12 @@ class Vertex : public world::MapElement, public de::MeshElement /** * Returns the X axis origin (i.e., position) of the vertex in the map coordinate space. */ - inline coord_t x() const { return origin().x; } + inline de::ddouble x() const { return origin().x; } /** * Returns the Y axis origin (i.e., position) of the vertex in the map coordinate space. */ - inline coord_t y() const { return origin().y; } + inline de::ddouble y() const { return origin().y; } /** * Change the origin (i.e., position) of the vertex in the map coordinate diff --git a/doomsday/apps/client/src/render/blockmapvisual.cpp b/doomsday/apps/client/src/render/blockmapvisual.cpp index 904c869313..a8b05ad049 100644 --- a/doomsday/apps/client/src/render/blockmapvisual.cpp +++ b/doomsday/apps/client/src/render/blockmapvisual.cpp @@ -59,8 +59,8 @@ static void drawMobj(mobj_t const &mobj) static void drawLine(Line const &line) { - glVertex2f(line.fromOrigin().x, line.fromOrigin().y); - glVertex2f( line.toOrigin().x, line.toOrigin().y); + glVertex2f(line.from().x(), line.from().y()); + glVertex2f(line.to ().x(), line.to ().y()); } static void drawSubspace(ConvexSubspace const &subspace) diff --git a/doomsday/apps/client/src/render/rend_main.cpp b/doomsday/apps/client/src/render/rend_main.cpp index 123d145705..998961a1b2 100644 --- a/doomsday/apps/client/src/render/rend_main.cpp +++ b/doomsday/apps/client/src/render/rend_main.cpp @@ -324,7 +324,7 @@ static void reportWallDrawn(Line &line) if(line.isMappedByPlayer(playerNum)) return; // Mark as drawn. - line.markMappedByPlayer(playerNum); + line.setMappedByPlayer(playerNum); // Send a status report. if(gx.HandleMapObjectStatusReport) @@ -2023,17 +2023,17 @@ static bool renderWorldPoly(Vector3f const *rvertices, duint numVertices, static Lumobj::LightmapSemantic lightmapForSurface(Surface const &surface) { - if(surface.parent().type() == DMU_SIDE) return Lumobj::Side; + if (surface.parent().type() == DMU_SIDE) return Lumobj::Side; // Must be a plane then. auto const &plane = surface.parent().as(); - return plane.isSectorFloor()? Lumobj::Down : Lumobj::Up; + return plane.isSectorFloor() ? Lumobj::Down : Lumobj::Up; } static DGLuint prepareLightmap(ClientTexture *tex = nullptr) { - if(tex) + if (tex) { - if(TextureVariant *variant = tex->prepareVariant(Rend_MapSurfaceLightmapTextureSpec())) + if (TextureVariant *variant = tex->prepareVariant(Rend_MapSurfaceLightmapTextureSpec())) { return variant->glName(); } @@ -2480,7 +2480,7 @@ static bool applyNearFadeOpacity(WallEdge const &leftEdge, WallEdge const &right mobj_t const *mo = viewPlayer->publicData().mo; Line const &line = leftEdge.lineSide().line(); - coord_t linePoint[2] = { line.fromOrigin().x, line.fromOrigin().y }; + coord_t linePoint[2] = { line.from().x(), line.from().y() }; coord_t lineDirection[2] = { line.direction().x, line.direction().y }; vec2d_t result; ddouble pos = V2d_ProjectOnLine(result, mo->origin, linePoint, lineDirection); @@ -5324,7 +5324,7 @@ static void drawFakeRadioShadowPoints(Map &map) LineOwner const *own = base; do { - coord_t const z = own->line().frontSector().floor().heightSmoothed(); + coord_t const z = own->line().front().sector().floor().heightSmoothed(); drawPoint(Vector3d(vtx.origin() + own->extendedShadowOffset(), z), yellow); drawPoint(Vector3d(vtx.origin() + own->innerShadowOffset (), z), red); diff --git a/doomsday/apps/client/src/render/rend_particle.cpp b/doomsday/apps/client/src/render/rend_particle.cpp index 3f6cbd55f8..0753de2de5 100644 --- a/doomsday/apps/client/src/render/rend_particle.cpp +++ b/doomsday/apps/client/src/render/rend_particle.cpp @@ -498,12 +498,12 @@ static void drawParticles(dint rtype, bool withBlend) // Should we use a texture? DGLuint tex = 0; - if(rtype == PTC_POINT || - (rtype >= PTC_TEXTURE && rtype < PTC_TEXTURE + MAX_PTC_TEXTURES)) + if (rtype == PTC_POINT + || (rtype >= PTC_TEXTURE && rtype < PTC_TEXTURE + MAX_PTC_TEXTURES)) { - if(renderTextures) + if (renderTextures) { - if(rtype == PTC_POINT || 0 == ptctexname[rtype - PTC_TEXTURE]) + if (rtype == PTC_POINT || 0 == ptctexname[rtype - PTC_TEXTURE]) tex = pointTex; else tex = ptctexname[rtype - PTC_TEXTURE]; @@ -511,7 +511,7 @@ static void drawParticles(dint rtype, bool withBlend) } ushort primType = GL_QUADS; - if(rtype == PTC_MODEL) + if (rtype == PTC_MODEL) { //glDepthMask(GL_TRUE); //glEnable(GL_DEPTH_TEST); @@ -520,7 +520,7 @@ static void drawParticles(dint rtype, bool withBlend) .setDepthTest(true) .apply(); } - else if(tex != 0) + else if (tex != 0) { //glDepthMask(GL_FALSE); //glDisable(GL_CULL_FACE); @@ -543,43 +543,43 @@ static void drawParticles(dint rtype, bool withBlend) // How many particles will be drawn? size_t i = 0; - if(maxParticles) + if (maxParticles) { i = numParts - (unsigned) maxParticles; } blendmode_t mode = BM_NORMAL, newMode; - for(; i < numParts; ++i) + for (; i < numParts; ++i) { OrderedParticle const *slot = &order[i]; Generator const *gen = slot->generator; - ParticleInfo const *pinfo = &gen->particleInfo()[slot->particleId]; + ParticleInfo const &pinfo = gen->particleInfo()[slot->particleId]; - GeneratorParticleStage const *st = &gen->stages[pinfo->stage]; - ded_ptcstage_t const *stDef = &gen->def->stages[pinfo->stage]; + GeneratorParticleStage const *st = &gen->stages[pinfo.stage]; + ded_ptcstage_t const *stDef = &gen->def->stages[pinfo.stage]; dshort stageType = st->type; - if(stageType >= PTC_TEXTURE && stageType < PTC_TEXTURE + MAX_PTC_TEXTURES && - 0 == ptctexname[stageType - PTC_TEXTURE]) + if (stageType >= PTC_TEXTURE && stageType < PTC_TEXTURE + MAX_PTC_TEXTURES && + 0 == ptctexname[stageType - PTC_TEXTURE]) { stageType = PTC_POINT; } // Only render one type of particles. - if((rtype == PTC_MODEL && stDef->model < 0) || - (rtype != PTC_MODEL && stageType != rtype)) + if ((rtype == PTC_MODEL && stDef->model < 0) || + (rtype != PTC_MODEL && stageType != rtype)) { continue; } - if(rtype >= PTC_TEXTURE && rtype < PTC_TEXTURE + MAX_PTC_TEXTURES && - 0 == ptctexname[rtype - PTC_TEXTURE]) + if (rtype >= PTC_TEXTURE && rtype < PTC_TEXTURE + MAX_PTC_TEXTURES && + 0 == ptctexname[rtype - PTC_TEXTURE]) continue; - if((gen->blendmode() != BM_ADD) == withBlend) + if ((gen->blendmode() != BM_ADD) == withBlend) continue; - if(rtype != PTC_MODEL && !withBlend) + if (rtype != PTC_MODEL && !withBlend) { // We may need to change the blending mode. newMode = gen->blendmode(); @@ -594,19 +594,19 @@ static void drawParticles(dint rtype, bool withBlend) // Is there a next stage for this particle? ded_ptcstage_t const *nextStDef; - if(pinfo->stage >= gen->def->stages.size() - 1 || - !gen->stages[pinfo->stage + 1].type) + if (pinfo.stage >= gen->def->stages.size() - 1 || + !gen->stages[pinfo.stage + 1].type) { // There is no "next stage". Use the current one. - nextStDef = &gen->def->stages[pinfo->stage]; + nextStDef = &gen->def->stages[pinfo.stage]; } else { - nextStDef = &gen->def->stages[pinfo->stage + 1]; + nextStDef = &gen->def->stages[pinfo.stage + 1]; } // Where is intermark? - dfloat const inter = 1 - dfloat( pinfo->tics ) / stDef->tics; + dfloat const inter = 1 - dfloat( pinfo.tics ) / stDef->tics; // Calculate size and color. dfloat size = de::lerp( stDef->particleRadius(slot->particleId), @@ -621,7 +621,7 @@ static void drawParticles(dint rtype, bool withBlend) { // This is a simplified version of sectorlight (no distance // attenuation or range compression). - if(world::ConvexSubspace *subspace = pinfo->bspLeaf->subspacePtr()) + if(world::ConvexSubspace *subspace = pinfo.bspLeaf->subspacePtr()) { dfloat const intensity = subspace->cluster().lightSourceIntensity(); color *= Vector4f(intensity, intensity, intensity, 1); @@ -654,14 +654,14 @@ static void drawParticles(dint rtype, bool withBlend) glColor4f(color.x, color.y, color.z, color.w); - bool const nearWall = (pinfo->contact && !pinfo->mov[0] && !pinfo->mov[1]); + bool const nearWall = (pinfo.contact && !pinfo.mov[0] && !pinfo.mov[1]); bool nearPlane = false; - if(world::ConvexSubspace *subspace = pinfo->bspLeaf->subspacePtr()) + if(world::ConvexSubspace *subspace = pinfo.bspLeaf->subspacePtr()) { world::SectorCluster &cluster = subspace->cluster(); - if(FLT2FIX(cluster. visFloor().heightSmoothed()) + 2 * FRACUNIT >= pinfo->origin[2] || - FLT2FIX(cluster.visCeiling().heightSmoothed()) - 2 * FRACUNIT <= pinfo->origin[2]) + if(FLT2FIX(cluster. visFloor().heightSmoothed()) + 2 * FRACUNIT >= pinfo.origin[2] || + FLT2FIX(cluster.visCeiling().heightSmoothed()) - 2 * FRACUNIT <= pinfo.origin[2]) { nearPlane = true; } @@ -677,19 +677,19 @@ static void drawParticles(dint rtype, bool withBlend) flatOnWall = true; } - Vector3f center = gen->particleOrigin(*pinfo).xzy(); + Vector3f center = gen->particleOrigin(pinfo).xzy(); if(!flatOnPlane && !flatOnWall) { - Vector3f offset(frameTimePos, nearPlane? 0 : frameTimePos, frameTimePos); - center += offset * gen->particleMomentum(*pinfo).xzy(); + Vector3f offset(frameTimePos, nearPlane ? 0 : frameTimePos, frameTimePos); + center += offset * gen->particleMomentum(pinfo).xzy(); } // Model particles are rendered using the normal model rendering routine. if(rtype == PTC_MODEL && stDef->model >= 0) { vissprite_t temp; de::zap(temp); - setupModelParamsForParticle(temp, pinfo, st, stDef, center, dist, size, inter, color.w); + setupModelParamsForParticle(temp, &pinfo, st, stDef, center, dist, size, inter, color.w); Rend_DrawModel(temp); continue; } @@ -715,18 +715,21 @@ static void drawParticles(dint rtype, bool withBlend) // Flat against a wall, then? else if(flatOnWall) { - vec2d_t origin, projected; + DENG2_ASSERT(pinfo.contact); + Line const &contact = *pinfo.contact; // There will be a slight approximation on the XY plane since // the particles aren't that accurate when it comes to wall // collisions. // Calculate a new center point (project onto the wall). - V2d_Set(origin, FIX2FLT(pinfo->origin[0]), FIX2FLT(pinfo->origin[1])); + vec2d_t origin; + V2d_Set(origin, FIX2FLT(pinfo.origin[0]), FIX2FLT(pinfo.origin[1])); - coord_t linePoint[2] = { pinfo->contact->fromOrigin().x, pinfo->contact->fromOrigin().y }; - coord_t lineDirection[2] = { pinfo->contact->direction().x, pinfo->contact->direction().y }; - V2d_ProjectOnLine(projected, origin, linePoint, lineDirection); + vec2d_t projected; + V2d_ProjectOnLine(projected, origin, + contact.from().origin().data().baseAs(), + contact.direction().data().baseAs()); // Move away from the wall to avoid the worst Z-fighting. ddouble const gap = -1; // 1 map unit. @@ -738,8 +741,7 @@ static void drawParticles(dint rtype, bool withBlend) projected[1] += diff[1] / dist * gap; } - DENG2_ASSERT(pinfo->contact); - Vector2f unitVec = lineUnitVector(*pinfo->contact); + Vector2f unitVec = lineUnitVector(*pinfo.contact); glTexCoord2f(0, 0); glVertex3d(projected[0] - size * unitVec.x, center.y - size, @@ -783,9 +785,9 @@ static void drawParticles(dint rtype, bool withBlend) else // It's a line. { glVertex3f(center.x, center.y, center.z); - glVertex3f(center.x - FIX2FLT(pinfo->mov[0]), - center.y - FIX2FLT(pinfo->mov[2]), - center.z - FIX2FLT(pinfo->mov[1])); + glVertex3f(center.x - FIX2FLT(pinfo.mov[0]), + center.y - FIX2FLT(pinfo.mov[2]), + center.z - FIX2FLT(pinfo.mov[1])); } } diff --git a/doomsday/apps/client/src/render/shadowedge.cpp b/doomsday/apps/client/src/render/shadowedge.cpp index 13c8422b6c..c08f5e9161 100644 --- a/doomsday/apps/client/src/render/shadowedge.cpp +++ b/doomsday/apps/client/src/render/shadowedge.cpp @@ -91,10 +91,10 @@ static dfloat opennessFactor(dfloat fz, dfloat bz, dfloat bhz) /// @todo fixme: Should use the visual plane heights of sector clusters. static bool middleMaterialCoversOpening(LineSide const &side) { - if(!side.hasSector()) return false; // Never. + if (!side.hasSector()) return false; // Never. - if(!side.hasSections()) return false; - if(!side.middle().hasMaterial()) return false; + if (!side.hasSections()) return false; + if (!side.middle().hasMaterial()) return false; MaterialAnimator &matAnimator = side.middle().material().as() .getAnimator(Rend_MapSurfaceMaterialSpec()); @@ -103,10 +103,10 @@ static bool middleMaterialCoversOpening(LineSide const &side) matAnimator.prepare(); // Might the material cover the opening? - if(matAnimator.isOpaque() && !side.middle().blendMode() && side.middle().opacity() >= 1) + if (matAnimator.isOpaque() && !side.middle().blendMode() && side.middle().opacity() >= 1) { // Stretched middles always cover the opening. - if(side.isFlagged(SDF_MIDDLE_STRETCH)) + if (side.isFlagged(SDF_MIDDLE_STRETCH)) return true; Sector const &frontSec = side.sector(); @@ -114,7 +114,7 @@ static bool middleMaterialCoversOpening(LineSide const &side) // Determine the opening between the visual sector planes at this edge. coord_t openBottom; - if(backSec && backSec->floor().heightSmoothed() > frontSec.floor().heightSmoothed()) + if (backSec && backSec->floor().heightSmoothed() > frontSec.floor().heightSmoothed()) { openBottom = backSec->floor().heightSmoothed(); } @@ -124,7 +124,7 @@ static bool middleMaterialCoversOpening(LineSide const &side) } coord_t openTop; - if(backSec && backSec->ceiling().heightSmoothed() < frontSec.ceiling().heightSmoothed()) + if (backSec && backSec->ceiling().heightSmoothed() < frontSec.ceiling().heightSmoothed()) { openTop = backSec->ceiling().heightSmoothed(); } @@ -133,7 +133,7 @@ static bool middleMaterialCoversOpening(LineSide const &side) openTop = frontSec.ceiling().heightSmoothed(); } - if(matAnimator.dimensions().y >= openTop - openBottom) + if (matAnimator.dimensions().y >= openTop - openBottom) { // Possibly; check the placement. if(side.leftHEdge()) // possibility of degenerate BSP leaf @@ -164,37 +164,37 @@ void ShadowEdge::prepare(dint planeIndex) // there won't be a shadow at all. Open neighbor sectors cause some changes // in the polygon corner vertices (placement, opacity). - if(hedge.twin().hasFace() && - hedge.twin().face().mapElementAs().hasCluster()) + if (hedge.twin().hasFace() && + hedge.twin().face().mapElementAs().hasCluster()) { SectorCluster const &backCluster = hedge.twin().face().mapElementAs().cluster(); Plane const &backPlane = backCluster.visPlane(planeIndex); Surface const &wallEdgeSurface = - lineSide.back().hasSector()? lineSide.surface(planeIndex == Sector::Ceiling? LineSide::Top : LineSide::Bottom) - : lineSide.middle(); + lineSide.back().hasSector() ? lineSide.surface(planeIndex == Sector::Ceiling ? LineSide::Top : LineSide::Bottom) + : lineSide.middle(); // Figure out the relative plane heights. coord_t fz = plane.heightSmoothed(); - if(planeIndex == Sector::Ceiling) + if (planeIndex == Sector::Ceiling) fz = -fz; coord_t bz = backPlane.heightSmoothed(); - if(planeIndex == Sector::Ceiling) + if (planeIndex == Sector::Ceiling) bz = -bz; coord_t bhz = backCluster.plane(otherPlaneIndex).heightSmoothed(); - if(planeIndex == Sector::Ceiling) + if (planeIndex == Sector::Ceiling) bhz = -bhz; // Determine openness. - if(fz < bz && !wallEdgeSurface.hasMaterial()) + if (fz < bz && !wallEdgeSurface.hasMaterial()) { d->sectorOpenness = 2; // Consider it fully open. } // Is the back sector a closed yet sky-masked surface? - else if(cluster.visFloor().heightSmoothed() >= backCluster.visCeiling().heightSmoothed() && - cluster.visPlane(otherPlaneIndex).surface().hasSkyMaskedMaterial() && - backCluster.visPlane(otherPlaneIndex).surface().hasSkyMaskedMaterial()) + else if (cluster.visFloor().heightSmoothed() >= backCluster.visCeiling().heightSmoothed() && + cluster .visPlane(otherPlaneIndex).surface().hasSkyMaskedMaterial() && + backCluster.visPlane(otherPlaneIndex).surface().hasSkyMaskedMaterial()) { d->sectorOpenness = 2; // Consider it fully open. } @@ -202,7 +202,7 @@ void ShadowEdge::prepare(dint planeIndex) { // Does the middle material completely cover the open range (we do // not want to give away the location of any secret areas)? - if(!middleMaterialCoversOpening(lineSide)) + if (!middleMaterialCoversOpening(lineSide)) { d->sectorOpenness = opennessFactor(fz, bz, bhz); } @@ -210,7 +210,7 @@ void ShadowEdge::prepare(dint planeIndex) } // Only calculate the remaining values when the edge is at least partially open. - if(d->sectorOpenness >= 1) + if (d->sectorOpenness >= 1) return; // Find the neighbor of this wall section and determine the relative @@ -221,11 +221,11 @@ void ShadowEdge::prepare(dint planeIndex) LineOwner const *vo = &lineSide.line().vertexOwner(edge)->navigate(ClockDirection(d->edge ^ 1)); Line const &neighborLine = vo->line(); - if(&neighborLine == &lineSide.line()) + if (&neighborLine == &lineSide.line()) { d->openness = 1; // Fully open. } - else if(neighborLine.isSelfReferencing()) /// @todo Skip over these? -ds + else if (neighborLine.isSelfReferencing()) /// @todo Skip over these? -ds { d->openness = 1; } @@ -234,35 +234,35 @@ void ShadowEdge::prepare(dint planeIndex) // Choose the correct side of the neighbor (determined by which vertex is shared). LineSide const &neighborLineSide = neighborLine.side(&lineSide.line().vertex(edge) == &neighborLine.from()? d->edge ^ 1 : d->edge); - if(!neighborLineSide.hasSections() && neighborLineSide.back().hasSector()) + if (!neighborLineSide.hasSections() && neighborLineSide.back().hasSector()) { // A one-way window, open side. d->openness = 1; } - else if(!neighborLineSide.hasSector() || - (neighborLineSide.back().hasSector() && middleMaterialCoversOpening(neighborLineSide))) + else if (!neighborLineSide.hasSector() || + (neighborLineSide.back().hasSector() && middleMaterialCoversOpening(neighborLineSide))) { d->openness = 0; } - else if(neighborLineSide.back().hasSector()) + else if (neighborLineSide.back().hasSector()) { // Its a normal neighbor. Sector const *backSec = neighborLineSide.back().sectorPtr(); - if(backSec != &cluster.sector() && - !((plane.isSectorFloor () && backSec->ceiling().heightSmoothed() <= plane.heightSmoothed()) || - (plane.isSectorCeiling() && backSec->floor ().heightSmoothed() >= plane.heightSmoothed()))) + if (backSec != &cluster.sector() && + !((plane.isSectorFloor () && backSec->ceiling().heightSmoothed() <= plane.heightSmoothed()) || + (plane.isSectorCeiling() && backSec->floor ().heightSmoothed() >= plane.heightSmoothed()))) { // Figure out the relative plane heights. coord_t fz = plane.heightSmoothed(); - if(planeIndex == Sector::Ceiling) + if (planeIndex == Sector::Ceiling) fz = -fz; coord_t bz = backSec->plane(planeIndex).heightSmoothed(); - if(planeIndex == Sector::Ceiling) + if (planeIndex == Sector::Ceiling) bz = -bz; coord_t bhz = backSec->plane(otherPlaneIndex).heightSmoothed(); - if(planeIndex == Sector::Ceiling) + if (planeIndex == Sector::Ceiling) bhz = -bhz; d->openness = opennessFactor(fz, bz, bhz); @@ -270,10 +270,10 @@ void ShadowEdge::prepare(dint planeIndex) } } - if(d->openness < 1) + if (d->openness < 1) { LineOwner *vo = lineSide.line().vertexOwner(lineSide.sideId() ^ d->edge); - if(d->edge) vo = &vo->prev(); + if (d->edge) vo = &vo->prev(); d->inner = Vector3d(lineSide.vertex(d->edge).origin() + vo->innerShadowOffset(), plane.heightSmoothed()); diff --git a/doomsday/apps/client/src/render/wallspec.cpp b/doomsday/apps/client/src/render/wallspec.cpp index 7e3ecdbb46..04920c2764 100644 --- a/doomsday/apps/client/src/render/wallspec.cpp +++ b/doomsday/apps/client/src/render/wallspec.cpp @@ -32,59 +32,59 @@ using namespace de; /** * Should angle based light level deltas be applied? */ -static bool useWallSectionLightLevelDeltas(LineSide const &side, int section) +static bool useWallSectionLightLevelDeltas(LineSide const &side, dint section) { // Disabled? - if(rendLightWallAngle <= 0) - return false; + if (rendLightWallAngle <= 0) return false; // Never if the surface's material was chosen as a HOM fix (lighting must // be consistent with that applied to the relative back sector plane). - if(side.surface(section).hasFixMaterial() && - side.hasSector() && side.back().hasSector()) + if (side.surface(section).hasFixMaterial() && + side.hasSector() && side.back().hasSector()) { Sector &backSector = side.back().sector(); - if(backSector.floor().height() < backSector.ceiling().height()) + if (backSector.floor().height() < backSector.ceiling().height()) return false; } return true; } -WallSpec WallSpec::fromMapSide(LineSide const &side, int section) // static +WallSpec WallSpec::fromMapSide(LineSide const &side, dint section) // static { bool const isTwoSidedMiddle = (section == LineSide::Middle && !side.considerOneSided()); WallSpec spec(section); - if(side.line().definesPolyobj() || isTwoSidedMiddle) + if (side.line().definesPolyobj() || isTwoSidedMiddle) { spec.flags &= ~WallSpec::ForceOpaque; spec.flags |= WallSpec::NoEdgeDivisions; } - if(isTwoSidedMiddle) + if (isTwoSidedMiddle) { - if(viewPlayer && ((viewPlayer->publicData().flags & (DDPF_NOCLIP|DDPF_CAMERA)) || - !side.line().isFlagged(DDLF_BLOCKING))) + if (viewPlayer && + ((viewPlayer->publicData().flags & (DDPF_NOCLIP | DDPF_CAMERA)) || + !side.line().isFlagged(DDLF_BLOCKING))) spec.flags |= WallSpec::NearFade; spec.flags |= WallSpec::SortDynLights; } // Suppress the sky clipping in debug mode. - if(devRendSkyMode) + if (devRendSkyMode) spec.flags &= ~WallSpec::SkyClip; - if(side.line().definesPolyobj()) + if (side.line().definesPolyobj()) spec.flags |= WallSpec::NoFakeRadio; bool useLightLevelDeltas = useWallSectionLightLevelDeltas(side, section); - if(!useLightLevelDeltas) + if (!useLightLevelDeltas) spec.flags |= WallSpec::NoLightDeltas; // We can skip normal smoothing if light level delta smoothing won't be done. - if(!useLightLevelDeltas || !rendLightWallAngleSmooth) + if (!useLightLevelDeltas || !rendLightWallAngleSmooth) spec.flags |= WallSpec::NoEdgeNormalSmoothing; return spec; diff --git a/doomsday/apps/client/src/world/bsp/partitioner.cpp b/doomsday/apps/client/src/world/bsp/partitioner.cpp index 2524756a1e..e8d658badd 100644 --- a/doomsday/apps/client/src/world/bsp/partitioner.cpp +++ b/doomsday/apps/client/src/world/bsp/partitioner.cpp @@ -274,8 +274,8 @@ DENG2_PIMPL(Partitioner) { for(Line *line : lines) { - Sector *frontSec = line->frontSectorPtr(); - Sector *backSec = line->backSectorPtr(); + Sector *frontSec = line->front().sectorPtr(); + Sector *backSec = line->back().sectorPtr(); // Handle the "one-way window" effect. if(!backSec && line->_bspWindowSector) diff --git a/doomsday/apps/client/src/world/generator.cpp b/doomsday/apps/client/src/world/generator.cpp index 4836d4564f..52f912a355 100644 --- a/doomsday/apps/client/src/world/generator.cpp +++ b/doomsday/apps/client/src/world/generator.cpp @@ -831,8 +831,8 @@ void Generator::moveParticle(dint index) // particle should be killed (if it's moving slowly at max). if(pinfo->contact) { - Sector *front = pinfo->contact->frontSectorPtr(); - Sector *back = pinfo->contact->backSectorPtr(); + Sector *front = pinfo->contact->front().sectorPtr(); + Sector *back = pinfo->contact->back().sectorPtr(); if(front && back && abs(pinfo->mov[2]) < FRACUNIT / 2) { @@ -919,13 +919,13 @@ void Generator::moveParticle(dint index) // Bounce if we hit a solid wall. /// @todo fixme: What about "one-way" window lines? clParm.ptcHitLine = &line; - if(!line.hasBackSector()) + if(!line.back().hasSector()) { return LoopAbort; // Boing! } - Sector *front = line.frontSectorPtr(); - Sector *back = line.backSectorPtr(); + Sector *front = line.front().sectorPtr(); + Sector *back = line.back().sectorPtr(); // Determine the opening we have here. /// @todo Use R_OpenRange() diff --git a/doomsday/apps/client/src/world/interceptor.cpp b/doomsday/apps/client/src/world/interceptor.cpp index 601f6e32ef..453c7cc19f 100644 --- a/doomsday/apps/client/src/world/interceptor.cpp +++ b/doomsday/apps/client/src/world/interceptor.cpp @@ -192,14 +192,14 @@ DENG2_PIMPL_NOREF(Interceptor) fixed_t origin[2] = { DBL2FIX(from.x), DBL2FIX(from.y) }; fixed_t direction[2] = { DBL2FIX(to.x - from.x), DBL2FIX(to.y - from.y) }; - fixed_t lineFromX[2] = { DBL2FIX(line.fromOrigin().x), DBL2FIX(line.fromOrigin().y) }; - fixed_t lineToX[2] = { DBL2FIX( line.toOrigin().x), DBL2FIX( line.toOrigin().y) }; + fixed_t lineFromX[2] = { DBL2FIX(line.from().x()), DBL2FIX(line.from().y()) }; + fixed_t lineToX[2] = { DBL2FIX(line.to ().x()), DBL2FIX(line.to ().y()) }; // Is this line crossed? // Avoid precision problems with two routines. dint s1, s2; - if(direction[0] > FRACUNIT * 16 || direction[1] > FRACUNIT * 16 || - direction[0] < -FRACUNIT * 16 || direction[1] < -FRACUNIT * 16) + if ( direction[0] > FRACUNIT * 16 || direction[1] > FRACUNIT * 16 + || direction[0] < -FRACUNIT * 16 || direction[1] < -FRACUNIT * 16) { s1 = V2x_PointOnLineSide(lineFromX, origin, direction); s2 = V2x_PointOnLineSide(lineToX, origin, direction); @@ -212,14 +212,14 @@ DENG2_PIMPL_NOREF(Interceptor) } // Is this line crossed? - if(s1 == s2) return; + if (s1 == s2) return; // Calculate interception point. fixed_t lineDirectionX[2] = { DBL2FIX(line.direction().x), DBL2FIX(line.direction().y) }; dfloat distance = FIX2FLT(V2x_Intersection(lineFromX, lineDirectionX, origin, direction)); // On the correct side of the trace origin? - if(distance >= 0) + if (distance >= 0) { addIntercept(ICPT_LINE, distance, &line); } diff --git a/doomsday/apps/client/src/world/line.cpp b/doomsday/apps/client/src/world/line.cpp index 5a31114aba..de9eb8eea3 100644 --- a/doomsday/apps/client/src/world/line.cpp +++ b/doomsday/apps/client/src/world/line.cpp @@ -20,14 +20,6 @@ #include "world/line.h" -#include -#include -#include -#include -#include -#include -#include - #include "dd_main.h" // App_Materials(), verbose #include "m_misc.h" @@ -48,6 +40,15 @@ # include "render/rend_fakeradio.h" #endif +#include +#include +#include +#include +#include +#include +#include +#include + #ifdef WIN32 # undef max # undef min @@ -58,7 +59,7 @@ using namespace world; DENG2_PIMPL_NOREF(Line::Side::Segment) { - HEdge *hedge = nullptr; ///< Half-edge attributed to the line segment (not owned). + HEdge *hedge = nullptr; ///< Half-edge attributed to the line segment (not owned). #ifdef __CLIENT__ ddouble length = 0; ///< Accurate length of the segment. @@ -74,6 +75,16 @@ Line::Side::Segment::Segment(Line::Side &lineSide, HEdge &hedge) d->hedge = &hedge; } +Line::Side &Line::Side::Segment::lineSide() +{ + return parent().as(); +} + +Line::Side const &Line::Side::Segment::lineSide() const +{ + return parent().as(); +} + HEdge &Line::Side::Segment::hedge() const { DENG2_ASSERT(d->hedge); @@ -122,8 +133,7 @@ DENG2_PIMPL_NOREF(Line::Side) dint flags = 0; ///< @ref sdefFlags Sector *sector = nullptr; ///< Attributed sector (not owned). - typedef QList Segments; - Segments segments; ///< On "this" side, sorted. + QList segments; ///< On "this" side, sorted. bool needSortSegments = false; ///< set to @c true when the list needs sorting. dint shadowVisCount = 0; ///< Framecount of last time shadows were drawn. @@ -151,24 +161,17 @@ DENG2_PIMPL_NOREF(Line::Side) #ifdef __CLIENT__ /** - * Stores data for FakeRadio. + * POD: FakeRadio geometry and shadow state. */ struct RadioData { + std::array spans; ///< { bottom, top } + std::array topCorners; ///< { left, right } + std::array bottomCorners; ///< { left, right } + std::array sideCorners; ///< { left, right } de::dint updateFrame = 0; - edgespan_t spans[2]; ///< { bottom, top } - shadowcorner_t topCorners[2]; ///< { left, right } - shadowcorner_t bottomCorners[2]; ///< { left, right } - shadowcorner_t sideCorners[2]; ///< { left, right } - - RadioData() - { - de::zap(spans); - de::zap(topCorners); - de::zap(bottomCorners); - de::zap(sideCorners); - } - } radioData; + }; + RadioData radioData; #endif ~Impl() { qDeleteAll(segments); } @@ -178,9 +181,9 @@ DENG2_PIMPL_NOREF(Line::Side) */ Section §ionById(dint sectionId) { - if(sections) + if (sections) { - switch(sectionId) + switch (sectionId) { case Middle: return sections->middle; case Bottom: return sections->bottom; @@ -195,12 +198,12 @@ DENG2_PIMPL_NOREF(Line::Side) { needSortSegments = false; - if(segments.count() < 2) + if (segments.count() < 2) return; // We'll use a QMap for sorting the segments. QMap sortedSegs; - for(Segment *seg : segments) + for (Segment *seg : segments) { sortedSegs.insert((seg->hedge().origin() - lineSideOrigin).length(), seg); } @@ -213,7 +216,7 @@ DENG2_PIMPL_NOREF(Line::Side) DENG2_ASSERT(sector); sc.corner = openness; sc.proximity = proximityPlane; - if(sc.proximity) + if (sc.proximity) { // Determine relative height offsets (affects shadow map selection). sc.pHeight = sc.proximity->heightSmoothed(); @@ -244,13 +247,13 @@ DENG2_PIMPL_NOREF(Line::Side) /** * Change the FakeRadio "edge span" metrics. - * @todo replace shadow edge enumeration with a shadow corner enumeration. + * @todo Replace shadow edge enumeration with a shadow corner enumeration. -ds */ void setRadioEdgeSpan(bool top, bool right, ddouble length) { edgespan_t &span = radioData.spans[dint(top)]; span.length = length; - if(!right) + if (!right) { span.shift = span.length; } @@ -259,13 +262,13 @@ DENG2_PIMPL_NOREF(Line::Side) /// Observes Line FlagsChange void lineFlagsChanged(Line &line, dint oldFlags) { - if(sections) + if (sections) { - if((line.flags() & DDLF_DONTPEGTOP) != (oldFlags & DDLF_DONTPEGTOP)) + if ((line.flags() & DDLF_DONTPEGTOP) != (oldFlags & DDLF_DONTPEGTOP)) { sections->top.surface.markForDecorationUpdate(); } - if((line.flags() & DDLF_DONTPEGBOTTOM) != (oldFlags & DDLF_DONTPEGBOTTOM)) + if ((line.flags() & DDLF_DONTPEGBOTTOM) != (oldFlags & DDLF_DONTPEGBOTTOM)) { sections->bottom.surface.markForDecorationUpdate(); } @@ -284,19 +287,34 @@ Line::Side::Side(Line &line, Sector *sector) #endif } +Line &Line::Side::line() +{ + return parent().as(); +} + +Line const &Line::Side::line() const +{ + return parent().as(); +} + +bool Line::Side::isFront() const +{ + return sideId() == Line::Front; +} + String Line::Side::description() const { String const name = (isFront() ? "Front" : "Back"); QStringList flagNames; - if(flags() & SDF_BLENDTOPTOMID) flagNames << "blendtoptomiddle"; - if(flags() & SDF_BLENDMIDTOTOP) flagNames << "blendmiddletotop"; - if(flags() & SDF_BLENDMIDTOBOTTOM) flagNames << "blendmiddletobottom"; - if(flags() & SDF_BLENDBOTTOMTOMID) flagNames << "blendbottomtomiddle"; - if(flags() & SDF_MIDDLE_STRETCH) flagNames << "middlestretch"; + if (flags() & SDF_BLENDTOPTOMID) flagNames << "blendtoptomiddle"; + if (flags() & SDF_BLENDMIDTOTOP) flagNames << "blendmiddletotop"; + if (flags() & SDF_BLENDMIDTOBOTTOM) flagNames << "blendmiddletobottom"; + if (flags() & SDF_BLENDBOTTOMTOMID) flagNames << "blendbottomtomiddle"; + if (flags() & SDF_MIDDLE_STRETCH) flagNames << "middlestretch"; String flagsString; - if(!flagNames.isEmpty()) + if (!flagNames.isEmpty()) { String const flagsAsText = flagNames.join("|"); flagsString = String(_E(l) " Flags: " _E(.)_E(i) "%1" _E(.)).arg(flagsAsText); @@ -331,22 +349,22 @@ dint Line::Side::sideId() const bool Line::Side::considerOneSided() const { // Are we suppressing the back sector? - if(d->flags & SDF_SUPPRESS_BACK_SECTOR) return true; + if (d->flags & SDF_SUPPRESS_BACK_SECTOR) return true; - if(!back().hasSector()) return true; + if (!back().hasSector()) return true; // Front side of a "one-way window"? - if(!back().hasSections()) return true; + if (!back().hasSections()) return true; - if(!line().definesPolyobj()) + if (!line().definesPolyobj()) { // If no segment is linked then the convex subspace on "this" side must // have been degenerate (thus no geometry). HEdge *hedge = leftHEdge(); - if(!hedge || !hedge->twin().hasFace()) + if (!hedge || !hedge->twin().hasFace()) return true; - if(!hedge->twin().face().mapElementAs().hasCluster()) + if (!hedge->twin().face().mapElementAs().hasCluster()) return true; } @@ -360,9 +378,14 @@ bool Line::Side::hasSector() const Sector &Line::Side::sector() const { - if(d->sector) return *d->sector; - /// @throw Line::MissingSectorError Attempted with no sector attributed. - throw Line::MissingSectorError("Line::Side::sector", "No sector is attributed"); + if (d->sector) return *d->sector; + /// @throw MissingSectorError Attempted with no sector attributed. + throw MissingSectorError("Line::Side::sector", "No sector is attributed"); +} + +Sector *Line::Side::sectorPtr() const +{ + return hasSector() ? §or() : nullptr; } bool Line::Side::hasSections() const @@ -373,7 +396,7 @@ bool Line::Side::hasSections() const void Line::Side::addSections() { // Already defined? - if(hasSections()) return; + if (hasSections()) return; d->sections.reset(new Impl::Sections(*this)); } @@ -390,11 +413,11 @@ Surface const &Line::Side::surface(dint sectionId) const LoopResult Line::Side::forAllSurfaces(std::function func) const { - if(hasSections()) + if (hasSections()) { - for(dint i = Middle; i <= Top; ++i) + for (dint i = Middle; i <= Top; ++i) { - if(auto result = func(const_cast(this)->surface(i))) + if (auto result = func(const_cast(this)->surface(i))) return result; } } @@ -420,14 +443,14 @@ void Line::Side::clearSegments() Line::Side::Segment *Line::Side::addSegment(HEdge &hedge) { // Have we an exiting segment for this half-edge? - for(Segment *seg : d->segments) + for (Segment *seg : d->segments) { - if(&seg->hedge() == &hedge) + if (&seg->hedge() == &hedge) return seg; } // No, insert a new one. - Segment *newSeg = new Segment(*this, hedge); + auto *newSeg = new Segment(*this, hedge); d->segments.append(newSeg); d->needSortSegments = true; // We'll need to (re)sort. @@ -440,7 +463,8 @@ Line::Side::Segment *Line::Side::addSegment(HEdge &hedge) HEdge *Line::Side::leftHEdge() const { if(d->segments.isEmpty()) return nullptr; - if(d->needSortSegments) + + if (d->needSortSegments) { d->sortSegments(from().origin()); } @@ -449,8 +473,9 @@ HEdge *Line::Side::leftHEdge() const HEdge *Line::Side::rightHEdge() const { - if(d->segments.isEmpty()) return nullptr; - if(d->needSortSegments) + if (d->segments.isEmpty()) return nullptr; + + if (d->needSortSegments) { d->sortSegments(from().origin()); } @@ -461,7 +486,7 @@ void Line::Side::updateSoundEmitterOrigin(dint sectionId) { LOG_AS("Line::Side::updateSoundEmitterOrigin"); - if(!hasSections()) return; + if (!hasSections()) return; SoundEmitter &emitter = d->sectionById(sectionId).soundEmitter; @@ -474,10 +499,10 @@ void Line::Side::updateSoundEmitterOrigin(dint sectionId) ddouble const fceil = d->sector->ceiling().height(); /// @todo fixme what if considered one-sided? - switch(sectionId) + switch (sectionId) { case Middle: - if(!back().hasSections() || line().isSelfReferencing()) + if (!back().hasSections() || line().isSelfReferencing()) { emitter.origin[2] = (ffloor + fceil) / 2; } @@ -489,8 +514,8 @@ void Line::Side::updateSoundEmitterOrigin(dint sectionId) break; case Bottom: - if(!back().hasSections() || line().isSelfReferencing() || - back().sector().floor().height() <= ffloor) + if (!back().hasSections() || line().isSelfReferencing() + || back().sector().floor().height() <= ffloor) { emitter.origin[2] = ffloor; } @@ -501,8 +526,8 @@ void Line::Side::updateSoundEmitterOrigin(dint sectionId) break; case Top: - if(!back().hasSections() || line().isSelfReferencing() || - back().sector().ceiling().height() >= fceil) + if (!back().hasSections() || line().isSelfReferencing() + || back().sector().ceiling().height() >= fceil) { emitter.origin[2] = fceil; } @@ -516,7 +541,7 @@ void Line::Side::updateSoundEmitterOrigin(dint sectionId) void Line::Side::updateAllSoundEmitterOrigins() { - if(!hasSections()) return; + if (!hasSections()) return; updateMiddleSoundEmitterOrigin(); updateBottomSoundEmitterOrigin(); @@ -525,7 +550,7 @@ void Line::Side::updateAllSoundEmitterOrigins() void Line::Side::updateSurfaceNormals() { - if(!hasSections()) return; + if (!hasSections()) return; Vector3f normal(( to().origin().y - from().origin().y) / line().length(), (from().origin().x - to().origin().x) / line().length(), @@ -550,17 +575,17 @@ void Line::Side::setFlags(dint flagsToChange, FlagOp operation) void Line::Side::chooseSurfaceTintColors(dint sectionId, Vector3f const **topColor, Vector3f const **bottomColor) const { - if(hasSections()) + if (hasSections()) { - switch(sectionId) + switch (sectionId) { case Middle: - if(isFlagged(SDF_BLENDMIDTOTOP)) + if (isFlagged(SDF_BLENDMIDTOTOP)) { *topColor = &top ().tintColor(); *bottomColor = &middle().tintColor(); } - else if(isFlagged(SDF_BLENDMIDTOBOTTOM)) + else if (isFlagged(SDF_BLENDMIDTOBOTTOM)) { *topColor = &middle().tintColor(); *bottomColor = &bottom().tintColor(); @@ -573,7 +598,7 @@ void Line::Side::chooseSurfaceTintColors(dint sectionId, Vector3f const **topCol return; case Top: - if(isFlagged(SDF_BLENDTOPTOMID)) + if (isFlagged(SDF_BLENDTOPTOMID)) { *topColor = &top ().tintColor(); *bottomColor = &middle().tintColor(); @@ -586,7 +611,7 @@ void Line::Side::chooseSurfaceTintColors(dint sectionId, Vector3f const **topCol return; case Bottom: - if(isFlagged(SDF_BLENDBOTTOMTOMID)) + if (isFlagged(SDF_BLENDBOTTOMTOMID)) { *topColor = &middle().tintColor(); *bottomColor = &bottom().tintColor(); @@ -599,8 +624,8 @@ void Line::Side::chooseSurfaceTintColors(dint sectionId, Vector3f const **topCol return; } } - /// @throw Line::InvalidSectionIdError The given section identifier is not valid. - throw Line::InvalidSectionIdError("Line::Side::chooseSurfaceTintColors", "Invalid section id " + String::number(sectionId)); + /// @throw InvalidSectionIdError The given section identifier is not valid. + throw InvalidSectionIdError("Line::Side::chooseSurfaceTintColors", "Invalid section id " + String::number(sectionId)); } dint Line::Side::shadowVisCount() const @@ -617,10 +642,10 @@ void Line::Side::setShadowVisCount(dint newCount) static bool materialHasAnimatedTextureLayers(Material const &mat) { - for(dint i = 0; i < mat.layerCount(); ++i) + for (dint i = 0; i < mat.layerCount(); ++i) { MaterialLayer const &layer = mat.layer(i); - if(!layer.is() && !layer.is()) + if (!layer.is() && !layer.is()) { if(layer.isAnimated()) return true; } @@ -642,19 +667,19 @@ static Material *chooseFixMaterial(LineSide &side, dint section) Sector *frontSec = side.sectorPtr(); Sector *backSec = side.back().sectorPtr(); - if(backSec) + if (backSec) { // Our first choice is a material in the other sector. - if(section == LineSide::Bottom) + if (section == LineSide::Bottom) { - if(frontSec->floor().height() < backSec->floor().height()) + if (frontSec->floor().height() < backSec->floor().height()) { choice1 = backSec->floorSurface().materialPtr(); } } - else if(section == LineSide::Top) + else if (section == LineSide::Top) { - if(frontSec->ceiling().height() > backSec->ceiling().height()) + if (frontSec->ceiling().height() > backSec->ceiling().height()) { choice1 = backSec->ceilingSurface().materialPtr(); } @@ -662,7 +687,7 @@ static Material *chooseFixMaterial(LineSide &side, dint section) // In the special case of sky mask on the back plane, our best // choice is always this material. - if(choice1 && choice1->isSkyMasked()) + if (choice1 && choice1->isSkyMasked()) { return choice1; } @@ -673,16 +698,16 @@ static Material *chooseFixMaterial(LineSide &side, dint section) // Try the left neighbor first. Line *other = R_FindLineNeighbor(side.line(), *side.line().vertexOwner(side.sideId()), Clockwise, frontSec); - if(!other) + if (!other) { // Try the right neighbor. other = R_FindLineNeighbor(side.line(), *side.line().vertexOwner(side.sideId()^1), Anticlockwise, frontSec); } - if(other) + if (other) { - if(!other->hasBackSector()) + if (!other->back().hasSector()) { // Our choice is clear - the middle material. choice1 = other->front().middle().materialPtr(); @@ -690,16 +715,16 @@ static Material *chooseFixMaterial(LineSide &side, dint section) else { // Compare the relative heights to decide. - LineSide &otherSide = other->side(&other->frontSector() == frontSec? Line::Front : Line::Back); - Sector &otherSec = other->side(&other->frontSector() == frontSec? Line::Back : Line::Front).sector(); + LineSide &otherSide = other->side(&other->front().sector() == frontSec ? Line::Front : Line::Back); + Sector &otherSec = other->side(&other->front().sector() == frontSec ? Line::Back : Line::Front).sector(); - if(otherSec.ceiling().height() <= frontSec->floor().height()) + if (otherSec.ceiling().height() <= frontSec->floor().height()) choice1 = otherSide.top().materialPtr(); - else if(otherSec.floor().height() >= frontSec->ceiling().height()) + else if (otherSec.floor().height() >= frontSec->ceiling().height()) choice1 = otherSide.bottom().materialPtr(); - else if(otherSec.ceiling().height() < frontSec->ceiling().height()) + else if (otherSec.ceiling().height() < frontSec->ceiling().height()) choice1 = otherSide.top().materialPtr(); - else if(otherSec.floor().height() > frontSec->floor().height()) + else if (otherSec.floor().height() > frontSec->floor().height()) choice1 = otherSide.bottom().materialPtr(); // else we'll settle for a plane material. } @@ -710,20 +735,20 @@ static Material *chooseFixMaterial(LineSide &side, dint section) choice2 = frontSec->planeSurface(section == LineSide::Bottom? Sector::Floor : Sector::Ceiling).materialPtr(); // Prefer a non-animated, non-masked material. - if(choice1 && !materialHasAnimatedTextureLayers(*choice1) && !choice1->isSkyMasked()) + if (choice1 && !materialHasAnimatedTextureLayers(*choice1) && !choice1->isSkyMasked()) return choice1; - if(choice2 && !materialHasAnimatedTextureLayers(*choice2) && !choice2->isSkyMasked()) + if (choice2 && !materialHasAnimatedTextureLayers(*choice2) && !choice2->isSkyMasked()) return choice2; // Prefer a non-masked material. - if(choice1 && !choice1->isSkyMasked()) + if (choice1 && !choice1->isSkyMasked()) return choice1; - if(choice2 && !choice2->isSkyMasked()) + if (choice2 && !choice2->isSkyMasked()) return choice2; // At this point we'll accept anything if it means avoiding HOM. - if(choice1) return choice1; - if(choice2) return choice2; + if (choice1) return choice1; + if (choice2) return choice2; // We'll assign the special "missing" material... return &world::Materials::get().material(de::Uri("System", Path("missing"))); @@ -732,15 +757,15 @@ static Material *chooseFixMaterial(LineSide &side, dint section) static void addMissingMaterial(LineSide &side, dint section) { // Sides without sections need no fixing. - if(!side.hasSections()) return; + if (!side.hasSections()) return; // ...nor those of self-referencing lines. - if(side.line().isSelfReferencing()) return; + if (side.line().isSelfReferencing()) return; // ...nor those of "one-way window" lines. - if(!side.back().hasSections() && side.back().hasSector()) return; + if (!side.back().hasSections() && side.back().hasSector()) return; // A material must actually be missing to qualify for fixing. Surface &surface = side.surface(section); - if(surface.hasMaterial() && !surface.hasFixMaterial()) + if (surface.hasMaterial() && !surface.hasFixMaterial()) return; Material *oldMaterial = surface.materialPtr(); @@ -748,13 +773,13 @@ static void addMissingMaterial(LineSide &side, dint section) // Look for and apply a suitable replacement (if found). surface.setMaterial(chooseFixMaterial(side, section), true/* is missing fix */); - if(oldMaterial == surface.materialPtr()) + if (oldMaterial == surface.materialPtr()) return; // We'll need to recalculate reverb. - if(HEdge *hedge = side.leftHEdge()) + if (HEdge *hedge = side.leftHEdge()) { - if(hedge->hasFace() && hedge->face().hasMapElement()) + if (hedge->hasFace() && hedge->face().hasMapElement()) { SectorCluster &cluster = hedge->face().mapElementAs().cluster(); cluster.markReverbDirty(); @@ -763,48 +788,48 @@ static void addMissingMaterial(LineSide &side, dint section) } // During map setup we log missing materials. - if(ddMapSetup && verbose) + if (ddMapSetup && verbose) { String path = surface.hasMaterial()? surface.material().manifest().composeUri().asText() : ""; LOG_WARNING("%s of Line #%d is missing a material for the %s section.\n" " %s was chosen to complete the definition.") - << (side.isBack()? "Back" : "Front") << side.line().indexInMap() - << (section == LineSide::Middle? "middle" : section == LineSide::Top? "top" : "bottom") + << (side.isBack() ? "Back" : "Front") << side.line().indexInMap() + << (section == LineSide::Middle ? "middle" : section == LineSide::Top? "top" : "bottom") << path; } } void Line::Side::fixMissingMaterials() { - if(hasSector() && back().hasSector()) + if (hasSector() && back().hasSector()) { Sector const &frontSec = sector(); Sector const &backSec = back().sector(); // A potential bottom section fix? - if(!(frontSec.floorSurface().hasSkyMaskedMaterial() && - backSec.floorSurface().hasSkyMaskedMaterial())) + if (!(frontSec.floorSurface().hasSkyMaskedMaterial() && + backSec .floorSurface().hasSkyMaskedMaterial())) { - if(frontSec.floor().height() < backSec.floor().height()) + if (frontSec.floor().height() < backSec.floor().height()) { addMissingMaterial(*this, LineSide::Bottom); } - else if(bottom().hasFixMaterial()) + else if (bottom().hasFixMaterial()) { bottom().setMaterial(0); } } // A potential top section fix? - if(!(frontSec.ceilingSurface().hasSkyMaskedMaterial() && - backSec.ceilingSurface().hasSkyMaskedMaterial())) + if (!(frontSec.ceilingSurface().hasSkyMaskedMaterial() && + backSec .ceilingSurface().hasSkyMaskedMaterial())) { - if(backSec.ceiling().height() < frontSec.ceiling().height()) + if (backSec.ceiling().height() < frontSec.ceiling().height()) { addMissingMaterial(*this, LineSide::Top); } - else if(top().hasFixMaterial()) + else if (top().hasFixMaterial()) { top().setMaterial(0); } @@ -843,13 +868,13 @@ edgespan_t const &Line::Side::radioEdgeSpan(bool top) const static dfloat radioCornerOpenness(binangle_t angle) { // Facing outwards? - if(angle > BANG_180) return -1; + if (angle > BANG_180) return -1; // Precisely collinear? - if(angle == BANG_180) return 0; + if (angle == BANG_180) return 0; // If the difference is too small consider it collinear (there won't be a shadow). - if(angle < BANG_45 / 5) return 0; + if (angle < BANG_45 / 5) return 0; // 90 degrees is the largest effective difference. return (angle > BANG_90)? dfloat( BANG_90 ) / angle : dfloat( angle ) / BANG_90; @@ -857,7 +882,7 @@ static dfloat radioCornerOpenness(binangle_t angle) static inline binangle_t lineNeighborAngle(LineSide const &side, Line const *other, binangle_t diff) { - return (other && other != &side.line())? diff : 0 /*Consider it coaligned*/; + return (other && other != &side.line()) ? diff : 0 /*Consider it coaligned*/; } static binangle_t findSolidLineNeighborAngle(LineSide const &side, bool right) @@ -872,7 +897,7 @@ static binangle_t findSolidLineNeighborAngle(LineSide const &side, bool right) /** * Returns @c true if there is open space in the sector. */ -static inline bool sectorOpen(Sector const *sector) +static inline bool sectorIsOpen(Sector const *sector) { return (sector && sector->ceiling().height() > sector->floor().height()); } @@ -905,14 +930,14 @@ static void scanNeighbor(LineSide const &side, bool top, bool right, edge_t &edg // Select the next line. binangle_t diff = (direction == Clockwise ? own->angle() : own->prev().angle()); Line const *iter = &own->navigate(direction).line(); - dint scanSecSide = (iter->hasFrontSector() && iter->frontSectorPtr() == startSector ? Line::Back : Line::Front); + dint scanSecSide = (iter->front().hasSector() && iter->front().sectorPtr() == startSector ? Line::Back : Line::Front); // Step selfreferencing lines. - while((!iter->hasFrontSector() && !iter->hasBackSector()) || iter->isSelfReferencing()) + while ((!iter->front().hasSector() && !iter->back().hasSector()) || iter->isSelfReferencing()) { own = &own->navigate(direction); diff += (direction == Clockwise ? own->angle() : own->prev().angle()); iter = &own->navigate(direction).line(); - scanSecSide = (iter->frontSectorPtr() == startSector); + scanSecSide = (iter->front().sectorPtr() == startSector); } // Determine the relative backsector. @@ -920,15 +945,15 @@ static void scanNeighbor(LineSide const &side, bool top, bool right, edge_t &edg Sector const *scanSector = scanSide.sectorPtr(); // Select plane heights for relative offset comparison. - ddouble const iFFloor = iter->frontSector().floor ().heightSmoothed(); - ddouble const iFCeil = iter->frontSector().ceiling().heightSmoothed(); - Sector const *bsec = iter->backSectorPtr(); + ddouble const iFFloor = iter->front().sector().floor ().heightSmoothed(); + ddouble const iFCeil = iter->front().sector().ceiling().heightSmoothed(); + Sector const *bsec = iter->back().sectorPtr(); ddouble const iBFloor = (bsec ? bsec->floor ().heightSmoothed() : 0); ddouble const iBCeil = (bsec ? bsec->ceiling().heightSmoothed() : 0); // Determine whether the relative back sector is closed. bool closed = false; - if(side.isFront() && iter->hasBackSector()) + if (side.isFront() && iter->back().hasSector()) { closed = top? (iBFloor >= fCeil) : (iBCeil <= fFloor); // Compared to "this" sector anyway. } @@ -941,13 +966,13 @@ static void scanNeighbor(LineSide const &side, bool top, bool right, edge_t &edg // Does this line's length contribute to the alignment of the texture on the // segment shadow edge being rendered? ddouble lengthDelta = 0; - if(top) + if (top) { - if(iter->hasBackSector() - && ( (side.isFront() && iter->backSectorPtr() == side.line().frontSectorPtr() && iFCeil >= fCeil) - || (side.isBack () && iter->backSectorPtr() == side.line().backSectorPtr () && iFCeil >= fCeil) - || (side.isFront() && closed == false && iter->backSectorPtr() != side.line().frontSectorPtr() - && iBCeil >= fCeil && sectorOpen(iter->backSectorPtr())))) + if (iter->back().hasSector() + && ( (side.isFront() && iter->back().sectorPtr() == side.line().front().sectorPtr() && iFCeil >= fCeil) + || (side.isBack () && iter->back().sectorPtr() == side.line().back().sectorPtr () && iFCeil >= fCeil) + || (side.isFront() && closed == false && iter->back().sectorPtr() != side.line().front().sectorPtr() + && iBCeil >= fCeil && sectorIsOpen(iter->back().sectorPtr())))) { gap += iter->length(); // Should we just mark it done instead? } @@ -959,11 +984,11 @@ static void scanNeighbor(LineSide const &side, bool top, bool right, edge_t &edg } else { - if(iter->hasBackSector() - && ( (side.isFront() && iter->backSectorPtr() == side.line().frontSectorPtr() && iFFloor <= fFloor) - || (side.isBack () && iter->backSectorPtr() == side.line().backSectorPtr () && iFFloor <= fFloor) - || (side.isFront() && closed == false && iter->backSectorPtr() != side.line().frontSectorPtr() - && iBFloor <= fFloor && sectorOpen(iter->backSectorPtr())))) + if (iter->back().hasSector() + && ( (side.isFront() && iter->back().sectorPtr() == side.line().front().sectorPtr() && iFFloor <= fFloor) + || (side.isBack () && iter->back().sectorPtr() == side.line().back().sectorPtr () && iFFloor <= fFloor) + || (side.isFront() && closed == false && iter->back().sectorPtr() != side.line().front().sectorPtr() + && iBFloor <= fFloor && sectorIsOpen(iter->back().sectorPtr())))) { gap += iter->length(); // Should we just mark it done instead? } @@ -975,30 +1000,29 @@ static void scanNeighbor(LineSide const &side, bool top, bool right, edge_t &edg } // Time to stop? - if(iter == &side.line()) - break; + if (iter == &side.line()) break; + // Not coalignable? - if(!(diff >= BANG_180 - SEP && diff <= BANG_180 + SEP)) - break; // No. + if (!(diff >= BANG_180 - SEP && diff <= BANG_180 + SEP)) break; + // Perhaps a closed edge? - if(scanSector) + if (scanSector) { - if(!sectorOpen(scanSector)) - break; + if (!sectorIsOpen(scanSector)) break; // A height difference from the start sector? - if(top) + if (top) { - if(scanSector->ceiling().heightSmoothed() != fCeil - && scanSector->floor().heightSmoothed() < startSector->ceiling().heightSmoothed()) + if (scanSector->ceiling().heightSmoothed() != fCeil + && scanSector->floor().heightSmoothed() < startSector->ceiling().heightSmoothed()) { break; } } else { - if(scanSector->floor().heightSmoothed() != fFloor - && scanSector->ceiling().heightSmoothed() > startSector->floor().heightSmoothed()) + if (scanSector->floor().heightSmoothed() != fFloor + && scanSector->ceiling().heightSmoothed() > startSector->floor().heightSmoothed()) { break; } @@ -1006,18 +1030,18 @@ static void scanNeighbor(LineSide const &side, bool top, bool right, edge_t &edg } // Swap to the iter line's owner node (i.e., around the corner)? - if(&own->navigate(direction) == iter->v2Owner()) + if (&own->navigate(direction) == iter->v2Owner()) { own = iter->v1Owner(); } - else if(&own->navigate(direction) == iter->v1Owner()) + else if (&own->navigate(direction) == iter->v1Owner()) { own = iter->v2Owner(); } // Skip into the back neighbor sector of the iter line if heights are within // the accepted range. - if(scanSector && side.back().hasSector() && scanSector != side.back().sectorPtr() + if (scanSector && side.back().hasSector() && scanSector != side.back().sectorPtr() && ( ( top && scanSector->ceiling().heightSmoothed() == startSector->ceiling().heightSmoothed()) || (!top && scanSector->floor ().heightSmoothed() == startSector->floor ().heightSmoothed()))) { @@ -1026,7 +1050,7 @@ static void scanNeighbor(LineSide const &side, bool top, bool right, edge_t &edg // be two sided isn't, we need to check whether there is a valid neighbor. Line *backNeighbor = R_FindLineNeighbor(*iter, *own, direction, startSector); - if(backNeighbor && backNeighbor != iter) + if (backNeighbor && backNeighbor != iter) { // Into the back neighbor sector. own = &own->navigate(direction); @@ -1040,13 +1064,13 @@ static void scanNeighbor(LineSide const &side, bool top, bool right, edge_t &edg // Now we've found the furthest coalignable neighbor, select the back neighbor if // present for "edge open-ness" comparison. - if(edge.sector) // The back sector of the coalignable neighbor. + if (edge.sector) // The back sector of the coalignable neighbor. { // Since we have the details of the backsector already, simply get the next // neighbor (it *is* the back neighbor). DENG2_ASSERT(edge.line); edge.line = R_FindLineNeighbor(*edge.line, - *edge.line->vertexOwner(dint(edge.line->hasBackSector() && edge.line->backSectorPtr() == edge.sector) ^ dint(right)), + *edge.line->vertexOwner(dint(edge.line->back().hasSector() && edge.line->back().sectorPtr() == edge.sector) ^ dint(right)), direction, edge.sector, &edge.diff); } } @@ -1066,19 +1090,19 @@ static void scanNeighbor(LineSide const &side, bool top, bool right, edge_t &edg void Line::Side::updateRadioForFrame(dint frameNumber) { // Disabled completely? - if(!::rendFakeRadio || ::levelFullBright) return; + if (!::rendFakeRadio || ::levelFullBright) return; // Updates are disabled? - if(!::devFakeRadioUpdate) return; + if (!::devFakeRadioUpdate) return; // Sides without sectors don't need updating. - if(!hasSector()) return; + if (!hasSector()) return; // Sides of self-referencing lines do not receive shadows. (Not worth it?). - if(line().isSelfReferencing()) return; + if (line().isSelfReferencing()) return; // Have already determined the shadow properties? - if(d->radioData.updateFrame == frameNumber) return; + if (d->radioData.updateFrame == frameNumber) return; d->radioData.updateFrame = frameNumber; // Mark as done. // Process the side corners first. @@ -1087,7 +1111,7 @@ void Line::Side::updateRadioForFrame(dint frameNumber) // Top and bottom corners are somewhat more complex as we must traverse neighbors // to find the extent of the coalignable surfaces for texture mapping/selection. - for(dint i = 0; i < 2; ++i) + for (dint i = 0; i < 2; ++i) { bool const rightEdge = i != 0; @@ -1131,7 +1155,7 @@ dint Line::Side::setProperty(DmuArgs const &args) switch(args.prop) { case DMU_SECTOR: { - if(P_IsDummy(&line())) + if (P_IsDummy(&line())) { args.value(DMT_SIDE_SECTOR, &d->sector, 0); } @@ -1160,11 +1184,11 @@ DENG2_PIMPL(Line) dint flags; ///< Public DDLF_* flags. Side front; ///< Front side of the line. Side back; ///< Back side of the line. - bool mapped[DDMAXPLAYERS]; ///< Whether the line has been seen by each player yet. + std::array mapped; ///< Whether the line has been seen by each player yet. Vertex *from = nullptr; ///< Start vertex (not owned). Vertex *to = nullptr; ///< End vertex (not owned). - Polyobj *polyobj = nullptr; ///< Polyobj the line defines a section of, if any. + Polyobj *polyobj = nullptr; ///< Polyobj the line defines a section of, if any (not owned). dint validCount = 0; ///< Used by legacy algorithms to prevent repeated processing. @@ -1183,7 +1207,7 @@ DENG2_PIMPL(Line) : direction(to.origin() - from.origin()) , length (direction.length()) , angle (bamsAtan2(dint(direction.y), dint(direction.x))) - , slopeType(M_SlopeTypeXY(direction.x, direction.y)) + , slopeType(M_SlopeType(direction.data().baseAs())) { V2d_InitBoxXY (aaBox.arvec2, from.x(), from.y()); V2d_AddToBoxXY(aaBox.arvec2, to .x(), to .y()); @@ -1195,9 +1219,7 @@ DENG2_PIMPL(Line) : Base (i) , front(*i, frontSector) , back (*i, backSector) - { - de::zap(mapped); - } + {} /** * Returns the additional geometry metrics (cached). @@ -1228,8 +1250,8 @@ Line::Line(Vertex &from, Vertex &to, dint flags, Sector *frontSector, Sector *ba , d(new Impl(this, frontSector, backSector)) { d->flags = flags; - replaceFrom(from); - replaceTo (to); + replaceVertex(From, from); + replaceVertex(To , to); } dint Line::flags() const @@ -1266,8 +1288,8 @@ bool Line::definesPolyobj() const Polyobj &Line::polyobj() const { if (d->polyobj) return *d->polyobj; - /// @throw Line::MissingPolyobjError Attempted with no polyobj attributed. - throw Line::MissingPolyobjError("Line::polyobj", "No polyobj is attributed"); + /// @throw MissingPolyobjError Attempted with no polyobj attributed. + throw MissingPolyobjError("Line::polyobj", "No polyobj is attributed"); } void Line::setPolyobj(Polyobj *newPolyobj) @@ -1289,6 +1311,11 @@ void Line::setPolyobj(Polyobj *newPolyobj) } } +bool Line::isSelfReferencing() const +{ + return front().hasSector() && front().sectorPtr() == back().sectorPtr(); +} + Line::Side &Line::side(dint back) { return (back ? d->back : d->front); @@ -1303,18 +1330,12 @@ LoopResult Line::forAllSides(std::function func) const { for (dint i = 0; i < 2; ++i) { - if (auto result = func(const_cast(this)->side(i))) + if (auto result = func(const_cast(side(i)))) return result; } return LoopContinue; } -Vertex &Line::vertex(dint to) const -{ - DENG2_ASSERT((to ? d->to : d->from) != nullptr); - return (to ? *d->to : *d->from); -} - void Line::replaceVertex(dint to, Vertex &newVertex) { Vertex **adr = (to ? &d->to : &d->from); @@ -1328,11 +1349,44 @@ void Line::replaceVertex(dint to, Vertex &newVertex) d->gdata.release(); } +Vertex &Line::vertex(dint to) +{ + DENG2_ASSERT((to ? d->to : d->from) != nullptr); + return (to ? *d->to : *d->from); +} + +Vertex const &Line::vertex(dint to) const +{ + DENG2_ASSERT((to ? d->to : d->from) != nullptr); + return (to ? *d->to : *d->from); +} + +Vertex &Line::from() +{ + return vertex(From); +} + +Vertex const &Line::from() const +{ + return vertex(From); +} + +Vertex &Line::to() +{ + return vertex(To); +} + +Vertex const &Line::to() const +{ + return vertex(To); +} + LoopResult Line::forAllVertexs(std::function func) const { for (dint i = 0; i < 2; ++i) { - if (auto result = func(vertex(i))) return result; + if (auto result = func(const_cast(this)->vertex(i))) + return result; } return LoopContinue; } @@ -1342,9 +1396,15 @@ AABoxd const &Line::aaBox() const return d->geom().aaBox; } -ddouble Line::length() const +binangle_t Line::angle() const { - return d->geom().length; + return d->geom().angle; +} + +Vector2d Line::center() const +{ + /// @todo Worth caching in Impl::GeomData? -dj + return from().origin() + direction() / 2; } Vector2d const &Line::direction() const @@ -1352,14 +1412,14 @@ Vector2d const &Line::direction() const return d->geom().direction; } -slopetype_t Line::slopeType() const +ddouble Line::length() const { - return d->geom().slopeType; + return d->geom().length; } -binangle_t Line::angle() const +slopetype_t Line::slopeType() const { - return d->geom().angle; + return d->geom().slopeType; } dint Line::boxOnSide(AABoxd const &box) const @@ -1426,7 +1486,7 @@ bool Line::isMappedByPlayer(dint playerNum) const return d->mapped[playerNum]; } -void Line::markMappedByPlayer(dint playerNum, bool yes) +void Line::setMappedByPlayer(dint playerNum, bool yes) { d->mapped[playerNum] = yes; } @@ -1441,13 +1501,33 @@ void Line::setValidCount(dint newValidCount) d->validCount = newValidCount; } +Line::Side &Line::front() +{ + return side(Front); +} + +Line::Side const &Line::front() const +{ + return side(Front); +} + +Line::Side &Line::back() +{ + return side(Back); +} + +Line::Side const &Line::back() const +{ + return side(Back); +} + #ifdef __CLIENT__ -bool Line::castsShadow() const +bool Line::isShadowCaster() const { if (definesPolyobj()) return false; if (isSelfReferencing()) return false; - // Lines with no other neighbor do not qualify for shadowing. + // Lines with no other neighbor do not qualify as shadow casters. if (&v1Owner()->next().line() == this || &v2Owner()->next().line() == this) return false; @@ -1470,12 +1550,12 @@ dint Line::property(DmuArgs &args) const break; case DMU_FRONT: { /// @todo Update the games so that sides without sections can be returned. - Line::Side const *frontAdr = hasFrontSections() ? &d->front : nullptr; + Line::Side const *frontAdr = front().hasSections() ? &d->front : nullptr; args.setValue(DDVT_PTR, &frontAdr, 0); break; } case DMU_BACK: { /// @todo Update the games so that sides without sections can be returned. - Line::Side const *backAdr = hasBackSections() ? &d->back : nullptr; + Line::Side const *backAdr = back().hasSections() ? &d->back : nullptr; args.setValue(DDVT_PTR, &backAdr, 0); break; } case DMU_VERTEX0: diff --git a/doomsday/apps/client/src/world/linesighttest.cpp b/doomsday/apps/client/src/world/linesighttest.cpp index dc9435a1b0..8b9555065b 100644 --- a/doomsday/apps/client/src/world/linesighttest.cpp +++ b/doomsday/apps/client/src/world/linesighttest.cpp @@ -104,8 +104,8 @@ DENG2_PIMPL_NOREF(LineSightTest) line.aaBox().maxY < ray.aabox.minY) return true; - fixed_t const lineV1OriginX[2] = { DBL2FIX(line.fromOrigin().x), DBL2FIX(line.fromOrigin().y) }; - fixed_t const lineV2OriginX[2] = { DBL2FIX(line.toOrigin ().x), DBL2FIX(line.toOrigin ().y) }; + fixed_t const lineV1OriginX[2] = { DBL2FIX(line.from().x()), DBL2FIX(line.from().y()) }; + fixed_t const lineV2OriginX[2] = { DBL2FIX(line.to ().x()), DBL2FIX(line.to ().y()) }; if(V2x_PointOnLineSide(lineV1OriginX, ray.origin, ray.direction) == V2x_PointOnLineSide(lineV2OriginX, ray.origin, ray.direction)) diff --git a/doomsday/apps/client/src/world/map.cpp b/doomsday/apps/client/src/world/map.cpp index 49e338c7cd..d39af0e16f 100644 --- a/doomsday/apps/client/src/world/map.cpp +++ b/doomsday/apps/client/src/world/map.cpp @@ -406,11 +406,16 @@ DENG2_PIMPL(Map) Vector2d testLineCenter; }; + static bool lineHasZeroLength(Line const &line) + { + return de::abs(line.length()) < 1.0 / 128.0; + } + static void testForWindowEffect2(Line &line, testForWindowEffectParams &p) { if(&line == p.testLine) return; if(line.isSelfReferencing()) return; - if(line.hasZeroLength()) return; + if(lineHasZeroLength(line)) return; ddouble dist = 0; Sector *hitSector = nullptr; @@ -424,8 +429,8 @@ DENG2_PIMPL(Map) (line.aaBox().minY > p.testLineCenter.y + bsp::DIST_EPSILON)) return; - dist = (line.fromOrigin().x + - (p.testLineCenter.y - line.fromOrigin().y) * line.direction().x / line.direction().y) + dist = (line.from().x() + + (p.testLineCenter.y - line.from().y()) * line.direction().x / line.direction().y) - p.testLineCenter.x; isFront = ((p.testLine->direction().y > 0) != (dist > 0)); @@ -447,8 +452,8 @@ DENG2_PIMPL(Map) (line.aaBox().minX > p.testLineCenter.x + bsp::DIST_EPSILON)) return; - dist = (line.fromOrigin().y + - (p.testLineCenter.x - line.fromOrigin().x) * line.direction().y / line.direction().x) + dist = (line.from().y() + + (p.testLineCenter.x - line.from().x()) * line.direction().y / line.direction().x) - p.testLineCenter.y; isFront = ((p.testLine->direction().x > 0) == (dist > 0)); @@ -485,9 +490,9 @@ DENG2_PIMPL(Map) bool lineMightHaveWindowEffect(Line const &line) { if(line.definesPolyobj()) return false; - if(line.hasFrontSector() && line.hasBackSector()) return false; - if(!line.hasFrontSector()) return false; - if(line.hasZeroLength()) return false; + if(line.front().hasSector() && line.back().hasSector()) return false; + if(!line.front().hasSector()) return false; + if(lineHasZeroLength(line)) return false; // Look for window effects by checking for an odd number of one-sided // line owners for a single vertex. Idea courtesy of Graham Jackson. @@ -542,7 +547,7 @@ DENG2_PIMPL(Map) return LoopContinue; }); - if(p.backOpen && p.frontOpen && line->frontSectorPtr() == p.backOpen) + if(p.backOpen && p.frontOpen && line->front().sectorPtr() == p.backOpen) { notifyOneWayWindowFound(*line, *p.frontOpen); @@ -874,8 +879,8 @@ DENG2_PIMPL(Map) // Lines with only one sector will not be linked to because a mobj can't // legally cross one. - if(!line->hasFrontSector()) return; - if(!line->hasBackSector()) return; + if(!line->front().hasSector()) return; + if(!line->back().hasSector()) return; // Add a node to the mobj's ring. nodeindex_t nodeIndex = NP_New(&mobjNodes, line); @@ -1951,7 +1956,7 @@ void Map::initRadio() /// of the subspace's edges (not parallel), link the line to the ConvexSubspace. for(Line *line : d->lines) { - if(!line->castsShadow()) continue; + if(!line->isShadowCaster()) continue; // For each side of the line. for(dint i = 0; i < 2; ++i) @@ -2513,7 +2518,7 @@ LoopResult Map::forAllSectorsTouchingMobj(mobj_t &mob, std::functionfrontSector(); + Sector &frontSec = ld->front().sector(); if(frontSec.validCount() != validCount) { frontSec.setValidCount(validCount); @@ -2522,9 +2527,9 @@ LoopResult Map::forAllSectorsTouchingMobj(mobj_t &mob, std::functionhasBackSector()) + if(ld->back().hasSector()) { - Sector &backSec = ld->backSector(); + Sector &backSec = ld->back().sector(); if(backSec.validCount() != validCount) { backSec.setValidCount(validCount); @@ -3821,7 +3826,7 @@ void pruneVertexes(Mesh &mesh, Map::Lines const &lines) VertexInfo &info = vertexInfo[line->from().indexInMap()]; info.refCount--; - line->replaceFrom(*info.equiv); + line->replaceVertex(Line::From, *info.equiv); vertexInfo[line->from().indexInMap()].refCount++; } @@ -3831,7 +3836,7 @@ void pruneVertexes(Mesh &mesh, Map::Lines const &lines) VertexInfo &info = vertexInfo[line->to().indexInMap()]; info.refCount--; - line->replaceTo(*info.equiv); + line->replaceVertex(Line::To, *info.equiv); vertexInfo[line->to().indexInMap()].refCount++; } @@ -3887,7 +3892,7 @@ bool Map::endEditing() // Ensure lines with only one sector are flagged as blocking. for(Line *line : d->editable.lines) { - if(!line->hasFrontSector() || !line->hasBackSector()) + if(!line->front().hasSector() || !line->back().hasSector()) line->setFlags(DDLF_BLOCKING); } diff --git a/doomsday/apps/client/src/world/maputil.cpp b/doomsday/apps/client/src/world/maputil.cpp index db4dc1ca4b..ae51f84266 100644 --- a/doomsday/apps/client/src/world/maputil.cpp +++ b/doomsday/apps/client/src/world/maputil.cpp @@ -39,7 +39,7 @@ using namespace de; lineopening_s::lineopening_s(Line const &line) { - if(!line.hasBackSector()) + if(!line.back().hasSector()) { top = bottom = range = lowFloor = 0; return; @@ -201,12 +201,12 @@ Line *R_FindLineNeighbor(Line const &line, LineOwner const &own, ClockDirection *diff += (direction == Anticlockwise ? cown->angle() : own.angle()); } - if(!other->hasBackSector() || !other->isSelfReferencing()) + if(!other->back().hasSector() || !other->isSelfReferencing()) { if(sector) // Must one of the sectors match? { - if(other->frontSectorPtr() == sector || - (other->hasBackSector() && other->backSectorPtr() == sector)) + if(other->front().sectorPtr() == sector || + (other->back().hasSector() && other->back().sectorPtr() == sector)) return other; } else @@ -276,32 +276,32 @@ Line *R_FindSolidLineNeighbor(Line const &line, LineOwner const &own, ClockDirec LineOwner const *cown = (direction == Anticlockwise ? &own.prev() : &own.next()); Line *other = &cown->line(); - if(other == &line) return nullptr; + if (other == &line) return nullptr; - if(diff) + if (diff) { *diff += (direction == Anticlockwise ? cown->angle() : own.angle()); } - if(!((other->isBspWindow()) && other->frontSectorPtr() != sector) - && !other->isSelfReferencing()) + if (!((other->isBspWindow()) && other->front().sectorPtr() != sector) + && !other->isSelfReferencing()) { - if(!other->hasFrontSector() || !other->hasBackSector()) + if (!other->front().hasSector() || !other->back().hasSector()) return other; - if( other->frontSector().floor ().heightSmoothed() >= sector->ceiling().heightSmoothed() - || other->frontSector().ceiling().heightSmoothed() <= sector->floor ().heightSmoothed() - || other->backSector ().floor ().heightSmoothed() >= sector->ceiling().heightSmoothed() - || other->backSector ().ceiling().heightSmoothed() <= sector->floor ().heightSmoothed() - || other->backSector ().ceiling().heightSmoothed() <= other->backSector().floor().heightSmoothed()) + if ( other->front().sector().floor ().heightSmoothed() >= sector->ceiling().heightSmoothed() + || other->front().sector().ceiling().heightSmoothed() <= sector->floor ().heightSmoothed() + || other->back().sector().floor ().heightSmoothed() >= sector->ceiling().heightSmoothed() + || other->back().sector().ceiling().heightSmoothed() <= sector->floor ().heightSmoothed() + || other->back().sector().ceiling().heightSmoothed() <= other->back().sector().floor().heightSmoothed()) return other; // Both front and back MUST be open by this point. // Perhaps a middle material completely covers the opening? // We should not give away the location of false walls (secrets). - LineSide &otherSide = other->side(other->frontSectorPtr() == sector ? Line::Front : Line::Back); - if(middleMaterialCoversOpening(otherSide)) + LineSide &otherSide = other->side(other->front().sectorPtr() == sector ? Line::Front : Line::Back); + if (middleMaterialCoversOpening(otherSide)) return other; } diff --git a/doomsday/apps/client/src/world/polyobj.cpp b/doomsday/apps/client/src/world/polyobj.cpp index d59a953d5a..1694dc9b22 100644 --- a/doomsday/apps/client/src/world/polyobj.cpp +++ b/doomsday/apps/client/src/world/polyobj.cpp @@ -205,21 +205,21 @@ void Polyobj::unlink() void Polyobj::link() { - if(!_bspLeaf) + if (!_bspLeaf) { map().link(*this); // Find the center point of the polyobj. Vector2d avg; - for(Line *line : lines()) + for (Line *line : lines()) { - avg += line->fromOrigin(); + avg += line->from().origin(); } avg /= lineCount(); // Given the center point determine in which BSP leaf the polyobj resides. _bspLeaf = &map().bspLeafAt(avg); - if(((BspLeaf *)_bspLeaf)->hasSubspace()) + if (((BspLeaf *)_bspLeaf)->hasSubspace()) { ((BspLeaf *)_bspLeaf)->subspace().link(*this); } diff --git a/doomsday/apps/client/src/world/reject.cpp b/doomsday/apps/client/src/world/reject.cpp index 5e26c75ad3..c2a98264f1 100644 --- a/doomsday/apps/client/src/world/reject.cpp +++ b/doomsday/apps/client/src/world/reject.cpp @@ -47,11 +47,11 @@ void BuildRejectForMap(Map const &map) { Line *line = &map.lines[i]; - if(!line->hasFrontSector() || !line->hasBackSector()) + if(!line->front().hasSector() || !line->back().hasSector()) continue; - Sector *sec1 = line->frontSectorPtr(); - Sector *sec2 = line->backSectorPtr(); + Sector *sec1 = line->front().sectorPtr(); + Sector *sec2 = line->back().sectorPtr(); if(!sec1 || !sec2 || sec1 == sec2) continue; diff --git a/doomsday/apps/client/src/world/sector.cpp b/doomsday/apps/client/src/world/sector.cpp index 40f7259858..f16afbc53b 100644 --- a/doomsday/apps/client/src/world/sector.cpp +++ b/doomsday/apps/client/src/world/sector.cpp @@ -367,7 +367,7 @@ void Sector::buildSides() dint count = 0; map().forAllLines([this, &count] (Line &line) { - if(line.frontSectorPtr() == this || line.backSectorPtr() == this) + if(line.front().sectorPtr() == this || line.back().sectorPtr() == this) { ++count; } @@ -381,12 +381,12 @@ void Sector::buildSides() map().forAllLines([this] (Line &line) { - if(line.frontSectorPtr() == this) + if(line.front().sectorPtr() == this) { // Ownership of the side is not given to the sector. d->sides.append(&line.front()); } - else if(line.backSectorPtr() == this) + else if(line.back().sectorPtr() == this) { // Ownership of the side is not given to the sector. d->sides.append(&line.back()); diff --git a/doomsday/apps/client/src/world/vertex.cpp b/doomsday/apps/client/src/world/vertex.cpp index 87f4873259..cb9201c874 100644 --- a/doomsday/apps/client/src/world/vertex.cpp +++ b/doomsday/apps/client/src/world/vertex.cpp @@ -91,7 +91,7 @@ void Vertex::countLineOwners() LineOwner const *own = firstOwn; do { - if(!own->line().hasFrontSector() || !own->line().hasBackSector()) + if(!own->line().front().hasSector() || !own->line().back().hasSector()) { _onesOwnerCount += 1; } diff --git a/doomsday/apps/server/src/server/sv_pool.cpp b/doomsday/apps/server/src/server/sv_pool.cpp index c8f7b12b24..5db8fd6b90 100644 --- a/doomsday/apps/server/src/server/sv_pool.cpp +++ b/doomsday/apps/server/src/server/sv_pool.cpp @@ -1579,15 +1579,15 @@ coord_t Sv_DeltaDistance(void const *deltaPtr, ownerinfo_t const *info) { LineSide *side = worldSys().map().sidePtr(delta->id); Line &line = side->line(); - return M_ApproxDistance(info->origin[VX] - line.center().x, - info->origin[VY] - line.center().y); + return M_ApproxDistance(info->origin[0] - line.center().x, + info->origin[1] - line.center().y); } if (delta->type == DT_POLY) { Polyobj const &pob = worldSys().map().polyobj(delta->id); - return M_ApproxDistance(info->origin[VX] - pob.origin[VX], - info->origin[VY] - pob.origin[VY]); + return M_ApproxDistance(info->origin[0] - pob.origin[0], + info->origin[1] - pob.origin[1]); } if (delta->type == DT_MOBJ_SOUND) diff --git a/doomsday/apps/server/src/shelluser.cpp b/doomsday/apps/server/src/shelluser.cpp index eed513e6f0..c17b0bc4c8 100644 --- a/doomsday/apps/server/src/shelluser.cpp +++ b/doomsday/apps/server/src/shelluser.cpp @@ -140,11 +140,11 @@ void ShellUser::sendMapOutline() std::unique_ptr packet(new shell::MapOutlinePacket); - App_World().map().forAllLines([&packet] (Line &line) + App_World().map().forAllLines ([&packet] (Line &line) { - packet->addLine(Vector2i(line.fromOrigin().x, line.fromOrigin().y), - Vector2i(line.toOrigin().x, line.toOrigin().y), - (line.hasFrontSector() && line.hasBackSector())? + packet->addLine(line.from().origin().toVector2i(), + line.to ().origin().toVector2i(), + (line.front().hasSector() && line.back().hasSector()) ? shell::MapOutlinePacket::TwoSidedLine : shell::MapOutlinePacket::OneSidedLine); return LoopContinue; });