My question is slightly off topic to this thread but motivated by the 
posted code sample...

I was under the impression that *setDependentsDirty* can be called any 
number of times with different arguments before *compute* is called (if 
ever). This would mean that storage of *m_element_index* (or caching of 
*any* information from *setDependentsDirty*) would need to store more than 
just the one call.  This could be solved by making *m_element_index* an 
array of cached values and *compute* handling all of them.  Is this right?

Rob

On Saturday, March 17, 2018 at 7:03:16 AM UTC-7, justin hidair wrote:
>
>  
>
> */*in the boolean flag case :*
>
> *lets say aDistance and aAmount are both child of a compound in an array 
> of compound*/*
>
> MStatus *myclass::setDependentsDirty*(const MPlug &plug, MPlugArray &
> affect)
>
> {
>
>                 mayastream << "dirtying. .." << "\n";
>
>  
>
>         if(plug.*isChild*() && plug.*attribute*() == aDistance )
>
>         {
>
>                 e_distance_change= true ;
>
>                 */*get index to target this attribute specifically will 
> be*
>
> *                useful with MArrayDataHandle*/*
>
>                 m_element_idx = plug.*parent*().*logicalIndex*();
>
>         }
>
>         else
>
>         if(plug.*isChild*() && plug.*attribute*() == aAmount )
>
>         {
>
>                 
>
>                 e_amount_change= true ;
>
>                 */*get index to target this attribute specifically will 
> be*
>
> *                useful with MArrayDataHandle*/*
>
>                 m_element_idx = plug.*parent*().*logicalIndex*();
>
>         }
>
>  
>
>     return *MPxNode::setDependentsDirty*(plug , affect );
>
>     
>
> }
>
> MStatus *myclass::compute*(...)
>
> {
>
>     *//typical moves:*
>
>     cmp_array = datablock.*inputArrayValue*(aArray);
>
>     if( e_distance_change == true )
>
>     {
>
>     */*    perform targeted calculations*
>
> *            use cmp_array.jumpToElement(m_element_idx)*/*
>
>     }
>
>     else
>
>     if(e_amount_change == true )
>
>     {
>
>         */*perform targeted calculations*
>
> *            use cmp_array.jumpToElement(m_element_idx)*/*
>
>  
>
>     }
>
> *//...*
>
> }
>
>  
>
> */*in the use Plug case :*
>
> *lets say aDistance and aAmount are both child of a compound in an array 
> of compound*/*
>
> MStatus *myclass::setDependentsDirty*(const MPlug &plug, MPlugArray &
> affect)
>
> {
>
>                 mayastream << "dirtying. .." << "\n";
>
>  
>
>         m_dirty_plug = plug;     
>
>                 */*just one line and we can use the plug however we want*
>
> *                the benefit is we also have all the methods of MPlug*
>
> *                like .isConnected and so on , aslong as the method stay ) 
> const *
>
> *                we can use it in compute without a problem...*
>
> *                we can use this to get index in array : *
>
> *                m_dirty_plug.parent().logicalIndex();*
>
> *                now to compute() ... */*
>
>  
>
>     return *MPxNode::setDependentsDirty*(plug , affect );
>
>     
>
> }
>
> MStatus *myclass::compute*(...)
>
> {
>
>     *//things I never saw:*
>
>     cmp_array = datablock.*inputArrayValue*(aArray);
>
>     if(m_dirty_plug.*isChild*() && m_dirty_plug.*attribute*() == 
> aDistance )  
>
>     {
>
>         */*perform targeted calculations*
>
> *        use all the cool const methods of MPlug*
>
> *        use 
> cmp_array.jumpToElement(m_dirty_plug.parent().logicalIndex())*/*
>
>     }
>
>     else
>
>     if(m_dirty_plug.*isChild*() && m_dirty_plug.*attribute*() == aAmount)
>
>     {
>
>         */*perform targeted calculations*
>
> *        use all the cool const methods of MPlug*
>
> *        use 
> cmp_array.jumpToElement(m_dirty_plug.parent().logicalIndex())*/*
>
>  
>
>     }
>
>     */*...*
>
> *    optionnaly at the end you can if you want reset  m_dirty_plug with *
>
> *    m_dirty_plug.setMObject(MObject::kNullObj) but it's not really 
> required because it*
>
> *    will be reassigned ... it allow to use .isNull() in particular cases 
> tho*
>
> *    lot of things you can do with just a plug instead of 4 boolean flags, 
> it's also *
>
> *    way easier to maintain*/*
>
> }
>
>  
>
>  
>

-- 
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 python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/07e1f6bd-6c6e-4225-8d2f-6c85e758676a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to