Setting plugs clean - MDataHandle.setClean() vs MDataBlock.setClean()

Setting plugs clean - MDataHandle.setClean() vs MDataBlock.setClean()

bradley_henke
Enthusiast Enthusiast
636 Views
0 Replies
Message 1 of 1

Setting plugs clean - MDataHandle.setClean() vs MDataBlock.setClean()

bradley_henke
Enthusiast
Enthusiast

It's a bit confusing to me how to properly set plugs clean in a compute method. 

 

I've created a node which computes outputTranslate, outputRotate, and outputScale attributes. Each of these attributes are arrays of compounds:

 

outputTranslate[0].outputTranslateX
outputTranslate[0].outputTranslateY
outputTranslate[0].outputTranslateZ

 

 

During compute, I will always be computing all elements of all three attributes (outTranslate, outRotate, outScale). However, I recently realized that my compute function is getting called 3 times, once for each attribute. I believe the reason for this is that the array plugs (outputTranslate, outputRotate, and outputScale), are not actually getting set clean; however, the element plugs are being set clean. The only way in which I have managed to set the root attribute plugs clean is using MDataBlock.setClean(attribute). 

 


 

This lead me to do some experimenting, and this is what I discovered:

Return MStatus::kSucess

When computing a plug, if I don't call MDataHandle.setClean() or MDataBlock.setClean(), then returning kSucess will clean an element plug when called. It will not clean an array plug.

 

MDataHandle.setClean(plug) and MDataHandle.setClean(attribute)

This will clean the element plug which was originally passed to compute, but it will not clean any other element plugs. For example, if compute was called with, "outputTranslate[0].outTranslate", then that plug will be set clean, but additionally cleaning "outputRotate[0].outRotate" with a MDataHandle seems to have no affect. If compute is called with the array plug "outputTranslate", then dataBlock.outputValue(outputTranslate).setClean(), does not clean the array plug.

 

MArrayDataHandle.setClean()

This is able to clean the element plugs, but I have no way of cleaning the array plug.

 

MDataBlock.setClean(plug)

This will clean element plugs, but it will not clean the array plug.

 

MDataBlock.setClean(attribute)

This is the ONLY way that I have found to actually clean the array plug.

 


 

Given these results, it seems like the only sure fire way to clean an array plug is using MDataBlock.setClean(MObject attribute). Am I missing something? Generally speaking, when should I being using the various forms of set clean?

  • MDataHandle.setClean(MPlug plug)
  • MDataHandle.setClean(MObject attribtue)
  • MDataBlock.setClean(MPlug plug)
  • MDataBlock.setClean(MObject attribute)

 

 

 

 

 

637 Views
0 Replies
Replies (0)