Announcements

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

dirtyPlugExists always true?

dirtyPlugExists always true?

nobrainnobrain
Community Visitor Community Visitor
723 Views
2 Replies
Message 1 of 3

dirtyPlugExists always true?

nobrainnobrain
Community Visitor
Community Visitor

Hi,

 

I'm writing some custom nodes using the API and I can't figure out how to detect if an attribute has actually changed:

my node have input (integer) attributes in_a, in_b and outputs out_c.

 

both inputs are needed for calculation of c, but I want to perform additional calculation when b changed.

basically I have this

MStatus mynode::preEvaluation(const  MDGContext& context, const MEvaluationNode& evaluationNode)
{

...

     if( (evaluationNode.dirtyPlugExists(in_a, &status) && status)
|| (evaluationNode.dirtyPlugExists(in_b, &status) && status))
{
needRefresh = true;
}

if(evaluationNode.dirtyPlugExists(in_b, &status) && status)
{ 
mustperformadditionalstuff = true;
}

return MStatus::kSuccess;
}

 

basically it works fine, except that when I have some keyframes on b, this function

evaluationNode.dirtyPlugExists(in_b, &status)

always returns true, on every single frame.

It's not expected since on most frames the value doesn't change. but now my boolean is always set to true;

 

Am I missing something about the way we can track if an input plug is dirty?

 

thanks

 

0 Likes
724 Views
2 Replies
Replies (2)
Message 2 of 3

cheng_xi_li
Autodesk Support
Autodesk Support

Hi,

 

Since it is integer, can you cache the value and do a comparison in your code? I think the reason here because it is a curve so its output always gets dirty when time changes. This will affect nodes connecting to it.

 

Yours,

Li

0 Likes
Message 3 of 3

kevin.picott
Alumni
Alumni

Plugs are considered dirty in the evaluation nodes only if they will be scheduled for evaluation. The only time an animated plug won't be "dirty" is if the animation is static, i.e. has the same value at all frames. Unlike DG mode the dirty status in the evaluation graph is constant - it only changes when topology changes.

 

The naming might be a bit confusing - think of the function as "will be computed during evaluation" instead of "dirty".



Kevin "Father of the DG" Picott

Senior Principal Engineer