if (accumulator >= test)into
{
accumulator -= test;
x += stepx;
}
int subtract = accumulator - test;Magic! No conditionals! You might use something like this if you're working on a REAL inner-loop, such as code that'll run on a GPU or likewise run many times on a mobile or handheld CPU.
int hibit = 1 - (subtract >> 31) & 1;
accumulator -= test * hibit;
x += stepx * hibit;
No comments:
Post a Comment