Skip to content

Commit

Permalink
Refactor|Materials: Relocated Materials::rebuild() logic to def_main.cpp
Browse files Browse the repository at this point in the history
The Materials collection has lacks the knowledge of how the materials
were originally interpreted from definitions, so therefore it cannot
action a "rebuild".
  • Loading branch information
danij-deng committed Jan 22, 2013
1 parent 8399828 commit a985f20
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 29 deletions.
9 changes: 0 additions & 9 deletions doomsday/client/include/resource/materials.h
Expand Up @@ -265,15 +265,6 @@ class Materials
*/
Manifest &find(Uri const &search) const;

/**
* Update @a material according to the supplied definition @a def.
* To be called after an engine update/reset.
*
* @param material Material to be updated.
* @param def Material definition to update using.
*/
void rebuild(Material &material, ded_material_t *def = 0);

/**
* Create a new Material unless an existing Material is found at the path
* (and within the same scheme) as that specified in @a def, in which case
Expand Down
8 changes: 7 additions & 1 deletion doomsday/client/src/def_main.cpp
Expand Up @@ -1203,7 +1203,13 @@ void Def_Read()
{
// Update existing.
Material &material = App_Materials().find(*reinterpret_cast<de::Uri *>(def->uri)).material();
App_Materials().rebuild(material, def);

/// @todo We should be able to rebuild the variants.
material.clearVariants();
material.setDefinition(def);

// Re-link definitions.
material.manifest().linkDefinitions();
}
catch(Materials::Manifest::MissingMaterialError const&)
{} // Ignore this error.
Expand Down
19 changes: 0 additions & 19 deletions doomsday/client/src/resource/materials.cpp
Expand Up @@ -313,25 +313,6 @@ void Materials::clearDefinitionLinks()
}
}

void Materials::rebuild(Material &material, ded_material_t *def)
{
if(!def) return;

/// @todo We should be able to rebuild the variants.
material.clearVariants();
material.setDefinition(def);

// Update manifests.
for(uint i = 0; i < d->manifestCount; ++i)
{
Manifest *manifest = d->manifestIdMap[i];
if(!manifest || !manifest->hasMaterial()) continue;
if(&manifest->material() != &material) continue;

manifest->linkDefinitions();
}
}

void Materials::purgeCacheQueue()
{
d->variantCacheQueue.clear();
Expand Down

0 comments on commit a985f20

Please sign in to comment.