Skip to content

Commit

Permalink
World|Sky: Removed now unused logic from Sky
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed Sep 7, 2014
1 parent a75e2a1 commit 1b351f5
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 47 deletions.
7 changes: 0 additions & 7 deletions doomsday/client/include/world/sky.h
Expand Up @@ -214,13 +214,6 @@ class Sky : public de::MapElement
*/
void setHorizonOffset(float newOffset);

/**
* Returns the unique identifier of the sky's first active layer.
*
* @see Layer::isActive()
*/
int firstActiveLayer() const;

#ifdef __CLIENT__

/**
Expand Down
12 changes: 6 additions & 6 deletions doomsday/client/src/render/skydrawable.cpp
Expand Up @@ -536,14 +536,14 @@ void SkyDrawable::cacheDrawableAssets(Sky const *sky)
}
}

if(d->haveModels)
if(!d->haveModels) return;

for(int i = 0; i < MAX_MODELS; ++i)
{
for(int i = 0; i < MAX_MODELS; ++i)
ModelConfig &mcfg = model(i);
if(mcfg.def)
{
ModelConfig &mdata = model(i);
if(!mdata.def) continue;

d->resSys().cache(mdata.model);
d->resSys().cache(mcfg.model);
}
}
}
Expand Down
48 changes: 14 additions & 34 deletions doomsday/client/src/world/sky.cpp
Expand Up @@ -139,15 +139,13 @@ void Sky::Layer::setFadeoutLimit(float newLimit)
}

DENG2_PIMPL(Sky)
, DENG2_OBSERVES(Layer, ActiveChange)
#ifdef __CLIENT__
, DENG2_OBSERVES(Layer, ActiveChange)
, DENG2_OBSERVES(Layer, MaterialChange)
, DENG2_OBSERVES(Layer, MaskedChange)
#endif
{
Layers layers;
int firstActiveLayer = -1; /// @c -1= 'no active layers'.
bool needFirstActiveLayerUpdate = true;

float height = 0;
float horizonOffset = 0;
Expand All @@ -163,10 +161,10 @@ DENG2_PIMPL(Sky)
for(int i = 0; i < NUM_LAYERS; ++i)
{
layers.append(new Layer(self));
Layer *layer = layers.last();

layer->audienceForActiveChange() += this;
#ifdef __CLIENT__
Layer *layer = layers.last();
layer->audienceForActiveChange() += this;
layer->audienceForMaskedChange() += this;
layer->audienceForMaterialChange() += this;
#endif
Expand All @@ -178,33 +176,13 @@ DENG2_PIMPL(Sky)
qDeleteAll(layers);
}

void updateFirstActiveLayerIfNeeded()
{
if(!needFirstActiveLayerUpdate) return;
needFirstActiveLayerUpdate = false;

firstActiveLayer = -1; // -1 denotes 'no active layers'.
for(int i = 0; i < layers.count(); ++i)
{
if(layers[i]->isActive())
{
firstActiveLayer = i;
break;
}
}
}

#ifdef __CLIENT__
/// Observes Layer ActiveChange
void skyLayerActiveChanged(Layer & /*layer*/)
{
needFirstActiveLayerUpdate = true;
#ifdef __CLIENT__
needUpdateAmbientColor = true;
#endif
needUpdateAmbientColor = true;
}

#ifdef __CLIENT__

/**
* @todo Move to SkyDrawable and have it simply update this component once the
* ambient color has been calculated.
Expand All @@ -221,7 +199,15 @@ DENG2_PIMPL(Sky)
// By default the ambient color is pure white.
ambientColor = Vector3f(1, 1, 1);

updateFirstActiveLayerIfNeeded();
int firstActiveLayer = -1; // -1 denotes 'no active layers'.
for(int i = 0; i < layers.count(); ++i)
{
if(layers[i]->isActive())
{
firstActiveLayer = i;
break;
}
}
if(firstActiveLayer < 0) return;

Vector3f avgMaterialColor;
Expand Down Expand Up @@ -405,12 +391,6 @@ void Sky::setHorizonOffset(float newOffset)
}
}

int Sky::firstActiveLayer() const
{
d->updateFirstActiveLayerIfNeeded();
return d->firstActiveLayer;
}

int Sky::property(DmuArgs &args) const
{
switch(args.prop)
Expand Down

0 comments on commit 1b351f5

Please sign in to comment.