|
|
Skiba <abx### [at] babilonorg> wrote:
> #declare MyFunc=function(x,y,z){
> #local A=x+y+z;
> #local B=max3(x,y,z);
> (A*x/B)+(A*y/B)+(A*z/B)
> } // I don't know what's this expression feel free to test
>
> this can't work, but you can replace this with two declarations
>
> #declare WithLocals=function(x,y,z,A,B){
> (A*x/B)+(A*y/B)+(A*z/B)
> }
> #declare MyFunc=function(x,y,z){WithLocals(x,y,z,x+y+z,max3(x,y,z))}
>
> I don't know 3.5 engine yet but I think it causes one calculation of
> such local variables.
While this should work, I would only recommend it for really complex cases
(more than 20 or so operators) because function calls are in many cases more
"expensive" than just calculating the value over and over again (which can
be optimised, btw).
Thorsten
____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: tho### [at] trfde
Visit POV-Ray on the web: http://mac.povray.org
Post a reply to this message
|
|