Lol I love these conversations , YES you are right this is something I didn’t
mentioned but In my real compute() I have something to verify that it is the
first compute ( it’s some truly used cached data not a collection of indices) ,
if it is , I simply do a complete computation it’s a bit like this :
if( myvector.size() == 0 )
{
//complete compute() , everything counts
}
else
if( myplug ==…)
{
//update cache , targeted compute
}
else( …)
this mechanism implies a lot of things so beware , for example if an output
attribute is disconnected and you have cached data , you need to override
MPxNode::connectionBroken(const MPlug&,…) to clear your cache , and set its
size back to zero while you are at it …
like this :
else
if (plug.attribute(MRTERR()) == a_output)
{
reset_cache();
}
Sent from Mail for Windows 10
From: Rob Engle
Sent: Saturday, March 17, 2018 9:55 PM
To: [email protected]
Subject: Re: [Maya-Python] Why most people use boolean flags
insteadofcatchingthe MPlug ?
Perhaps I am not being clear. setDependentsDirty could be called a bunch of
times, with different plugs (distance and amount) and different indices before
compute is ever called. That would mean the code in compute would only have
cached the results of the last call.
I understand the dependency graph evaluation to be: Step 1: propagate dirty
flags from changed attribute(s) to all dependent destinations. One attribute
change can cause numerous downstream attributes (possibly through different
array indices) to dirty. Step 2: determine which, and compute now-dirty
attributes needed to be evaluated (some attributes may have been dirtied but
don't affect drawing or any open attribute editors, for example). This implies
that, if you are caching info from calls to setDependentsDirty, you need to
cache all the calls, not just the last one.
In other words, I think "you only need to worry about one attribute change at a
time" is incorrect. You only need to worry about one attribute computation at
a time but, if you are storing information from setDependentsDirty, you can't
just cache the last call. What happens in your code if BOTH distance and
amount changed? What if they are coming from different indices?
What am I missing here?
thanks,
Rob
On Sat, Mar 17, 2018 at 12:59 PM, justin hidair <[email protected]> wrote:
Correct . However it is expensive(for a dev) to do it that way when you know
you can just use one unsigned int that get assigned in every call of
setdepdirty() , and it goes also with the fact that you only have to worry
about one attribute change at a time , and it is not necessary to store every
indices like that , the use of MArrayDataHandle::jumpToArrayElement() with
MArrayDataHandle::elementIndex() is a recommended combo to iterate over the
array of compounds/element even in the documentation , and you will need to
call MDataBlock::inputArrayValue() once you are in compute anyway so … this
m_element_index thing is just here so I know what element is tingling so that I
don’t have to do expensive complete calculations, it’s lazy evaluation if you
want
--
You received this message because you are subscribed to the Google Groups
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/CAFLHEW3eMe3eG_roRj3EbJu3NAruwYynRwRPnOSECYtAGCoR4g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/5aad91de.6882df0a.88e21.1375%40mx.google.com.
For more options, visit https://groups.google.com/d/optout.