Skip to content

Commit

Permalink
Merge branch 'master' of ssh://github.com/skyjake/Doomsday-Engine
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Mar 19, 2013
2 parents bc61fbe + 35039f1 commit 14d190d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
8 changes: 4 additions & 4 deletions doomsday/client/include/resource/material.h
Expand Up @@ -74,6 +74,9 @@ class Material : public de::MapElement
static int const max_decorations = 16;
#endif

/// Required animation is missing. @ingroup errors
DENG2_ERROR(MissingAnimationError);

/// The referenced layer does not exist. @ingroup errors
DENG2_ERROR(UnknownLayerError);

Expand Down Expand Up @@ -911,10 +914,7 @@ class Material : public de::MapElement
/**
* Retrieve the animation state for the specified render @a context.
*/
inline Animation *animation(MaterialContextId context) const
{
return animations().value(context, NULL);
}
Animation &animation(MaterialContextId context) const;

/**
* Provides access to the set of usage context animation states,
Expand Down
13 changes: 13 additions & 0 deletions doomsday/client/src/resource/material.cpp
Expand Up @@ -618,6 +618,19 @@ void Material::clearDecorations()
d->animationsAreDirty = true;
}

Material::Animation &Material::animation(MaterialContextId context) const
{
d->rebuildAnimations();

Animations::const_iterator found = d->animations.find(context);
if(found != d->animations.end())
{
return *found.value();
}
/// @throw MissingAnimationError No animation exists for the specifed context.
throw MissingAnimationError("Material::animation", QString("No animation for context %1").arg(int(context)));
}

Material::Animations const &Material::animations() const
{
d->rebuildAnimations();
Expand Down
14 changes: 7 additions & 7 deletions doomsday/client/src/resource/materialsnapshot.cpp
Expand Up @@ -251,7 +251,7 @@ void MaterialSnapshot::Instance::takeSnapshot()
*/
for(int i = 0; i < layers.count(); ++i)
{
MaterialAnimation::LayerState const &l = material->animation(variant->context())->layer(i);
MaterialAnimation::LayerState const &l = material->animation(variant->context()).layer(i);

Material::Layer::Stage const *lsCur = layers[i]->stages()[l.stage];
if(Texture *tex = lsCur->texture)
Expand Down Expand Up @@ -287,7 +287,7 @@ void MaterialSnapshot::Instance::takeSnapshot()
// Do we need to prepare detail texture(s)?
if(!material->isSkyMasked() && material->isDetailed())
{
MaterialAnimation::LayerState const &l = material->animation(variant->context())->detailLayer();
MaterialAnimation::LayerState const &l = material->animation(variant->context()).detailLayer();
Material::DetailLayer::Stage const *lsCur = detailLayer->stages()[l.stage];

float const contrast = de::clamp(0.f, lsCur->strength, 1.f) * detailFactor /*Global strength multiplier*/;
Expand All @@ -313,7 +313,7 @@ void MaterialSnapshot::Instance::takeSnapshot()
// Do we need to prepare a shiny texture (and possibly a mask)?
if(!material->isSkyMasked() && material->isShiny())
{
MaterialAnimation::LayerState const &l = material->animation(variant->context())->shineLayer();
MaterialAnimation::LayerState const &l = material->animation(variant->context()).shineLayer();
Material::ShineLayer::Stage const *lsCur = shineLayer->stages()[l.stage];

if(Texture *tex = lsCur->texture)
Expand Down Expand Up @@ -350,7 +350,7 @@ void MaterialSnapshot::Instance::takeSnapshot()

if(stored.dimensions.x == 0 && stored.dimensions.y == 0) return;

MaterialAnimation::LayerState const &l = material->animation(variant->context())->layer(0);
MaterialAnimation::LayerState const &l = material->animation(variant->context()).layer(0);
Material::Layer::Stage const *lsCur = layers[0]->stages()[l.stage];
Material::Layer::Stage const *lsNext = layers[0]->stages()[(l.stage + 1) % layers[0]->stageCount()];

Expand Down Expand Up @@ -409,7 +409,7 @@ void MaterialSnapshot::Instance::takeSnapshot()
if(!material->isSkyMasked() && material->isDetailed())
{
#ifdef __CLIENT__
MaterialAnimation::LayerState const &l = material->animation(variant->context())->detailLayer();
MaterialAnimation::LayerState const &l = material->animation(variant->context()).detailLayer();
Material::DetailLayer::Stage const *lsCur = detailLayer->stages()[l.stage];
Material::DetailLayer::Stage const *lsNext = detailLayer->stages()[(l.stage + 1) % detailLayer->stageCount()];
#endif
Expand Down Expand Up @@ -463,7 +463,7 @@ void MaterialSnapshot::Instance::takeSnapshot()
if(!material->isSkyMasked() && material->isShiny())
{
#ifdef __CLIENT__
MaterialAnimation::LayerState const &l = material->animation(variant->context())->shineLayer();
MaterialAnimation::LayerState const &l = material->animation(variant->context()).shineLayer();
Material::ShineLayer::Stage const *lsCur = shineLayer->stages()[l.stage];
Material::ShineLayer::Stage const *lsNext = shineLayer->stages()[(l.stage + 1) % shineLayer->stageCount()];
#endif
Expand Down Expand Up @@ -526,7 +526,7 @@ void MaterialSnapshot::Instance::takeSnapshot()
for(Material::Decorations::const_iterator it = decorations.begin();
it != decorations.end(); ++it, ++idx)
{
MaterialAnimation::DecorationState const &l = material->animation(variant->context())->decoration(idx);
MaterialAnimation::DecorationState const &l = material->animation(variant->context()).decoration(idx);
MaterialDecoration const *lDef = *it;
MaterialDecoration::Stage const *lsCur = lDef->stages()[l.stage];
MaterialDecoration::Stage const *lsNext = lDef->stages()[(l.stage + 1) % lDef->stageCount()];
Expand Down

0 comments on commit 14d190d

Please sign in to comment.