Community
Maya Programming
Welcome to Autodesk’s Maya Forums. Share your knowledge, ask questions, and explore popular Maya SDK topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MPxFieldNode: accessing connected particle systems PP attributes in ::compute()

0 REPLIES 0
Reply
Message 1 of 1
smaraux
216 Views, 0 Replies

MPxFieldNode: accessing connected particle systems PP attributes in ::compute()

Hello all,

 

I am working on a custom field written with the Maya C++ API, inheriting from MPxFieldNode.

This field may have several particle systems plugged.

 

Brief version :

Is there any mean of accessing PP Attributes of *all* connected particle systems from MPxFieldNode::compute(), without causing their evaluation ?

 

Long version : 

As a requirement to use some third party code, I need to know the total count of particles, aka, sum of all connected particle systems' particles count, + some pp attributes values, in order to allocate arrays of objects

 

This allocation should occur :

- in the first MPxFieldNode::compute call (We keep trace of current frame to avoid reiniting several times for several particle systems) to prepare arrays to be written.

- in the same frame I must be able to write data to these arrays. 

I cannot allocate an array per particle system (third party code constraint), I need one array for all connected particles.

 

The issue : in the first compute, triggered by the first particle system, I'll try to access others particles plugged to crowdField, causing their evaluation. That generates a dependency loop, when building some MFnParticleSystem with connected objects.

 

I also tried accessing data through MDataBlock, but I can't manage to access pp attributes that way (let's say, lifespan for example) : mInputPPData seems to be used only for fieldName_attributeName data so its array is empty, mOwnerPPData does not give any attribute either. Moreover depending on how I fetch these arrays:

- as inputArrayValue, evalulations are requested on other particle systems

- as outputArrayValue, there is no evaluation but only particle system currently computed is accessible, access to others will crash.

 

Adding a re-entrance guard in the MPxFieldNode::compute can skip other particle systems compute() processing when counting particles, but does also tag them as 'clean", preventing them from calling their MPxFieldNode::compute at right time (field init for a particle system is done on a specific frame, which will be past at next call).

 

Is there any mean of accessing PP Attributes of *all* connected particle systems from MPxFieldNode::compute(), without causing their evaluation ?

 

Thank you for reading

 

 

0 REPLIES 0

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums