Using setDependentsDirty to dirty only an element of an output array

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I am having some issues trying to dirty only one element (at a specific logical index) of an output array. More precisely, I have a custom MPxDeformer node which has a multi compound attribute as an input, and I want to only dirty a specific element of an output array attribute, e.g., modifying the specific attribute inputArray[2].inputMesh should only dirty outputArray[2], not outputArray[0] and outputArray[1]. To do so, I have overriden setDependentsDirty, which works in most cases. However, I found that when I load a file with my deformer already setup that method is not called unless I manually change the input value, thus my output is not computed. Am I trying to do something that setDependentsDirty is not meant to be for? Is there a better way to accomplish what I want to do?
I attached a simple test I did that also has that issue. Here's how I create my attributes:
MStatus TestArrayPlugsNode::initialize()
{
MFnCompoundAttribute compoundAttribute;
MFnTypedAttribute typedAttribute;
MFnNumericAttribute numericAttribute;
_inputArray = compoundAttribute.create("inputArray", "in");
compoundAttribute.setArray(true);
_inputMesh = typedAttribute.create("inputMesh", "inMesh", MFnData::kMesh);
compoundAttribute.addChild(_inputMesh);
_inputValue = numericAttribute.create("inputValue", "inValue", MFnNumericData::kDouble, 1.0);
compoundAttribute.addChild(_inputValue);
_outputArray = typedAttribute.create("outputArray", "out", MFnData::kMesh);
typedAttribute.setArray(true);
typedAttribute.setWritable(false);
typedAttribute.setStorable(false);
addAttribute(_inputArray);
addAttribute(_outputArray);
return MS::kSuccess;
}
And here's my setDependentsDirty implementation (although it should not be the problem since it is not called at all):
MStatus TestArrayPlugsNode::setDependentsDirty(const MPlug& plug, MPlugArray& affectedPlugs)
{
std::cout << "setDependentsDirty(" << plug.name() << ")" << std::endl;
if (plug.attribute() == _inputMesh)
{
MPlug outputArrayPlug(thisMObject(), _outputArray);
MPlug outputArrayElemPlug = outputArrayPlug.elementByLogicalIndex(plug.parent().logicalIndex());
affectedPlugs.append(outputArrayElemPlug);
}
else
{
return MPxDeformerNode::setDependentsDirty(plug, affectedPlugs);
}
return MS::kSuccess;
}
Thanks,