Im not angry
. im just trying to point out thet thers good and bad benchmarks, this is worse than a awfull one.
Offourse it does not demonstrate anything! Nobody would do it thet way in mel. teyd call a orient constraint and be done with it. But sure theres alott of stuff where you can do a million times or more speed preformance if you choose the example BADLY.
I mean takaing somemthing stupid to demonstrate the speed difference is well just a show that you can equaly well do inefficient mel code. Its like comparing two garphics cards with a porgram whan the other has test platform optimized drivers and the other does not. Does this mean its fater just because it got fatser benchmarks? No!
I think people have a huge misunderstanding about what mel is. But that aside i do think the question is CAN it be done efficently with mel. Yes, you can you just do a aim contraint in mel and viola it updates at api speeds! NO question about it.
SO could i do it in mel? Yes! Is it mel thats doing the stuff? No, maya is. So how long did it take for you to do code for this in api? Some doing this in mel stepping thru time is 4-8 lines of code, and works granttedly right and is fast.
NOW id say you realy cant get faster than the constraint
, unless i knew for a fact that if you wanted to bake out the solution there is a fater way than stepping thru time like you do! its kindof a special case and it gets easily slower if theeres a animated hierarchy underneath tough. What you do is you fetch the anim of the target as anim curves then Interpolate them isnide yoru own code for the aim. Or even better if the keys are sparse do a full mathamatical solve on this.
Se heres the mel to create this!
CODE
{
$aim=polyCone -n aim -r 1 -h 2 -sx 20 -sy 1 -sz 0 -ax 0 1 0 -tx 1 -ch 1
;
$target=sphere -n target -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
;
aimConstraint -offset 0 0 0 -weight 1 -aimVector 0 1 0 -upVector 1 0 0 -worldUpType "vector" -worldUpVector 0 1 0 $target[0] $aim[0];
}
Point out here theres nothing not mel here ist just that again mel is not the kind of normal do this language in this sense.
Now baking it out you could just run (i wouldnt):
CODE
bakeResults -simulation true -t "0:1000000" -sampleBy 1 -disableImplicitControl true -preserveOutsideKeys true -sparseAnimCurveBake false -at "rx" -at "ry" -at "rz" aim;
Now youd get a awfull speed! because maya would evaluate the ogl (wich in it self takes time and so if you have synchronized output you couldnt exceed the refres rate or even pert of it)! but you can squish even more speed out of this. this is a dirty way of doing it theres a more elegant one but its one line more code
So lets optimize
(lets insert atimer too so we knwo how slow it is):
CODE
$startTime = timerX
;
setNamedPanelLayout "Single Perspective View";
outlinerPanel -e -rp modelPanel4 outlinerPanel1;
bakeResults -simulation true -t "0:1000000" -sampleBy 1 -disableImplicitControl true -preserveOutsideKeys true -sparseAnimCurveBake false -at "rx" -at "ry" -at "rz" aim;
$totalTime = timerX -startTime $startTime
;
print ("Total Time: "+$totalTime+"\n");
Conclusion
Anyway i timed how long it took me to bake out this for million frames of motion now i got 153.34 seconds (about 2 half minutes). bear in mind tough that million frames is 700 hours worth of finalized film frames so if you routinely bake this kind of stuff out it takes 0.43 seconds to bake out for a entire feature film. NOT much is it? okay unfair it took some time to generate the geoa too. Under 0.1 seconds (note i could habve disabled the ogl for this too! for more speed.).
So i generated my mel in 3 minutes ( or cut and pasted the vcode realy and wrote this post but didnt spellchek it, becaus ei dont realy have time). just compiling and loading it in to maya probably takes longer in api and for what? youd se the benefit if you routinely doiid thsi in movies for say once every day for a moth!!!!
Now is this benchmark good! HELL NO it only eveluates a few measly anim curves!
QED
Any questions?
PS. nice defense Rob much appriciated... i think i went overboard demontarting this! Dont you 