Fast sin/cos

Post tutorials on how to do certain tasks within game or engine code here.
Post Reply
mh
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am

Fast sin/cos

Post by mh »

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
Post Reply