Skip to content
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

Adding support for array parameters #5954

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/GafferScene/Shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,19 @@ class Shader::NetworkBuilder
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 }
} );
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The 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?

Copy link
Author

Choose a reason for hiding this comment

The 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.

Copy link
Contributor

Choose a reason for hiding this comment

The 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?

Copy link
Author

Choose a reason for hiding this comment

The 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.

Copy link
Contributor

Choose a reason for hiding this comment

The 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. addComponentConnections is intended to add connections to the children of a plug, not the plug itself. I think the bug is on line 621 when the children of an array plug are handled just by calling addComponentConnections - this isn't right, because the children of an array might not have components ( ie. a float array ). But we don't exactly have the right code for "add a top level connection if the top level is connected, otherwise add component connections" in a form that's easy to call - if we just called addParameter on line 621, that would sort of do the trick, but it would also be trying to set the parameter value, which we don't want here. We could paste in the relevant code from addParameter, but that's a bit messy. Maybe @johnhaddon has an idea how he'd like this arranged.

Copy link
Author

Choose a reason for hiding this comment

The 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. ramp['color'][1]['r'] vs ramp['position'][1]. This made the most sense to me as I didn't want to have a bunch of duplicate code looking for components within the array, I would be happy to move it anywhere it would make more sense.

}

template< typename T >
Expand Down