|
|
I'm working on a method of making cloth, and I posted a version of it in
.binaries.animations, but now I'm trying to make it faster. I used to have
this statement
#declare Unstretched = sqrt(pow(k*Normal_Length,2) +
pow(l*Normal_Length,2));
which is evaluated 24*16*16*4 times for each frame. Since Unstretched really
can have only five values, I thought I should precompute them and use a
#switch statement to choose, so I changed that line for the following:
#switch (abs(k) + abs(l))
#case (1) #declare Unstretched = Unstretched1; #break
#case (2)
#if ((k=0) | (l=0))
#declare Unstretched = Unstretched3;
#else
#declare Unstretched = Unstretched2;
#end
#break
#case (3) #declare Unstretched = Unstretched5; #break
#case (4) #declare Unstretched = Unstretched4; #break
#end
but it seems like that *increased* the parse time by about 50%. I thought
that just picking a precomputed value would be faster than calculating
Pythagoras' theorem. Did I do something wrong, or is #switch really that
slow?
--
Martin Magnusson
e-mail: Mar### [at] studentuuse
www-site: http://www.geocities.com/SoHo/9946/
Post a reply to this message
|
|