Skip to content

Commit

Permalink
Refactor|Renderer|Client: Moved FakeRadio neighbor scanning into Line…
Browse files Browse the repository at this point in the history
…::Side
  • Loading branch information
danij-deng committed Jul 2, 2015
1 parent 1141190 commit 58377fc
Show file tree
Hide file tree
Showing 5 changed files with 338 additions and 364 deletions.
16 changes: 6 additions & 10 deletions doomsday/apps/client/include/render/rend_fakeradio.h
@@ -1,4 +1,4 @@
/** @file rend_fakeradio.h Faked Radiosity Lighting.
/** @file rend_fakeradio.h Geometry generation for faked, radiosity lighting.
*
* Perhaps the most distinctive characteristic of radiosity lighting is that
* the corners of a room are slightly dimmer than the rest of the surfaces.
Expand Down Expand Up @@ -34,7 +34,6 @@
#ifndef CLIENT_RENDER_FAKERADIO
#define CLIENT_RENDER_FAKERADIO

#include "Line"
#include "WallEdge"

class ConvexSubspace;
Expand Down Expand Up @@ -62,30 +61,27 @@ struct edgespan_t
de::dfloat shift;
};

/**
* To be called to update the shadow properties for the specified line @a side.
*/
void Rend_RadioUpdateForLineSide(LineSide &side);
DENG2_EXTERN_C de::dint rendFakeRadio;
DENG2_EXTERN_C byte devFakeRadioUpdate;

/**
* Render FakeRadio for the specified wall section. Generates and then draws all shadow geometry
* for the wall section.
*
* Note that unlike Rend_RadioBspLeafEdges() there is no guard to ensure shadow geometry is rendered
* Note that unlike Rend_DrawFlatRadio() there is no guard to ensure shadow geometry is rendered
* only once per frame.
*
* @param leftEdge Geometry for the left edge of the wall section.
* @param rightEdge Geometry for the right edge of the wall section.
* @param ambientLight Ambient light level/luminosity.
*/
void Rend_RadioWallSection(de::WallEdge const &leftEdge, de::WallEdge const &rightEdge,
de::dfloat ambientLight);
void Rend_DrawWallRadio(de::WallEdge const &leftEdge, de::WallEdge const &rightEdge, de::dfloat ambientLight);

/**
* Render FakeRadio for the given subspace. Draws all shadow geometry linked to the ConvexSubspace,
* that has not already been rendered.
*/
void Rend_RadioSubspaceEdges(ConvexSubspace const &subspace);
void Rend_DrawFlatRadio(ConvexSubspace const &subspace);

/**
* Register the console commands, variables, etc..., of this module.
Expand Down
86 changes: 38 additions & 48 deletions doomsday/apps/client/include/world/line.h
Expand Up @@ -78,7 +78,7 @@ class Line : public de::MapElement
DENG2_ERROR(InvalidSectionIdError);

/// Notified whenever the flags change.
DENG2_DEFINE_AUDIENCE(FlagsChange, void lineFlagsChanged(Line &line, int oldFlags))
DENG2_DEFINE_AUDIENCE(FlagsChange, void lineFlagsChanged(Line &line, de::dint oldFlags))

// Logical edge identifiers:
enum { From, To };
Expand Down Expand Up @@ -195,10 +195,11 @@ class Line : public de::MapElement
* Construct a new line side.
*
* @param line Line parent which will own the side.
* @param sector Sector on "this" side of the line. Can be @c 0. Note
* once attributed the sector cannot normally be changed.
* @param sector Sector on "this" side of the line. Can be @c nullptr.
* Note that once attributed, the sector cannot normally
* be changed.
*/
Side(Line &line, Sector *sector = 0);
Side(Line &line, Sector *sector = nullptr);

/**
* Returns the Line owner of the side.
Expand All @@ -209,7 +210,7 @@ class Line : public de::MapElement
/**
* Returns the logical identifier for the side (Front or Back).
*/
int sideId() const;
de::dint sideId() const;

