|
![](/i/fill.gif) |
ABX <abx### [at] abx art pl> wrote in
news:plu4bv0oq60qq73fv6d6fj75gbbidtvh4d@4ax.com:
> On Fri, 02 May 2003 15:51:59 +0200, Mark Weyer
> <wey### [at] informatik uni-freiburg de> wrote:
>> I might get killed for proposing something so inefficient
>
> Inefficent indeed. First of all there is a limited number of tokens to
> be used in one function. You can split function into subfunctions but
> number of constants used in functions is also limited in whole scene.
> Maps are also limited in size IIRC, but their number in scenes is not
> so limited I think. Moreover evaluation of function even if done with
> JIT compiler seems not as fast as precompiled code of map evaluation.
> But measurement and comparison could be interesting and (who knows?)
> perhaps surprised.
I have not done the test you describe here, but I
have done another related test.
A couple of months ago I made the macro below just
to test if evaluation of such an "array" function
could be faster than the look-up of a array item
in "ordinary" arrays.
IIRC the evaluation at parse time of this macro
generated function was actually slower =(
On my todo list was also to test if "abuse" of
spline functions will give any speed increase.
(I.e. storing points in them and only pass para-
meter values to the functions that will
reference those points directly.)
Tor Olav
#macro Coord2DFunction(Points, v0)
#local SizeU = dimension_size(Points, 1);
#local SizeV = dimension_size(Points, 2);
function(u, v) {
#local U = 0;
#while (U < SizeU)
#local V = 0;
#while (V < SizeV)
#local Value = vdot(Points[U][V], v0);
+select(u - U, 0, 1, 0)*select(v - V, 0, 1, 0)*Value
#local V = V + 1;
#end // while
#local U = U + 1;
#end // while
}
#end // macro Coord2DFunction
Example usage:
#declare SomePoints =
array[5][4] {
{ < 0, 0, 2>, < 1, 0, 0>, < 2, 0, 1>, < 3, 0, 2> },
{ < 0, 1, -2>, < 1, 1, -2>, < 2, 1, -4>, < 3, 1, -4> },
{ < 0, 2, 1>, < 1, 2, -3>, < 2, 2, -1>, < 3, 2, 4> },
{ < 0, 3, 0>, < 1, 3, 0>, < 2, 3, 0>, < 3, 3, -4> },
{ < 0, 4, -3>, < 1, 4, 3>, < 2, 4, -3>, < 3, 4, -2> }
}
#declare xFn = Coord2DFunction(SomePoints, x)
#declare yFn = Coord2DFunction(SomePoints, y)
#declare zFn = Coord2DFunction(SomePoints, z)
sphere { <xFn(2, 3), yFn(2, 3), zFn(2, 3)>, 0.1 }
This should give the same result as:
sphere { SomePoints[2][3], 0.1 }
or:
sphere { <3, 2, 4>, 0.1 }
Post a reply to this message
|
![](/i/fill.gif) |