Forum

Fast sin/cos

Post tutorials on how to do certain tasks within game or engine code here.

Moderator: InsideQC Admins

Fast sin/cos

Postby mh » Tue Jun 05, 2012 4:51 pm

Lots of places in Quake where both sin and cos of an angle are calculated together. This might work for you, it might not, it might get you more speed, it might not.
Code: Select all
__declspec (naked) void Q_sincos (float angradians, float *angsin, float *angcos)
{
   __asm fld dword ptr [esp + 4]
   __asm fsincos

   __asm mov ebx, [esp + 12]
   __asm fstp dword ptr [ebx]

   __asm mov ebx, [esp + 8]
   __asm fstp dword ptr [ebx]

   __asm ret
}
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
User avatar
mh
 
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am

Return to Programming Tutorials

Who is online

Users browsing this forum: No registered users and 1 guest