This topic is now archived and is closed to further replies.


quick math

Recommended Posts

Can somebody give me an idea as to how someone, like me, a newbie, might go about making certain math functions faster -- just an idea of how to do this. At first I was thinking using Assembly, but I wonderred if I was missing something. How quick can assembly really make certain math functions anyway? Thanks for your help, L-

Share this post

Link to post
Share on other sites
what are the math function you are trying to optimize? the functions in Math.h are already about as optimized as they are likely to get.

are you just looking to optimize your game code? if so, the bottle-necks are not likely to be math functions. game bottlenecks are usually in the way you draw polygons, are you using BSP trees to cut down on the number of objects sent to the card for render? are you doing as much drawing as possible with z-buffering turned off?

a good optimization is to minimize the number of divides that you do. if you have code like this:

poo = variable / x;
log = another / x;
dongle = yourmom / x;

it's better to do:

oneOverX = 1/x;

poo = variable * oneOverX;
log = another * oneOverX;
dongle = yourmom * oneOverX;

a good compiler should already optimize the math fctns for you, i doubt you'll gain much by going to assembler to fix things. the bigger gains will be got by restructuring your code.


[edited by - Palidine on July 15, 2002 2:40:44 PM]

Share this post

Link to post
Share on other sites