Skip to content

Commit

Permalink
Refactor|FakeRadio: Use a side relative algorithm for generating plan…
Browse files Browse the repository at this point in the history
…e edge shadow geometry
  • Loading branch information
danij-deng committed May 7, 2013
1 parent 6f2a85d commit d7f8ae8
Show file tree
Hide file tree
Showing 4 changed files with 177 additions and 179 deletions.
17 changes: 2 additions & 15 deletions doomsday/client/include/render/rend_fakeradio.h
Expand Up @@ -44,26 +44,13 @@
class SectionEdge;

/**
* Used to link a line to a BSP leaf for the purposes of FakeRadio shadowing.
* Used to link a line side to a BSP leaf for the purposes of FakeRadio shadowing.
* @ingroup render
*/
struct ShadowLink
{
ShadowLink *next;
Line *line;
byte side;

Line::Side &lineSide()
{
DENG_ASSERT(line);
return line->side(side);
}

Line::Side const &lineSide() const
{
DENG_ASSERT(line);
return line->side(side);
}
Line::Side *side;
};

/**
Expand Down
10 changes: 7 additions & 3 deletions doomsday/client/src/edit_map.cpp
Expand Up @@ -1071,7 +1071,7 @@ void MPE_LineAddSide(int lineIdx, int sideId, short flags, ddstring_t const *top

#undef MPE_PlaneCreate
int MPE_PlaneCreate(int sectorIdx, coord_t height, ddstring_t const *materialUri,
float matOffsetX, float matOffsetY, float r, float g, float b, float a,
float matOffsetX, float matOffsetY, float tintRed, float tintGreen, float tintBlue, float opacity,
float normalX, float normalY, float normalZ, int archiveIndex)
{
if(!editMapInited) return -1;
Expand All @@ -1084,10 +1084,14 @@ int MPE_PlaneCreate(int sectorIdx, coord_t height, ddstring_t const *materialUri
plane->setIndexInArchive(archiveIndex);

plane->surface().setMaterial(findMaterialInDict(materialUri));
plane->surface().setTintColor(r, g, b);
plane->surface().setOpacity(a);
plane->surface().setTintColor(tintRed, tintGreen, tintBlue);
plane->surface().setMaterialOrigin(matOffsetX, matOffsetY);

if(!plane->isSectorFloor() && !plane->isSectorCeiling())
{
plane->surface().setOpacity(opacity);
}

return plane->inSectorIndex();
}

Expand Down
30 changes: 8 additions & 22 deletions doomsday/client/src/render/r_fakeradio.cpp
Expand Up @@ -194,39 +194,29 @@ void Rend_RadioUpdateVertexShadowOffsets(Vertex &vtx)
/**
* Link @a line to @a bspLeaf for the purposes of shadowing.
*/
static void linkShadowLineToSSec(Line *line, byte side, BspLeaf *bspLeaf)
static void linkShadowLineToSSec(Line::Side &side, BspLeaf &bspLeaf)
{
DENG_ASSERT(line && bspLeaf);

#ifdef DENG_DEBUG
// Check the links for dupes!
for(ShadowLink *i = bspLeaf->firstShadowLink(); i; i = i->next)
for(ShadowLink *i = bspLeaf.firstShadowLink(); i; i = i->next)
{
if(i->line == line && i->side == side)
if(i->side == &side)
throw Error("R_LinkShadow", "Already here!!");
}
#endif

// We'll need to allocate a new link.
ShadowLink *link = (ShadowLink *) ZBlockSet_Allocate(shadowLinksBlockSet);

link->line = line;
link->side = side;
link->side = &side;
// The links are stored into a linked list.
link->next = bspLeaf->_shadows;
bspLeaf->_shadows = link;
link->next = bspLeaf._shadows;
bspLeaf._shadows = link;
}

struct ShadowLinkerParms
{
Line *line;
byte side;
};

static int RIT_ShadowBspLeafLinker(BspLeaf *bspLeaf, void *context)
{
ShadowLinkerParms *parms = static_cast<ShadowLinkerParms *>(context);
linkShadowLineToSSec(parms->line, parms->side, bspLeaf);
linkShadowLineToSSec(*static_cast<Line::Side *>(context), *bspLeaf);
return false; // Continue iteration.
}

Expand Down Expand Up @@ -257,7 +247,6 @@ void Rend_RadioInitForMap()
*/
shadowLinksBlockSet = ZBlockSet_New(sizeof(ShadowLink), 1024, PU_MAP);

ShadowLinkerParms parms;
AABoxd bounds;

foreach(Line *line, theMap->lines())
Expand Down Expand Up @@ -285,13 +274,10 @@ void Rend_RadioInitForMap()
point = vtx1.origin() + vo1.extendedShadowOffset();
V2d_AddToBoxXY(bounds.arvec2, point.x, point.y);

parms.line = line;
parms.side = i;

// Link the shadowing line to all the BspLeafs whose axis-aligned
// bounding box intersects 'bounds'.
theMap->bspLeafsBoxIterator(bounds, side.sectorPtr(),
RIT_ShadowBspLeafLinker, &parms);
RIT_ShadowBspLeafLinker, &side);
}
}

Expand Down

0 comments on commit d7f8ae8

Please sign in to comment.