Skip to content

Commit

Permalink
Refactor|World: Simplified Segment (no need for a private => public i…
Browse files Browse the repository at this point in the history
…nst reference)
  • Loading branch information
danij-deng committed Aug 11, 2013
1 parent a97b04c commit 02c443a
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions doomsday/client/src/world/segment.cpp
Expand Up @@ -48,7 +48,7 @@ struct GeometryGroup
typedef QMap<int, GeometryGroup> GeometryGroups;
#endif

DENG2_PIMPL(Segment)
DENG2_PIMPL_NOREF(Segment)
{
/// Half-edge attributed to the line segment (not owned).
HEdge *hedge;
Expand All @@ -65,9 +65,8 @@ DENG2_PIMPL(Segment)
Flags flags;
#endif

Instance(Public *i, HEdge *hedge)
: Base(i),
hedge(hedge)
Instance(HEdge *hedge)
: hedge(hedge)
#ifdef __CLIENT__
,lineSideOffset(0),
length(0),
Expand Down Expand Up @@ -112,25 +111,26 @@ DENG2_PIMPL(Segment)
* @todo This could be enhanced so that only the lights on the right
* side of the surface are taken into consideration.
*/
void updateBiasContributors(GeometryGroup &geomGroup, int sectionIndex)
void updateBiasContributors(Line::Side const &lineSide,
GeometryGroup &geomGroup, int sectionIndex)
{
DENG_UNUSED(sectionIndex);

// If the data is already up to date, nothing needs to be done.
uint lastChangeFrame = self.map().biasLastChangeOnFrame();
uint lastChangeFrame = lineSide.map().biasLastChangeOnFrame();
if(geomGroup.biasLastUpdateFrame == lastChangeFrame)
return;

geomGroup.biasLastUpdateFrame = lastChangeFrame;

geomGroup.biasTracker.clearContributors();

Surface const &surface = self.lineSide().middle();
Surface const &surface = lineSide.middle();
Vector2d const &from = hedge->origin();
Vector2d const &to = hedge->twin().origin();
Vector2d const center = (from + to) / 2;

foreach(BiasSource *source, self.map().biasSources())
foreach(BiasSource *source, lineSide.map().biasSources())
{
// If the source is too weak we will ignore it completely.
if(source->intensity() <= 0)
Expand Down Expand Up @@ -158,7 +158,7 @@ DENG2_PIMPL(Segment)

Segment::Segment(Line::Side &lineSide, HEdge &hedge)
: MapElement(DMU_SEGMENT, &lineSide),
d(new Instance(this, &hedge))
d(new Instance(&hedge))
{}

/*
Expand Down Expand Up @@ -236,16 +236,17 @@ void Segment::lightBiasPoly(int group, Vector3f const *posCoords, Vector4f *colo
{
DENG_ASSERT(posCoords != 0 && colorCoords != 0);

Line::Side const &side = lineSide();
int const sectionIndex = group;
GeometryGroup *geomGroup = d->geometryGroup(sectionIndex);

// Should we update?
if(devUpdateBiasContributors)
{
d->updateBiasContributors(*geomGroup, sectionIndex);
d->updateBiasContributors(side, *geomGroup, sectionIndex);
}

Surface const &surface = lineSide().surface(sectionIndex);
Surface const &surface = side.surface(sectionIndex);
uint const biasTime = map().biasCurrentTime();

Vector3f const *posIt = posCoords;
Expand Down

0 comments on commit 02c443a

Please sign in to comment.