Skip to content

Commit

Permalink
Surface|Refactor: Removed the unnecessary isFromPolyobj() helper func
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed Apr 12, 2013
1 parent 567ded6 commit 1ec6495
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 34 deletions.
6 changes: 0 additions & 6 deletions doomsday/client/include/map/surface.h
Expand Up @@ -479,12 +479,6 @@ class Surface : public de::MapElement
*/
int setProperty(setargs_t const &args);

/**
* Helper function for determining whether the surface is owned by a
* Line which is itself owned by a Polyobj.
*/
static bool isFromPolyobj(Surface const &surface);

private:
DENG2_PRIVATE(d)
};
Expand Down
2 changes: 1 addition & 1 deletion doomsday/client/src/map/linedef.cpp
Expand Up @@ -104,7 +104,7 @@ void LineDef::Side::updateSurfaceNormals()
if(!_sideDef) return;

LineDef const &line = _sideDef->line();
byte sid = line.frontSideDefPtr() == _sideDef? FRONT : BACK;
byte sid = &line.front() == this? FRONT : BACK;

Surface &middleSurface = _sideDef->middle();
Surface &bottomSurface = _sideDef->bottom();
Expand Down
26 changes: 11 additions & 15 deletions doomsday/client/src/map/r_world.cpp
Expand Up @@ -547,11 +547,9 @@ static void resetAllMapSurfaceVisMaterialOrigins(GameMap &map)
* Non-animated materials are preferred.
* Sky materials are ignored.
*/
static Material *chooseFixMaterial(SideDef *s, SideDefSection section)
static Material *chooseFixMaterial(LineDef &line, int side, SideDefSection section)
{
Material *choice1 = 0, *choice2 = 0;
LineDef &line = s->line();
byte side = (line.frontSideDefPtr() == s? FRONT : BACK);
Sector *frontSec = line.sectorPtr(side);
Sector *backSec = line.sideDefPtr(side ^ 1)? line.sectorPtr(side ^ 1) : 0;

Expand Down Expand Up @@ -640,25 +638,23 @@ static Material *chooseFixMaterial(SideDef *s, SideDefSection section)
return &App_Materials().find(de::Uri("System", Path("missing"))).material();
}

static void addMissingMaterial(SideDef *s, SideDefSection section)
static void addMissingMaterial(LineDef &line, int side, SideDefSection section)
{
DENG_ASSERT(s);

// A material must be missing for this test to apply.
Surface &surface = s->surface(section);
Surface &surface = line.sideDef(side).surface(section);
if(surface.hasMaterial()) return;

// Look for a suitable replacement.
surface.setMaterial(chooseFixMaterial(s, section), true/* is missing fix */);
surface.setMaterial(chooseFixMaterial(line, side, section), true/* is missing fix */);

// During map load we log missing materials.
if(ddMapSetup && verbose)
{
String path = surface.hasMaterial()? surface.material().manifest().composeUri().asText() : "<null>";

LOG_WARNING("SideDef #%u is missing a material for the %s section.\n"
LOG_WARNING("%s of LineDef #%u is missing a material for the %s section.\n"
" %s was chosen to complete the definition.")
<< s->_buildData.index - 1
<< (side? "Back" : "Front") << line.origIndex() - 1
<< (section == SS_MIDDLE? "middle" : section == SS_TOP? "top" : "bottom")
<< path;
}
Expand Down Expand Up @@ -688,27 +684,27 @@ void R_UpdateMissingMaterialsForLinesOfSector(Sector const &sec)
// A potential bottom section fix?
if(frontSec.floor().height() < backSec.floor().height())
{
addMissingMaterial(line->frontSideDefPtr(), SS_BOTTOM);
addMissingMaterial(*line, FRONT, SS_BOTTOM);
}
else if(frontSec.floor().height() > backSec.floor().height())
{
addMissingMaterial(line->backSideDefPtr(), SS_BOTTOM);
addMissingMaterial(*line, BACK, SS_BOTTOM);
}

// A potential top section fix?
if(backSec.ceiling().height() < frontSec.ceiling().height())
{
addMissingMaterial(line->frontSideDefPtr(), SS_TOP);
addMissingMaterial(*line, FRONT, SS_TOP);
}
else if(backSec.ceiling().height() > frontSec.ceiling().height())
{
addMissingMaterial(line->backSideDefPtr(), SS_TOP);
addMissingMaterial(*line, BACK, SS_TOP);
}
}
else
{
// A potential middle section fix.
addMissingMaterial(line->frontSideDefPtr(), SS_MIDDLE);
addMissingMaterial(*line, FRONT, SS_MIDDLE);
}
}
}
Expand Down
10 changes: 0 additions & 10 deletions doomsday/client/src/map/surface.cpp
Expand Up @@ -843,13 +843,3 @@ int Surface::setProperty(setargs_t const &args)

return false; // Continue iteration.
}

bool Surface::isFromPolyobj(Surface const &surface)
{
if(surface.owner().type() == DMU_SIDEDEF)
{
SideDef *sideDef = surface.owner().castTo<SideDef>();
if(sideDef->line().isFromPolyobj()) return true;
}
return false;
}
2 changes: 1 addition & 1 deletion doomsday/client/src/render/rend_fakeradio.cpp
Expand Up @@ -1310,7 +1310,7 @@ static void processEdgeShadow(BspLeaf const &bspLeaf, LineDef const *line,
coord_t plnHeight = plane.visHeight();

// Polyobj surfaces never shadow.
if(Surface::isFromPolyobj(*suf)) return;
if(line->isFromPolyobj()) return;

// Surfaces with a missing material don't shadow.
if(!suf->hasMaterial()) return;
Expand Down
3 changes: 2 additions & 1 deletion doomsday/client/src/render/rend_main.cpp
Expand Up @@ -1809,7 +1809,8 @@ static boolean rendHEdgeSection(HEdge *hedge, SideDefSection section,
blendMode = surface->blendMode();
}

if(Surface::isFromPolyobj(*surface))
// Polyobj surfaces never shadow.
if(hedge->line().isFromPolyobj())
flags &= ~RHF_ADD_RADIO;

float glowStrength = 0;
Expand Down

0 comments on commit 1ec6495

Please sign in to comment.