Dirtied plug still has the old value during setDependentsDirty()

帅比萌擦擦* 提交于 2020-02-08 02:34:11

问题


When I dirty an input plug for example mFileAttr, the setDependentsDirty() gets properly invoked, but the value of fileName plug is still the old value! I only see it getting updated once it goes through compute(). How can I access the new value in setDependentsDirty() function since it's indeed triggered by the plug value update?

MStatus FNode::setDependentsDirty(const MPlug& plug, MPlugArray& plugArray) {
    if (plug == mFileAttr)
    { 
        MPlug fileNamePlug(thisMObject(), plug);
        MString fileName = fileNamePlug.asString();
    }
    return MPxNode::setDependentsDirty(plug, plugArray); }

Edit: Just to clarify, reading plug value itself, plug.asString(), it still holds the old value.


回答1:


If you take close look in doc you will see why you are not getting the updated value

"IMPORTANT NOTE: since the setDependentsDirty() method is called during dirty propagation, you must be careful not to perform any dependency graph computations from within the routine. Instead, if you want to know the value of a plug, use MDataBlock::outputValue() because it will not result in computation (and thus recursion). In general, the majority of {setDependentsDirty()} methods which users will implement should involve only fixed relationships. In the rare occurence where you need to look at plug values, please heed the warning with {MDataBlock::outputValue()} and use plugs which contain values which you know to be up to date prior to the start of dirty propagation. "



来源:https://stackoverflow.com/questions/38692288/dirtied-plug-still-has-the-old-value-during-setdependentsdirty

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!