Hey Jeremie,
What about only doing the recompute when your inputs change?
Can't remember what the function name was, but in one of the QFEs you could ask
an object or parameter for its evaluation id which is increased by Softimage
every time the parameter/object has changed - pretty sure that one made it into
2012/2013, but might only be accessible from C++. So as long as those ids don't
change, you can return the cached result..
Kai
On 08/02/2013, at 11:22 PM, Jeremie Passerin gerem@gmail.com wrote:
Hi list !
So here is a problem I'm facing every time I'm writing a Custom Operator with
multiple outputs.
As you know, operators are fully evaluated for each output.
In my case, there is a big chunk of the code that only needs to be evaluated
once per frame and I certainly don't want it to be evaluated for every output
as it affects drastically the performances.
My first problem is that Softimage doesn't always evaluate the output in the
same order... so here is my work around. I store the result the first time in
a data blob and then I count the number of time the operator has been called.
If it has been called more than the number of outputs, that means I need to
re-compute the result
function myOp_Update( ctxt, out ){
// Number of output I have
count = ctxt.Parameters(count).Value;
if ( ctxt.UserData == null || ctxt.UserData[0] = count )
{
outValues = Array(count);
// Do the big math
ctxt.UserData = [1, outValues];
}
// Output
ctxt.UserData[0] += 1;
out.Value = outValues[out.Index];
}
It seems to work most of the time but I still have some doubt that it's
working perfectly. It's difficult to exactly now when it happens but I'm
under the impression that I'm not always reevaluating it when I should.
Does any one do it differently ? Do we have a way to know when an operator is
called for the first time for a bunch of outputs ?
Thanks,
Jeremie