-
Notifications
You must be signed in to change notification settings - Fork 213
Adding support for array parameters #5954
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 1.5_maintenance
Are you sure you want to change the base?
Changes from 3 commits
eed1e18
eb76316
9634b89
98c95b5
c902277
77420aa
881d8d4
446cdc4
48cec0d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -430,12 +430,7 @@ class Shader::NetworkBuilder | |
} | ||
else if( const Gaffer::ArrayPlug *array = IECore::runTimeCast<const Gaffer::ArrayPlug>( parameter ) ) | ||
{ | ||
int i = 0; | ||
for( Plug::InputIterator it( array ); !it.done(); ++it, ++i ) | ||
{ | ||
IECore::InternedString childParameterName = parameterName.string() + "[" + std::to_string( i ) + "]"; | ||
addParameter( it->get(), childParameterName, shader, connections ); | ||
} | ||
addParameter( parameter, parameterName, shader, connections ); | ||
} | ||
else | ||
{ | ||
|
@@ -617,6 +612,28 @@ class Shader::NetworkBuilder | |
{ | ||
addSplineParameterComponentConnections< SplinefColor4fPlug >( (const SplinefColor4fPlug*)parameter, parameterName, connections ); | ||
} | ||
else if ( (Gaffer::TypeId)parameter->typeId() == ArrayPlugTypeId ) | ||
{ | ||
int i = 0; | ||
for ( Plug::InputIterator it( parameter ); !it.done(); ++it, ++i ) | ||
{ | ||
IECore::InternedString inputName = parameterName.string() + "[" + std::to_string( i ) + "]"; | ||
addParameterComponentConnections( it->get(), inputName, connections ); | ||
} | ||
} | ||
else | ||
{ | ||
const Gaffer::Plug *effectiveParameter = this->effectiveParameter( parameter ); | ||
if( effectiveParameter && isOutputParameter( effectiveParameter ) ) | ||
{ | ||
IECore::InternedString inputName = parameterName.string(); | ||
|
||
connections.push_back( { | ||
outputParameterForPlug( effectiveParameter ), | ||
{ IECore::InternedString(), inputName } | ||
} ); | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not clear to me what this case is for - could definitely use a comment at least. It doesn't seem related to this PR's main purpose ( arrays, which are handled in the case above ). Maybe this should be obvious, but I can't think offhand of what data types have components, other than compoundNumerics, splines, and arrays? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was to allow support connections to the entire array or individual array indices. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm still not quite following here - the conditional on line 615 should be handling arrays? You're saying that if you make a connection to the entire array, then addParameterComponentConnections is called on a Plug that isn't an ArrayPlug? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have finally come back to this to implement John's change, and the reason for this block of code is to handle a float array that has a float plug connected to an index. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, I'm still not 100% sure I understand this, but if I'm understanding correctly, you've identified a bug in the existing code, but I don't think this solution is in the right place. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not really a bug in current gaffer, it's very specific to array plugs as they have component connections which can either have sub component connections or just regular component connections. eg. |
||
} | ||
|
||
template< typename T > | ||
|
@@ -1059,6 +1076,10 @@ IECore::DataPtr Shader::parameterValue( const Gaffer::Plug *parameterPlug ) cons | |
{ | ||
return Gaffer::PlugAlgo::getValueAsData( valuePlug ); | ||
} | ||
else if( auto arrayPlug = IECore::runTimeCast<const Gaffer::ArrayPlug>( parameterPlug ) ) | ||
{ | ||
return Gaffer::PlugAlgo::getArrayAsVectorData( arrayPlug ); | ||
} | ||
|
||
return nullptr; | ||
} | ||
|
Uh oh!
There was an error while loading. Please reload this page.