Skip to content

Commit

Permalink
Refactor|Renderer|Line|Plane: Moved FakeRadio shadow caster checking …
Browse files Browse the repository at this point in the history
…into Line/Plane, cleanup
  • Loading branch information
danij-deng committed Jun 1, 2015
1 parent f95d794 commit 5842a29
Show file tree
Hide file tree
Showing 10 changed files with 136 additions and 139 deletions.
10 changes: 0 additions & 10 deletions doomsday/apps/client/include/render/rend_fakeradio.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,6 @@ void Rend_RadioRegister();
*/
void Rend_RadioInitForMap(de::Map &map);

/**
* Returns @c true iff @a line qualifies for (edge) shadow casting.
*/
bool Rend_RadioLineCastsShadow(Line const &line);

/**
* Returns @c true iff @a plane qualifies for (wall) shadow casting.
*/
bool Rend_RadioPlaneCastsShadow(Plane const &plane);

/**
* Returns the FakeRadio data for the specified line @a side.
*/
Expand Down
7 changes: 7 additions & 0 deletions doomsday/apps/client/include/world/line.h
Original file line number Diff line number Diff line change
Expand Up @@ -835,6 +835,13 @@ class Line : public de::MapElement
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:
int property(DmuArgs &args) const;
int setProperty(DmuArgs const &args);
Expand Down
5 changes: 5 additions & 0 deletions doomsday/apps/client/include/world/plane.h
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,11 @@ class Plane : public de::MapElement
void addMover(ClPlaneMover &mover);
void removeMover(ClPlaneMover &mover);

/**
* Returns @c true if the plane qualifies for FakeRadio shadow casting (on walls).
*/
bool castsShadow() const;

#endif // __CLIENT__

protected:
Expand Down
2 changes: 1 addition & 1 deletion doomsday/apps/client/include/world/vertex.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class Vertex : public de::MapElement, public de::MeshElement
*/
inline void setOrigin(float x, float y) { return setOrigin(de::Vector2d(x, y)); }

#if __CLIENT__
#ifdef __CLIENT__
/**
* Update all FakeRadio shadow offset coordinates for the vertex.
*
Expand Down
31 changes: 1 addition & 30 deletions doomsday/apps/client/src/render/r_fakeradio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,35 +46,6 @@ LineSideRadioData &Rend_RadioDataForLineSide(LineSide &side)
return lineSideRadioData[side.line().indexInMap() * 2 + (side.isBack()? 1 : 0)];
}

bool Rend_RadioLineCastsShadow(Line const &line)
{
if(line.definesPolyobj()) return false;
if(line.isSelfReferencing()) return false;

// Lines with no other neighbor do not qualify for shadowing.
if(&line.v1Owner()->next().line() == &line || &line.v2Owner()->next().line() == &line)
return false;

return true;
}

bool Rend_RadioPlaneCastsShadow(Plane const &plane)
{
if(plane.surface().hasMaterial())
{
MaterialAnimator &matAnimator = plane.surface().material().getAnimator(Rend_MapSurfaceMaterialSpec());

// Ensure we have up to date info about the material.
matAnimator.prepare();

if(!matAnimator.material().isDrawable()) return false;
if(matAnimator.material().isSkyMasked()) return false;

if(matAnimator.glowStrength() > 0) return false;
}
return true;
}

void Rend_RadioInitForMap(Map &map)
{
Time begunAt;
Expand All @@ -99,7 +70,7 @@ void Rend_RadioInitForMap(Map &map)
/// of the subspace's edges (not parallel), link the line to the ConvexSubspace.
map.forAllLines([] (Line &line)
{
if(Rend_RadioLineCastsShadow(line))
if(line.castsShadow())
{
// For each side of the line.
for(dint i = 0; i < 2; ++i)
Expand Down
4 changes: 2 additions & 2 deletions doomsday/apps/client/src/render/rend_fakeradio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1105,8 +1105,8 @@ void Rend_RadioWallSection(WallEdge const &leftEdge, WallEdge const &rightEdge,
backCluster = hedge->twin().face().mapElementAs<ConvexSubspace>().clusterPtr();
}

bool const haveBottomShadower = Rend_RadioPlaneCastsShadow(cluster->visFloor());
bool const haveTopShadower = Rend_RadioPlaneCastsShadow(cluster->visCeiling());
bool const haveBottomShadower = cluster->visFloor().castsShadow();
bool const haveTopShadower = cluster->visCeiling().castsShadow();

// Walls unaffected by floor and ceiling shadow casters receive no
// side shadows either. We could do better here...
Expand Down
3 changes: 1 addition & 2 deletions doomsday/apps/client/src/render/rend_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1324,9 +1324,8 @@ static bool renderWorldPoly(Vector3f const *rvertices, duint numVertices,

if(mod.texture)
{
// Prepare modulation texture coordinates.
modTexCoords = R_AllocRendTexCoords(numVerts);

// Modulation texture coordinates.
if(p.isWall)
{
modTexCoords[0] = Vector2f(mod.topLeft.x, mod.bottomRight.y);
Expand Down
Loading

0 comments on commit 5842a29

Please sign in to comment.