Triggering a node DG Evaluation from a callback (C++ MPXNode)

Triggering a node DG Evaluation from a callback (C++ MPXNode)

Anonymous
Not applicable
1,735 Views
4 Replies
Message 1 of 5

Triggering a node DG Evaluation from a callback (C++ MPXNode)

Anonymous
Not applicable

So I'm doing a plugin getting a node from a message Attribute. I based the plugin structure on that one:

affectsNode I believe it was made by the guy on Around-The-Corner blog

His method for dirtying the node simply didn't work on my end, oh sure the node got dirtied but if I'm constraining the object to another one (in other words there's no direct connection between the objects) the callback fires, the node gets dirtied but there's no DG evaluation triggering. Same thing when I open a file containing the node.

 

That's a big issue in my case and nothing made it work (I know the issue is not in the affectAttribute because if I change the dummy attribute value by hand everything evaluates as expected) .

It doesn't work using the MDGModifier::newPlugValue method, nor by executing a setAttr mel command with MDGModifier and the dgdirty command fails to execute at all. 

 

My theorical workaround would be to put all my compute inside a plugdirty callback and then only set the output plug clean inside the compute. But if I could avoid it I would.

Is there really no way to trigger a DG evaluation from a callback? 

 

0 Likes
1,736 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable

DG evaluation only occurs when the value of a dirty, affected attribute is retrieved. In the case of the affectsNode plugin you could force an evaluation by using MPlug or getAttr to retrieve the value of the projectionMatrix attribute after it has become dirty.

 

Alternatively, you can connect the affected attribute to some other attribute which will affect how the scene is rendered, in which case Maya will schedule a redraw of the viewport that will eventually result in the dirty attribute's value being retrieved.

0 Likes
Message 3 of 5

Anonymous
Not applicable

I understand what you're saying, I've been doing what you're talking about with the projection matrix attribute, which is getting the output value from the callback.

And even after setting the inputValue dirty it still doesn't trigger an evaluation.

Nor is setting the node dirty with a mel command, which works when you do it in a script outside the plugin.. 

 

My dirtyDummy attribute is hidden, so I'm not sure what you mean by connecting it to an attribute that forces the scene to render?

0 Likes
Message 4 of 5

Anonymous
Not applicable

I was talking about connecting the affected attribute to something which affects the draw. In the case of the affectsNode example projectionMatrix is the affected attribute.

 

At this point I'd need to see your actual code to provide any further help.

Message 5 of 5

Anonymous
Not applicable

Unfortunately I can't show the code,  I wouldn't have been able to connect my output to something else because I'm using a MDoubleArray as output and nearly none of the default maya nodes can take that as input.

 

In the end I just connected the transform as well which made it work.

It's not very pretty but it's not too bad. 

0 Likes