Page 1 of 1

Fast sin/cos

Posted: Tue Jun 05, 2012 4:51 pm
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
}