Skip to content

Commit

Permalink
switch : instrument inputIndex
Browse files Browse the repository at this point in the history
  • Loading branch information
johnhaddon committed Dec 7, 2023
1 parent c91f16c commit b799a03
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/Gaffer/Switch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,26 +344,36 @@ size_t Switch::inputIndex( const Context *context ) const
globalScope.emplace( context, globalScopePlug );
}

std::cerr << "inputIndex 1 " << fullName() << std::endl;

if( !enabledPlug->getValue() )
{
std::cerr << "inputIndex 1.1 " << fullName() << std::endl;
return 0;
}

std::cerr << "inputIndex 2 " << fullName() << std::endl;

const size_t index = indexPlug->getValue();

std::cerr << "inputIndex 3 " << fullName() << std::endl;

if( inPlugs->resizeWhenInputsChange() )
{
// Last input is always unconnected, so should be ignored.
std::cerr << "inputIndex 3.1 " << fullName() << std::endl;
return index % (numInputs - 1);
}
else
{
std::cerr << "inputIndex 3.2 " << fullName() << std::endl;
return index % numInputs;
}
}

const Plug *Switch::oppositePlug( const Plug *plug, const Context *context ) const
{
std::cerr << "oppositePlug 1 " << plug->fullName() << std::endl;
//std::cerr << "oppositePlug 1 " << plug->fullName() << std::endl;
const ArrayPlug *inPlugs = this->inPlugs();
const Plug *outPlug = this->outPlug();
if( !inPlugs || !outPlug )
Expand All @@ -390,7 +400,7 @@ const Plug *Switch::oppositePlug( const Plug *plug, const Context *context ) con
plug = static_cast<const Plug *>( plugParent );
}
}
std::cerr << "oppositePlug 2 " << std::endl;
//std::cerr << "oppositePlug 2 " << std::endl;

if( !ancestorPlug )
{
Expand All @@ -401,17 +411,17 @@ const Plug *Switch::oppositePlug( const Plug *plug, const Context *context ) con
const Plug *oppositeAncestorPlug = nullptr;
if( plug->direction() == Plug::Out )
{
std::cerr << "oppositePlug 3 " << std::endl;
//std::cerr << "oppositePlug 3 " << std::endl;
const size_t i = context ? inputIndex( context ) : 0;
std::cerr << "oppositePlug 4 " << std::endl;
//std::cerr << "oppositePlug 4 " << std::endl;
oppositeAncestorPlug = inPlugs->getChild<Plug>( i );
}
else
{
oppositeAncestorPlug = outPlug;
}

std::cerr << "oppositePlug 5 " << std::endl;
//std::cerr << "oppositePlug 5 " << std::endl;

// And then find the opposite of plug by traversing down from the ancestor plug.
const Plug *result = oppositeAncestorPlug;
Expand Down

0 comments on commit b799a03

Please sign in to comment.