Skip to content

Commit

Permalink
Material: Implemented Material_IsAnimated()
Browse files Browse the repository at this point in the history
Returns true if the material is animated using either the layer-stage
method or the older anim group method.
  • Loading branch information
danij-deng committed Jan 8, 2013
1 parent 470b447 commit cd4d81a
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 6 deletions.
5 changes: 4 additions & 1 deletion doomsday/engine/include/resource/material.h
Expand Up @@ -146,7 +146,10 @@ void Material_SetFlags(material_t *mat, short flags);
/// @return @c true if Material is not derived from an original game resource.
boolean Material_IsCustom(material_t const *mat);

/// @return @c true if Material belongs to one or more anim groups.
/// @return @c true= the material is animated.
boolean Material_IsAnimated(material_t const *mat);

/// @return @c true= the material belongs to one or more anim groups.
boolean Material_IsGroupAnimated(material_t const *mat);

/// @return @c true if Material should be replaced with Sky.
Expand Down
4 changes: 2 additions & 2 deletions doomsday/engine/src/map/r_world.cpp
Expand Up @@ -1598,9 +1598,9 @@ static material_t *chooseFixMaterial(SideDef *s, SideDefSection section)
choice2 = frontSec->SP_plane(section == SS_BOTTOM? PLN_FLOOR : PLN_CEILING)->PS_material;

// Prefer a non-animated, non-masked material.
if(choice1 && !Material_IsGroupAnimated(choice1) && !Material_IsSkyMasked(choice1))
if(choice1 && !Material_IsAnimated(choice1) && !Material_IsSkyMasked(choice1))
return choice1;
if(choice2 && !Material_IsGroupAnimated(choice2) && !Material_IsSkyMasked(choice2))
if(choice2 && !Material_IsAnimated(choice2) && !Material_IsSkyMasked(choice2))
return choice2;

// Prefer a non-masked material.
Expand Down
17 changes: 17 additions & 0 deletions doomsday/engine/src/resource/material.cpp
Expand Up @@ -401,6 +401,23 @@ boolean Material_IsCustom(material_t const *mat)
return boolean( mat->isCustom );
}

boolean Material_IsAnimated(material_t const *mat)
{
if(Material_IsGroupAnimated(mat)) return true;

// Perhaps stage animated?
if(mat->def)
{
int const layerCount = Material_LayerCount(mat);
for(int i = 0; i < layerCount; ++i)
{
ded_material_layer_t const &layer = mat->def->layers[i];
if(layer.stageCount.num > 1) return true;
}
}
return false; // Not at all.
}

boolean Material_IsGroupAnimated(material_t const *mat)
{
DENG2_ASSERT(mat);
Expand Down
5 changes: 2 additions & 3 deletions doomsday/engine/src/resource/materials.cpp
Expand Up @@ -963,10 +963,9 @@ static void printMaterialInfo(material_t &mat)
else
Con_Printf("Dimensions: %d x %d\n", Material_Width(&mat), Material_Height(&mat));

Con_Printf("Layers:%i InGroup:%s Drawable:%s EnvClass:%s"
"\nDecorated:%s Detailed:%s Glowing:%s Shiny:%s%s SkyMasked:%s\n",
Con_Printf("Layers:%i Drawable:%s EnvClass:%s Decorated:%s"
"\nDetailed:%s Glowing:%s Shiny:%s%s SkyMasked:%s\n",
Material_LayerCount(&mat),
Material_IsGroupAnimated(&mat)? "yes" : "no",
Material_IsDrawable(&mat) ? "yes" : "no",
Material_EnvironmentClass(&mat) == MEC_UNKNOWN? "N/A" : S_MaterialEnvClassName(Material_EnvironmentClass(&mat)),
App_Materials()->hasDecorations(mat) ? "yes" : "no",
Expand Down

0 comments on commit cd4d81a

Please sign in to comment.