Skip to content

Commit

Permalink
Optimize: Use native math function in bamsAtan2()
Browse files Browse the repository at this point in the history
It seems that manually calculating the value using LUTs is not the most
efficient solution any more.
  • Loading branch information
skyjake committed Sep 12, 2012
1 parent 10a288a commit cf51c4f
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions doomsday/engine/portable/src/m_bams.c
Expand Up @@ -57,6 +57,7 @@ static binangle_t atantable[BAMS_TABLE_ACCURACY];

// CODE --------------------------------------------------------------------

#ifdef DENG_BAMS_TABLE_ATAN2
/**
* Fills the BAM LUTs.
*/
Expand Down Expand Up @@ -119,3 +120,17 @@ binangle_t bamsAtan2(int y, int x)
// This is the final angle.
return bang;
}

#else // using native floating point atan2

void bamsInit(void)
{
// nothing to do
}

binangle_t bamsAtan2(int y, int x)
{
float rad = atan2f((float) y, (float) x);
return RAD2BANG(rad);
}
#endif

0 comments on commit cf51c4f

Please sign in to comment.