/**
* Returns @c true iff this is the front side of the owning line.
Expand All @@ -230,9 +231,7 @@ class Line : public de::MapElement
*
* @see lineSideId(), line(), Line::side(),
*/
inline Side &back() { return line().side(sideId() ^ 1); }

/// @copydoc back()
inline Side &back() { return line().side(sideId() ^ 1); }
inline Side const &back() const { return line().side(sideId() ^ 1); }

/**
Expand All @@ -249,7 +248,7 @@ class Line : public de::MapElement
*
* @see lineSideId(), line(), Line::vertex(),
*/
inline Vertex &vertex(int to) const { return line().vertex(sideId() ^ to); }
inline Vertex &vertex(de::dint to) const { return line().vertex(sideId() ^ to); }

/**
* Returns the relative From Vertex for the side, from the Line owner.
Expand Down Expand Up @@ -284,8 +283,8 @@ class Line : public de::MapElement
*
* @param sectionId Identifier of the surface to return.
*/
Surface &surface(int sectionId);
Surface const &surface(int sectionId) const;
Surface &surface(de::dint sectionId);
Surface const &surface(de::dint sectionId) const;

/**
* Returns the middle surface of the side.
Expand Down Expand Up @@ -350,7 +349,7 @@ class Line : public de::MapElement
* point is determined according to the center point of the owning line and
* the current @em sharp heights of the sector on "this" side of the line.
*/
void updateSoundEmitterOrigin(int sectionId);
void updateSoundEmitterOrigin(de::dint sectionId);

/**
* Update the @em middle sound emitter origin for the side.
Expand Down Expand Up @@ -391,11 +390,11 @@ class Line : public de::MapElement
Sector &sector() const;

/**
* Returns a pointer to the Sector attributed to the side; otherwise @c 0.
* Returns a pointer to the Sector attributed to the side; otherwise @c nullptr.
*
* @see hasSector()
*/
inline Sector *sectorPtr() const { return hasSector()? &sector() : 0; }
inline Sector *sectorPtr() const { return hasSector()? &sector() : nullptr; }

/**
* Clears (destroys) all segments for the side.
Expand All @@ -421,13 +420,13 @@ class Line : public de::MapElement

/**
* Convenient method of returning the half-edge of the left-most segment
* on this side of the line; otherwise @c 0 (no segments exist).
* on this side of the line; otherwise @c nullptr (no segments exist).
*/
de::HEdge *leftHEdge() const;

/**
* Convenient method of returning the half-edge of the right-most segment
* on this side of the line; otherwise @c 0 (no segments exist).
* on this side of the line; otherwise @c nullptr (no segments exist).
*/
de::HEdge *rightHEdge() const;

Expand All @@ -441,35 +440,35 @@ class Line : public de::MapElement
/**
* Returns the @ref sdefFlags for the side.
*/
int flags() const;
de::dint flags() const;

/**
* Change the side's flags.
*
* @param flagsToChange Flags to change the value of.
* @param operation Logical operation to perform on the flags.
*/
void setFlags(int flagsToChange, de::FlagOp operation = de::SetFlags);
void setFlags(de::dint flagsToChange, de::FlagOp operation = de::SetFlags);

/**
* Returns @c true iff the side is flagged @a flagsToTest.
*/
inline bool isFlagged(int flagsToTest) const { return (flags() & flagsToTest) != 0; }
inline bool isFlagged(de::dint flagsToTest) const { return (flags() & flagsToTest) != 0; }

