Skip to content

Commit

Permalink
Fix small bug when updating projects from rev. 9 to 10
Browse files Browse the repository at this point in the history
When two Specular BTDFs were almost paired but not quite (because the IORs wouldn't match, for instance) then both were inserted into the assembly but potentially with the same name.

When this happens, we now skip the insertion of the second one.
  • Loading branch information
dictoon authored and est77 committed Nov 1, 2018
1 parent 2a46f63 commit 5cff7b9
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/appleseed/renderer/modeling/project/projectfileupdater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -864,10 +864,15 @@ namespace
// Extract mat1 from the assembly.
auto_release_ptr<Material> mat1_owner = assembly.materials().remove(mat1.m_material);

// Extract mat1's BSDF from the assembly.
auto_release_ptr<BSDF> bsdf_owner = assembly.bsdfs().remove(mat1.m_bsdf);

// Update mat1's BSDF.
// todo: make sure the BSDF is not used in another material.
auto_release_ptr<BSDF> bsdf_owner = assembly.bsdfs().remove(mat1.m_bsdf);
update_bsdf(mat1);
assert(assembly.bsdfs().get_by_name(bsdf_owner->get_name()) == nullptr);

// Insert mat1's BSDF back into the assembly.
assembly.bsdfs().insert(bsdf_owner);

// Rename mat1.
Expand Down Expand Up @@ -897,11 +902,16 @@ namespace

if (!i->m_updated)
{
// Extract the material's BSDF from the assembly.
auto_release_ptr<BSDF> bsdf_owner = assembly.bsdfs().remove(i->m_bsdf);

// Update the material's BSDF.
// todo: make sure the BSDF is not used in another material.
auto_release_ptr<BSDF> bsdf_owner = assembly.bsdfs().remove(i->m_bsdf);
update_bsdf(*i);
assembly.bsdfs().insert(bsdf_owner);

// Insert the material's BSDF back into the assembly.
if (assembly.bsdfs().get_by_name(bsdf_owner->get_name()) == nullptr)
assembly.bsdfs().insert(bsdf_owner);

i->m_updated = true;
}
Expand Down

0 comments on commit 5cff7b9

Please sign in to comment.