Skip to content

Commit

Permalink
Merge pull request #44 from fdagenais-cinesite/fix_affects_methods
Browse files Browse the repository at this point in the history
Fix dirtying issues in affects() methods
  • Loading branch information
andrewkaufman authored Dec 11, 2020
2 parents aebf15d + 4c94074 commit 6218c47
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 78 deletions.
7 changes: 7 additions & 0 deletions include/AtomsGaffer/AtomsCrowdGenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,24 +81,31 @@ class AtomsCrowdGenerator : public GafferScene::BranchCreator
void hash( const Gaffer::ValuePlug *output, const Gaffer::Context *context, IECore::MurmurHash &h ) const override;
void compute( Gaffer::ValuePlug *output, const Gaffer::Context *context ) const override;

bool affectsBranchBound( const Gaffer::Plug *input ) const override;
void hashBranchBound( const ScenePath &parentPath, const ScenePath &branchPath, const Gaffer::Context *context, IECore::MurmurHash &h ) const override;
Imath::Box3f computeBranchBound( const ScenePath &parentPath, const ScenePath &branchPath, const Gaffer::Context *context ) const override;

bool affectsBranchTransform( const Gaffer::Plug *input ) const override;
void hashBranchTransform( const ScenePath &parentPath, const ScenePath &branchPath, const Gaffer::Context *context, IECore::MurmurHash &h ) const override;
Imath::M44f computeBranchTransform( const ScenePath &parentPath, const ScenePath &branchPath, const Gaffer::Context *context ) const override;

bool affectsBranchAttributes( const Gaffer::Plug *input ) const override;
void hashBranchAttributes( const ScenePath &parentPath, const ScenePath &branchPath, const Gaffer::Context *context, IECore::MurmurHash &h ) const override;
IECore::ConstCompoundObjectPtr computeBranchAttributes( const ScenePath &parentPath, const ScenePath &branchPath, const Gaffer::Context *context ) const override;

bool affectsBranchObject( const Gaffer::Plug *input ) const override;
void hashBranchObject( const ScenePath &parentPath, const ScenePath &branchPath, const Gaffer::Context *context, IECore::MurmurHash &h ) const override;
IECore::ConstObjectPtr computeBranchObject( const ScenePath &parentPath, const ScenePath &branchPath, const Gaffer::Context *context ) const override;

bool affectsBranchChildNames( const Gaffer::Plug *input ) const override;
void hashBranchChildNames( const ScenePath &parentPath, const ScenePath &branchPath, const Gaffer::Context *context, IECore::MurmurHash &h ) const override;
IECore::ConstInternedStringVectorDataPtr computeBranchChildNames( const ScenePath &parentPath, const ScenePath &branchPath, const Gaffer::Context *context ) const override;

bool affectsBranchSetNames( const Gaffer::Plug *input ) const override;
void hashBranchSetNames( const ScenePath &parentPath, const Gaffer::Context *context, IECore::MurmurHash &h ) const override;
IECore::ConstInternedStringVectorDataPtr computeBranchSetNames( const ScenePath &parentPath, const Gaffer::Context *context ) const override;

bool affectsBranchSet( const Gaffer::Plug *input ) const override;
void hashBranchSet( const ScenePath &parentPath, const IECore::InternedString &setName, const Gaffer::Context *context, IECore::MurmurHash &h ) const override;
IECore::ConstPathMatcherDataPtr computeBranchSet( const ScenePath &parentPath, const IECore::InternedString &setName, const Gaffer::Context *context ) const override;

Expand Down
2 changes: 2 additions & 0 deletions src/AtomsGaffer/AtomsCrowdClothReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ const IntPlug* AtomsCrowdClothReader::refreshCountPlug() const