void chooseSurfaceTintColors(int sectionId, de::Vector3f const **topColor,
void chooseSurfaceTintColors(de::dint sectionId, de::Vector3f const **topColor,
de::Vector3f const **bottomColor) const;

/**
* Returns the frame number of the last time shadows were drawn for the side.
*/
int shadowVisCount() const;
de::dint shadowVisCount() const;

/**
* Change the frame number of the last time shadows were drawn for the side.
*
* @param newCount New shadow vis count.
*/
void setShadowVisCount(int newCount);
void setShadowVisCount(de::dint newCount);

#ifdef __CLIENT__

Expand All @@ -479,39 +478,30 @@ class Line : public de::MapElement
*/
void fixMissingMaterials();

/**
* To be called to update the shadow properties for the line side.
*
* @todo Handle this internally -ds.
*/
void updateRadioForFrame(de::dint frameNumber);

/**
* Provides access to the FakeRadio shadowcorner_t data.
*/
shadowcorner_t const &radioCornerTop (bool right) const;
shadowcorner_t const &radioCornerBottom(bool right) const;
shadowcorner_t const &radioCornerSide (bool right) const;

/**
* Change the FakeRadio side corner properties.
*/
void setRadioCornerTop (bool right, dfloat openness, Plane *proximityPlane = nullptr);
void setRadioCornerBottom(bool right, dfloat openness, Plane *proximityPlane = nullptr);
void setRadioCornerSide (bool right, dfloat openness);

/**
* Provides access to the FakeRadio edgespan_t data.
*/
edgespan_t const &radioEdgeSpan(bool top) const;

/**
* Change the FakeRadio "edge span" metrics.
* @todo replace shadow edge enumeration with a shadow corner enumeration.
*/
void setRadioEdgeSpan(bool top, bool right, de::ddouble length);

de::dint radioUpdateFrame() const;
void setRadioUpdateFrame(de::dint newFrame);

#endif // __CLIENT__

protected:
int property(DmuArgs &args) const;
int setProperty(DmuArgs const &args);
de::dint property(DmuArgs &args) const;
de::dint setProperty(DmuArgs const &args);

private:
DENG2_PRIVATE(d)
Expand All @@ -528,7 +518,7 @@ class Line : public de::MapElement

public:
Line(Vertex &from, Vertex &to,
int flags = 0,
de::dint flags = 0,
Sector *frontSector = nullptr,
Sector *backSector = nullptr);

Expand All @@ -537,8 +527,8 @@ class Line : public de::MapElement
*
* @param back If not @c 0 return the Back side; otherwise the Front side.
*/
Side &side(int back);
Side const &side(int back) const;
Side &side(de::dint back);
Side const &side(de::dint back) const;

/**
* Returns the logical Front side of the line.
Expand All @@ -558,7 +548,7 @@ class Line : public de::MapElement
*
* @param back If not @c 0 test the Back side; otherwise the Front side.
*/
inline bool hasSections(int back) const { return side(back).hasSections(); }
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.
Expand All @@ -575,7 +565,7 @@ class Line : public de::MapElement
*
* @param back If not @c 0 test the Back side; otherwise the Front side.
*/
inline bool hasSector(int back) const { return side(back).hasSector(); }
inline bool hasSector(de::dint back) const { return side(back).hasSector(); }

/**
* Returns @c true iff a sector is attributed to the Front side of the line.
Expand All @@ -594,7 +584,7 @@ class Line : public de::MapElement
* @param back If not @c 0 return the sector for the Back side; otherwise
* the sector of the Front side.
*/
inline Sector &sector(int back) const { return side(back).sector(); }
inline Sector &sector(de::dint back) const { return side(back).sector(); }

/**
* Convenient accessor method for returning a pointer to the sector attributed
Expand All @@ -603,7 +593,7 @@ class Line : public de::MapElement
* @param back If not @c 0 return the sector for the Back side; otherwise
* the sector of the Front side.
*/
inline Sector *sectorPtr(int back) const { return side(back).sectorPtr(); }
inline Sector *sectorPtr(de::dint back) const { return side(back).sectorPtr(); }

/**
* Returns the sector attributed to the Front side of the line.
Expand Down Expand Up @@ -924,4 +914,4 @@ typedef Line::Side::Segment LineSideSegment;

Q_DECLARE_OPERATORS_FOR_FLAGS(Line::Side::SectionFlags)

#endif // DENG_WORLD_LINE_H
#endif // WORLD_LINE_H

0 comments on commit 58377fc

Please sign in to comment.