Skip to content

Commit

Permalink
Optimize|World|Sector: Height of permanently mapped planes is not obs…
Browse files Browse the repository at this point in the history
…erved by clusters

Such a mapping does not need to be resolved dynamically following a
height change so don't observe.
  • Loading branch information
danij-deng committed Sep 15, 2013
1 parent 8516796 commit 58e914c
Showing 1 changed file with 21 additions and 16 deletions.
37 changes: 21 additions & 16 deletions doomsday/client/src/world/sectorcluster.cpp
Expand Up @@ -140,29 +140,35 @@ DENG2_OBSERVES(Plane, HeightChange)
}
}

void observePlane(Plane *plane, bool yes = true)
void observePlane(Plane *plane, bool yes = true, bool observeHeight = true)
{
if(!plane) return;

if(yes)
{
plane->audienceForDeletion += this;
plane->audienceForHeightChange += this;
plane->audienceForDeletion += this;
if(observeHeight)
{
plane->audienceForHeightChange += this;
#ifdef __CLIENT__
plane->audienceForHeightSmoothedChange += this;
plane->audienceForHeightSmoothedChange += this;
#endif
}
}
else
{
plane->audienceForDeletion -= this;
plane->audienceForHeightChange -= this;
plane->audienceForDeletion -= this;
if(observeHeight)
{
plane->audienceForHeightChange -= this;
#ifdef __CLIENT__
plane->audienceForHeightSmoothedChange -= this;
plane->audienceForHeightSmoothedChange -= this;
#endif
}
}
}

void map(int planeIdx, Cluster *newCluster)
void map(int planeIdx, Cluster *newCluster, bool permanent = false)
{
Cluster **clusterAdr = mappedClusterAdr(planeIdx);
if(!clusterAdr || *clusterAdr == newCluster)
Expand All @@ -174,7 +180,7 @@ DENG2_OBSERVES(Plane, HeightChange)
*clusterAdr = newCluster;

observeCluster(*clusterAdr);
observePlane(mappedPlane(planeIdx));
observePlane(mappedPlane(planeIdx), true, !permanent);
}

void clearMapping(int planeIdx)
Expand Down Expand Up @@ -260,10 +266,10 @@ DENG2_OBSERVES(Plane, HeightChange)
map(Sector::Floor, thisPublic);
map(Sector::Ceiling, thisPublic);

// Should we permanently map planes to another cluster?
if(classification() & NeverMapped)
return;

// Should we permanently map planes to another cluster?
forever
{
// Locate the next exterior cluster.
Expand Down Expand Up @@ -323,15 +329,14 @@ DENG2_OBSERVES(Plane, HeightChange)
}

// Setup the mapping and we're done.
map(Sector::Floor, exteriorCluster);
map(Sector::Ceiling, exteriorCluster);
break;
map(Sector::Floor, exteriorCluster, true /*permanently*/);
map(Sector::Ceiling, exteriorCluster, true /*permanently*/);
return;
}

// No permanent mapping?
if(mappedVisFloor == thisPublic && !(classification() & AllSelfRef))
// Dynamic mapping may be needed for one or more planes.
if(!classification().testFlag(AllSelfRef))
{
// Dynamic mapping may be needed for one or more planes.
Plane const &sectorFloor = self.sector().floor();
Plane const &sectorCeiling = self.sector().ceiling();

Expand Down

0 comments on commit 58e914c

Please sign in to comment.