Kai Antweiler skrev:
Looks like you use a small Taylor polynomials for cos and calculate it using the
Horner scheme. I don't think this can be made faster.
Or could we use some discrete calculation for approximation?
2.
Instead of:
float val, amp = 1.0, sum = 0.0;
for ( int i = 0;i < oct;i++, amp *= 0.5, tp *= 2.0 ) {
val = Noise3d( f_tp );
if ( hard ) val = fabs( val );
sum += amp * val;
}
return 0.5 + 0.5*( sum * ( ( float ) ( 1 << oct ) / ( float ) ( ( 1
<< ( oct + 1 ) ) - 1 ) ) );
We could try:
float val, sum = 0.0;
for ( int i = 0;i < oct;i++, tp *= 2.0 ) {
val = Noise3d( f_tp );
if ( hard ) val = fabs( val );
sum += val / (float) (1<<i);
}
return 0.5 + 0.5*( sum * ( ( float ) ( 1 << oct ) / ( float ) ( ( 1
<< ( oct + 1 ) ) - 1 ) ) );
But that is probably worse.
It probably is - float->int and int->float conversions are expensive.
Keeping calculations in integers is usually way faster.
Hey why isn't there a thing like float-shift? After all this would
only require to add/subtract 1 from the exponent!
Well, there is such an instruction (FSCALE for x86); it doesn't seem
like gcc uses it though... Oo
3.
DynamicClouds.cpp:
vpX += (viewPortX-vpX%64+96)%64-32;
This might be faster using a mask:
vpX += (viewPortX-vpX&63+96)&63-32;
The compiler ought to figure this out for itself - at least for unsigned
values (for signed it makes two shifts instead).
/Erik
_______________________________________________
glob2-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/glob2-devel