PDA

View Full Version : Speed up a while loop


asah
11-14-2012, 07:29 PM
Hi,,

I write the following code in mel

$startFrame=`currentTime -q`;
int $currentFrame=$startFrame;
while($currentFrame !=0){
print ($currentFrame + ",,");
currentTime $currentFrame;
$currentFrame+=1;
if($currentFrame>471)
$currentFrame=0;
}
remaining code

-------------------------
and when apply this code , the character animation very slow in frames within while loop and when reach frame 0 start animated well

So, how speed up while loop (means between currentTime $currentFrame; in loop) or any other solution


plzzzzzzzz help me :(

zeroeffect
11-14-2012, 09:33 PM
Remove the print statement. This is an expensive operation and it is most likely slowing you down.

350fps with the print statement, 1100 fps without (on an empty scene).

f3rry
11-14-2012, 10:16 PM
Hi Chris,

How did you produced the time result from a script? Thanks

zeroeffect
11-14-2012, 11:05 PM
For the timing I just used the Frame Rate HUD (Display->Heads Up Display->Frame Rate). Not quite as fancy as a script but for playback performance it comes in handy.

asah
11-15-2012, 02:23 AM
Thanks for reply :)

I remove the print statement and also remove the if statement and make the while statement
while($currentFrame <= 471)
But the problem still exist :(

asah
11-15-2012, 03:44 AM
And why when remove currentTime statement within loop and apply the code when start animation like after write ---> playButtonForward;


$startFrame=`currentTime -q`;
int $currentFrame=$startFrame;
while($currentFrame <= 471)
{
$currentFrame+=1;
}

why the program does not enter the while loop , it perform the code after while immediately

Aikiman
11-16-2012, 12:13 AM
And why when remove currentTime statement within loop and apply the code when start animation like after write ---> playButtonForward;


$startFrame=`currentTime -q`;
int $currentFrame=$startFrame;
while($currentFrame <= 471)
{
$currentFrame+=1;
}

why the program does not enter the while loop , it perform the code after while immediately

How do you know it doesnt enter the while loop? Check it with a print $currentFrame inside loop to see.

CGTalk Moderation
11-16-2012, 12:13 AM
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.