QUOTE(Ptb @ 09/30/08, 02:02 PM) [snapback]292567[/snapback]
(which is executed by scriptjob)?
Why n earth a scriptjob. (i mean a scriptjobb is the last tool id use for this) Dont use mel. (also NEVER step time ist slow just step the node)
Write a node. the anim curve is a picecevise smooth polynomial so yes you could actually do a elemantary solve of it quite fast. Tough i tested doing a anim a curve wich has a 10000 frames worth of data with random frames at keyframe every 5 frames stepping torugh all frames for pos takes a lot less tiem then you think if you do it right:
CODE
//suppose this scene;
file -f -new;
sphere -p 0 0 0 -ax 0 1 0 -ssw 0 -esw 360 -r 1 -d 3 -ut 0 -tol 0.01 -s 8 -nsp 4 -ch 1;
for ($i=0;$i<2000;$i++){
setKeyframe -time ($i*5) -value(rand(0,2)) "nurbsSphere1.ty";
}
CODE
createNode time;
connectAttr -f time2.outTime nurbsSphere1_translateY.input;
prepration.
CODE
//you need these line to calc
$thisSum=0;
for ($i=0;$i<10000;$i++){
setAttr time2.outTime $i;
$thisSum+=`getAttr nurbsSphere1\_translateY.output`;
}
print $thisSum;
takes less than a second on my secondary computer thats 3 years old.
this way its pretty fast (this is faster than stepping torugh global time), buy you can do it even faster by using a expression node but its considerably harder to maintain, also you can cache the bits your not calculating.
Also baking the result is slightly faster/as fast too as long as you run your own time to bake and d NOT update screen.
CODE
//preparation slightly different
createNode time;
connectAttr -f time2.outTime nurbsSphere1_translateY.input;
expression -s "global float $thisSum=0;\r\n$thisSum+=.I[0];.O[0]=$thisSum" -o time2 -ae 0 -uc all;
connectAttr -f nurbsSphere1_translateY.output expression1.input[0];
addAttr -ln "out" -at double |nurbsSphere1;
setAttr -e -keyable true |nurbsSphere1.out;
connectAttr -f expression1.output[0] nurbsSphere1.out;
//you need these line to calc
$thisSum=0;
bakeResults -simulation false -t "1:10000" -sampleBy 1 -sparseAnimCurveBake true -at "out" nurbsSphere1;
print ("Total Time: "+$totalTime+"\n");
this may get faster if you do not use the global var. and isntead use a nother conection slot.
Anyway a c++ node would be on order 10-50 times faster so youd be seeing. Anyway expecting some 1/10 of second to brutefrce the issue with mel in slightly unoptimal maya execution. Certainly if you store say 5-10 sections of values in array you only need to update one part of the array and now you are in 1/100 second wich is acceptable by most terms?
PS: this does not change the fact that animating like this si not entirely intuitive.