PDA

View Full Version : Please Help! API nightmare: forcing evaluation and custom data!!


playmesumch00ns
02-26-2003, 09:36 PM
HI, I've got a serious problem which is screwing with my plugin project. I sort of have two questions, so I'll ask them and then explain the reasoning:

1) Is it possible to force the re-evaluation of a node (i.e. make an MPxNode call compute()) when an input changes if it's got no connected outputs. What I mean is I have a (MPxNode-derived) rendering node that relies on a whole string of data inputs.
Now I want the rendering node's compute function to be called whenever I change the input data. The specifics of the inputs are an array of compound attributes, each of which consists of an input mesh and an array of custom MPxData-derived data objects.
The trouble is the bloody thing won't re-evaluate when the inputs change! I think it's because the node's outputs (I put a dummy one in just to see if it would work) aren't connected to anything, so pig-headed Maya doesn't see any reason to call compute()


2) Can I get at my custom data outside of a node's compute function (If I could do this, it would mean I wouldn't have to worry about 1 as 1 is a workaround). I mean it's trivial to get a pointer to the custom data objects via the data block in the compute function, but because I'm trying to get at it from inside a render callback, i don't have a data block to work with. I can get a plug from inside the callback, but if I try getting an MObject from that plug, it fails with the ever-helpful "Unexpected Internal Failure" result.


Ok, so explanation: I've got my rendering node, nprRender which is going to do some post-process rendering via a callback. The render node depends on the attributes listed in 1), which are the worldMesh output of a mesh node and an array of custom nprData data objects, which are passed in from a series of nprLayer nodes.

Now I can get hold of the mesh object fine from inside the callback using the plugs. But as far as I can see, the MPlug has nothing which lets me get at custom data. From the manuals, the only way I can see to get at custom data is from the data block passed to the compute function! Aaargh!

So my theoretical workaround was to grab the custom data from the nprRender node's compute method and stick it some arrays ready to be processed when the render callback is tripped. Obviously this isn't a perfect solution, but it's the only one i can think of, and the problem I've described in 1) now has me tearing my hair out!

If you've read this far, thanks!:beer: Please, if anyone's even got the faintest idea how I might resolve this, please tell me as this is driving me nuts!

playmesumch00ns
02-26-2003, 10:55 PM
please please please?

playmesumch00ns
02-27-2003, 09:36 AM
I don't like keeping threads afloat, but someone's got to know this!?:)

somlor
02-27-2003, 09:46 AM
This sounds like a question worthy of the Rendering Theory Listserver: http://www.highend3d.com/render/listserver/

:p

[s]

playmesumch00ns
02-27-2003, 09:48 AM
cheers, I hadn't tried there. Was just about to post on the highend dev archive, but not many people there!

svenip
02-27-2003, 10:45 AM
i have only began to program plugin, but as far as my understanding goes right now you can set depdencies. if the input attribute changes and the your output has a dependency to this input the compute function will be calles.

attributeAffects( inputAttr, outputAttr );

playmesumch00ns
02-27-2003, 04:43 PM
svenip: Thanks for the reply! I think I got this problem sorted now. I find Maya's DG evaluation a bit fernickety. In the manuals it says that Maya basically jumps through lots of algorithmic hoops to make sure it only evaluates when it absolutely needs to, but then doesn't really go on to explain how that affects your code:hmm:

I think what it was was that because I was using a compound attribute, I had to set dependencies from the children to the aprent of the compound. Seems to be working now anyway!

With regards getting access to the data block, I think I may have that one fixed as well. There's a function called MPxNode::forceCache() which should give me what I need. Thanks to the maya-dev list for that one!

svenip
02-28-2003, 06:50 AM
david has explained it very very well in his book how the dg evaluation is happening inside maya. it's this push-pull model.
but anyway, good to now with the compound attributes :)

AmateurOne
03-01-2003, 02:03 PM
Originally posted by svenip
david has explained it very very well in his book how the dg evaluation is happening inside maya. it's this push-pull model.
but anyway, good to now with the compound attributes :)

And the DG is a very interesting model--nonprocedural in very rough analogy to the OPS5 and CLIPS languages. Maya's use of the dirty-flag is very reminiscent of a feature of CLIPS internal evaluation structure. Anyway OPS5 and CLIPS are data driven languages. I think the DG evaluation method might be best described as parameter driven--time being the driving parameter. Be very glad to hear any comments pro or con on these observations.

wrend
03-02-2003, 06:50 AM
me too, bump.

CGTalk Moderation
01-14-2006, 12:00 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.