[Closed] Open Curve editor – CA evaluations
Greetings
Finally have a bit of a free day (head office is in the UK, so no one is looking with the wedding going on) and am trying to get to the bottom of how and why my script controllers on Custom attributes are evaluated so many times when opening the curve editor.
The example i’m looking at is as follows.
A custom attribute on a helper object in my scene has a bit of math in it which evaluates to a float… when called externally once per frame, this math takes 144ms to execute for 394 frames. Works great on timechange, and transform callbacks etc… yay! However it takes something like 2 seconds to draw the resultant curve in the curve editor when viewing the CA. (the second derivative takes 16 seconds, just to open the curve)
I thought even with sub-frame evaluations, it was taking a bit long…
The code in the CA is basically a single function which takes the current frame as a parameter… ‘doStuff F’ and returns a result.
So, out of interest I thought I’d see how often the script controller is evaluating in a rather brute force kind of way… i added the line ‘print F’ and dumped the results into excel.
I was rather supprised. For 394 frames of animation (configured for 10fps):
with realtime selected in time configuration, F was printed 38,068 times.
The value of F ranged from -18.8937 to 414.522.
Between one whole frame and the next there are 12 sub frames. (every 40 ticks?)
i.e. F= 0,.08,.16,.25,.33,.41,.5,.59,.66,.75,.83,.91
each of these was printed 8 times!
The out of range values appeared once each, so can be ignored (though interesting as a seperate point)
with reltime disabled, F was printed 23,878 times, with 12 sub frames, but only repeated 5 times each… (similar out of range values as well)
In typical use of my plugin, speed of evaluation is fine, except when opening /using the curve editor (the resultant graphs can be handy as an animation reference at times). I’m wondering how I might start improving this in particular. Several of these scripted controlelrs have nodes assigned (some to themselves) and i’m wondering if this might cause extraneous evaluations?
I’m going to have a play in replacing some with weak references, removing, etc… and will post results if i come to some conclusion…
Has anyone else taken a really close look at this sort of thing?
Cheers
Mikie
… more info for anyone following along…
I kept getting fairly random results with various combinations of replacing node references with constants, test values, etc in my CAs… but for the life of me i could not find a pattern to how often 2011 was recalculating the track… it would recalc every 40ms, between 3 and 12 times… at one point it was printing F 132000 times to the listener (and that was with extra node references removed)
So i repeated this test with 3ds max 2012 (which i havn’t had time to look at prior to this) , and the difference was unbelievable… for 394 frames, the new trackview only called the funciton 286 times…
It runs BLISTERINGLY fast!
ummm… one slight problem… and i saw this with 2010 as well…
The vertical scale for the CA in the trackview resets to 0-100 every time the view is opened or the track is selected… and there seems to be no way to get the whole curve to display… not sure how to fix that, and it’s a bit of a deal breaker…
any thoughts?