void AtomsCrowdClothReader::affects( const Plug *input, AffectedPlugsContainer &outputs ) const
{
SceneProcessor::affects(input, outputs);

if( input == inPlug()->objectPlug() || input == inPlug()->attributesPlug() ||
input == atomsClothFilePlug() || input == refreshCountPlug() )
{
Expand Down
136 changes: 58 additions & 78 deletions src/AtomsGaffer/AtomsCrowdGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,65 +136,10 @@ void AtomsCrowdGenerator::affects( const Plug *input, AffectedPlugsContainer &ou
{
BranchCreator::affects( input, outputs );

if(
input == inPlug()->objectPlug() ||
input == inPlug()->attributesPlug() ||
input == variationsPlug()->childNamesPlug()
)
if( input == inPlug()->objectPlug() )
{
outputs.push_back( agentChildNamesPlug() );
}

if(
input == namePlug() ||
input == agentChildNamesPlug() ||
input == variationsPlug()->childNamesPlug()
)
{
outputs.push_back( outPlug()->childNamesPlug() );
}

if(
input == inPlug()->objectPlug() ||
input == inPlug()->attributesPlug() ||
input == namePlug() ||
input == variationsPlug()->boundPlug() ||
input == variationsPlug()->transformPlug() ||
input == agentChildNamesPlug() ||
input == boundingBoxPaddingPlug() ||
input == clothCachePlug()->objectPlug()
)
{
outputs.push_back( outPlug()->boundPlug() );
}

if(
input == inPlug()->objectPlug() ||
input == inPlug()->attributesPlug() ||
input == variationsPlug()->transformPlug()
)
{
outputs.push_back( outPlug()->transformPlug() );
}

if(
input == variationsPlug()->attributesPlug() ||
input == inPlug()->objectPlug() ||
input == inPlug()->attributesPlug()
)
{
outputs.push_back( outPlug()->attributesPlug() );
}

if( input == variationsPlug()->objectPlug() ||
input == variationsPlug()->attributesPlug() ||
input == inPlug()->objectPlug() ||
input == inPlug()->attributesPlug() ||
input == clothCachePlug()->objectPlug()
)
{
outputs.push_back( outPlug()->objectPlug() );
}
}

void AtomsCrowdGenerator::hash( const Gaffer::ValuePlug *output, const Gaffer::Context *context, MurmurHash &h ) const
Expand All @@ -204,9 +149,6 @@ void AtomsCrowdGenerator::hash( const Gaffer::ValuePlug *output, const Gaffer::C
if( output == agentChildNamesPlug() )
{
inPlug()->objectPlug()->hash( h );
inPlug()->attributesPlug()->hash( h );
h.append( variationsPlug()->childNamesHash( ScenePath() ) );
useInstancesPlug()->hash( h );
}
}

Expand Down Expand Up @@ -371,6 +313,15 @@ void AtomsCrowdGenerator::compute( Gaffer::ValuePlug *output, const Gaffer::Cont
BranchCreator::compute( output, context );
}

bool AtomsCrowdGenerator::affectsBranchBound( const Gaffer::Plug *input ) const
{
return ( input == inPlug()->attributesPlug() ||
input == namePlug() ||
input == variationsPlug()->transformPlug() ||
input == boundingBoxPaddingPlug() ||
input == clothCachePlug()->objectPlug() );
}

void AtomsCrowdGenerator::hashBranchBound( const ScenePath &parentPath, const ScenePath &branchPath, const Gaffer::Context *context, MurmurHash &h ) const
{
if( branchPath.size() < 4 )
Expand All @@ -385,33 +336,20 @@ void AtomsCrowdGenerator::hashBranchBound( const ScenePath &parentPath, const Sc
h = hashOfTransformedChildBounds( path, outPlug() );
}

else if( branchPath.size() == 4 )
else if( branchPath.size() >= 4 )
{
// "/agents/<agentType>/<variation>/<id>"
BranchCreator::hashBranchBound( parentPath, branchPath, context, h );

inPlug()->attributesPlug()->hash( h );
inPlug()->objectPlug()->hash( h );
boundingBoxPaddingPlug()->hash( h );
agentChildNamesHash( parentPath, context, h );
clothCachePlug()->objectPlug()->hash( h );
h.append( branchPath.back() );
{
AgentScope scope( context, branchPath );
variationsPlug()->transformPlug()->hash( h );
variationsPlug()->boundPlug()->hash( h );
}
}
else
{
// "/agents/<agentType>/<variation>/<id>/..."
clothCachePlug()->objectPlug()->hash( h );
AgentScope instanceScope( context, branchPath );
variationsPlug()->boundPlug()->hash( h );
boundingBoxPaddingPlug()->hash( h );
inPlug()->boundPlug()->hash( h );
inPlug()->attributesPlug()->hash( h );
inPlug()->objectPlug()->hash( h );
}
}

Imath::Box3f AtomsCrowdGenerator::computeBranchBound( const ScenePath &parentPath, const ScenePath &branchPath, const Gaffer::Context *context ) const
Expand Down Expand Up @@ -518,6 +456,12 @@ Imath::Box3f AtomsCrowdGenerator::computeBranchBound( const ScenePath &parentPat
}
}

bool AtomsCrowdGenerator::affectsBranchTransform( const Gaffer::Plug *input ) const
{
return ( input == inPlug()->attributesPlug() ||
input == variationsPlug()->transformPlug() );
}

void AtomsCrowdGenerator::hashBranchTransform( const ScenePath &parentPath, const ScenePath &branchPath, const Gaffer::Context *context, MurmurHash &h ) const
{

Expand All @@ -529,7 +473,6 @@ void AtomsCrowdGenerator::hashBranchTransform( const ScenePath &parentPath, cons
else if( branchPath.size() == 4 )
{
// "/agents/<agentType>/<variation>/<id>"
inPlug()->objectPlug()->hash( h );
inPlug()->attributesPlug()->hash( h );
h.append( branchPath[3] );
}
Expand All @@ -538,8 +481,6 @@ void AtomsCrowdGenerator::hashBranchTransform( const ScenePath &parentPath, cons
// "/agents/<agentType>/<variation>/<id>/..."
AgentScope scope( context, branchPath );
variationsPlug()->transformPlug()->hash( h );
inPlug()->attributesPlug()->hash( h );
inPlug()->objectPlug()->hash( h );
h.append( branchPath[3] );
}
}
Expand All @@ -565,9 +506,16 @@ Imath::M44f AtomsCrowdGenerator::computeBranchTransform( const ScenePath &parent
}
}

bool AtomsCrowdGenerator::affectsBranchAttributes( const Gaffer::Plug *input ) const
{
return ( input == variationsPlug()->attributesPlug() ||
input == inPlug()->objectPlug() ||
input == inPlug()->attributesPlug() );
}

void AtomsCrowdGenerator::hashBranchAttributes( const ScenePath &parentPath, const ScenePath &branchPath, const Gaffer::Context *context, MurmurHash &h ) const
{
if( branchPath.size() < 1 )
if( branchPath.size() < 2 )
{
// "/" or "/agents"
h = outPlug()->attributesPlug()->defaultValue()->Object::hash();
Expand Down Expand Up @@ -842,6 +790,17 @@ ConstCompoundObjectPtr AtomsCrowdGenerator::computeBranchAttributes( const Scene
}
}

bool AtomsCrowdGenerator::affectsBranchObject( const Gaffer::Plug *input ) const
{
return ( input == variationsPlug()->objectPlug() ||
input == variationsPlug()->attributesPlug() ||
input == variationsPlug()->transformPlug() ||
input == inPlug()->objectPlug() ||
input == inPlug()->attributesPlug() ||
input == clothCachePlug()->objectPlug() ||
input == useInstancesPlug() );
}

void AtomsCrowdGenerator::hashBranchObject( const ScenePath &parentPath, const ScenePath &branchPath, const Gaffer::Context *context, MurmurHash &h ) const
{
if( branchPath.size() <= 4 )
Expand All @@ -855,6 +814,7 @@ void AtomsCrowdGenerator::hashBranchObject( const ScenePath &parentPath, const S
clothCachePlug()->objectPlug()->hash( h );
AgentScope instanceScope( context, branchPath );
variationsPlug()->objectPlug()->hash( h );
variationsPlug()->transformPlug()->hash( h );
inPlug()->attributesPlug()->hash( h );
inPlug()->objectPlug()->hash( h );
atomsPoseHash( parentPath, branchPath, context, h );
Expand Down Expand Up @@ -1030,6 +990,13 @@ ConstObjectPtr AtomsCrowdGenerator::computeBranchObject( const ScenePath &parent
return result;
}

bool AtomsCrowdGenerator::affectsBranchChildNames( const Gaffer::Plug *input ) const
{
return ( input == namePlug() ||
input == agentChildNamesPlug() ||
input == variationsPlug()->childNamesPlug() );
}

void AtomsCrowdGenerator::hashBranchChildNames( const ScenePath &parentPath, const ScenePath &branchPath, const Gaffer::Context *context, MurmurHash &h ) const
{
if( branchPath.empty() )
Expand Down Expand Up @@ -1128,6 +1095,11 @@ ConstInternedStringVectorDataPtr AtomsCrowdGenerator::computeBranchChildNames( c
}
}

bool AtomsCrowdGenerator::affectsBranchSetNames( const Gaffer::Plug *input ) const
{
return ( input == variationsPlug()->setNamesPlug() );
}

void AtomsCrowdGenerator::hashBranchSetNames( const ScenePath &parentPath, const Gaffer::Context *context, MurmurHash &h ) const
{
h = variationsPlug()->setNamesPlug()->hash();
Expand All @@ -1138,6 +1110,14 @@ ConstInternedStringVectorDataPtr AtomsCrowdGenerator::computeBranchSetNames( con
return variationsPlug()->setNamesPlug()->getValue();
}

bool AtomsCrowdGenerator::affectsBranchSet( const Gaffer::Plug *input ) const
{
return ( input == variationsPlug()->childNamesPlug() ||
input == agentChildNamesPlug() ||
input == variationsPlug()->setPlug() ||
input == namePlug() );
}

void AtomsCrowdGenerator::hashBranchSet( const ScenePath &parentPath, const InternedString &setName, const Gaffer::Context *context, MurmurHash &h ) const
{
BranchCreator::hashBranchSet( parentPath, setName, context, h );
Expand Down

0 comments on commit 6218c47

Please sign in to comment.