22 #define DEG2RAD( a ) ( a * M_PI ) / 180.0F
29 #pragma optimize( "", off )
61 memcpy( im, m,
sizeof( im ) );
70 memset( zrot, 0,
sizeof( zrot ) );
71 zrot[0][0] = zrot[1][1] = zrot[2][2] = 1.0F;
73 zrot[0][0] = cos(
DEG2RAD( degrees ) );
74 zrot[0][1] = sin(
DEG2RAD( degrees ) );
75 zrot[1][0] = -sin(
DEG2RAD( degrees ) );
76 zrot[1][1] = cos(
DEG2RAD( degrees ) );
81 for (
i = 0;
i < 3;
i++ )
83 dst[
i] = rot[
i][0] * point[0] + rot[
i][1] * point[1] + rot[
i][2] * point[2];
88 #pragma optimize( "", on )
96 static float sr, sp, sy, cr, cp, cy;
117 right[0] = (-1*sr*sp*cy+-1*cr*-sy);
118 right[1] = (-1*sr*sp*sy+-1*cr*cy);
123 up[0] = (cr*sp*cy+-sr*-sy);
124 up[1] = (cr*sp*sy+-sr*cy);
136 inv_denom = 1.0F /
DotProduct( normal, normal );
140 n[0] = normal[0] * inv_denom;
141 n[1] = normal[1] * inv_denom;
142 n[2] = normal[2] * inv_denom;
144 dst[0] = p[0] - d * n[0];
145 dst[1] = p[1] - d * n[1];
146 dst[2] = p[2] - d * n[2];
156 float minelem = 1.0F;
162 for ( pos = 0,
i = 0;
i < 3;
i++ )
164 if ( fabs( src[
i] ) < minelem )
167 minelem = fabs( src[
i] );
170 tempvec[0] = tempvec[1] = tempvec[2] = 0.0F;
193 out[0][0] = in1[0][0] * in2[0][0] + in1[0][1] * in2[1][0] +
194 in1[0][2] * in2[2][0];
195 out[0][1] = in1[0][0] * in2[0][1] + in1[0][1] * in2[1][1] +
196 in1[0][2] * in2[2][1];
197 out[0][2] = in1[0][0] * in2[0][2] + in1[0][1] * in2[1][2] +
198 in1[0][2] * in2[2][2];
199 out[1][0] = in1[1][0] * in2[0][0] + in1[1][1] * in2[1][0] +
200 in1[1][2] * in2[2][0];
201 out[1][1] = in1[1][0] * in2[0][1] + in1[1][1] * in2[1][1] +
202 in1[1][2] * in2[2][1];
203 out[1][2] = in1[1][0] * in2[0][2] + in1[1][1] * in2[1][2] +
204 in1[1][2] * in2[2][2];
205 out[2][0] = in1[2][0] * in2[0][0] + in1[2][1] * in2[1][0] +
206 in1[2][2] * in2[2][0];
207 out[2][1] = in1[2][0] * in2[0][1] + in1[2][1] * in2[1][1] +
208 in1[2][2] * in2[2][1];
209 out[2][2] = in1[2][0] * in2[0][2] + in1[2][1] * in2[1][2] +
210 in1[2][2] * in2[2][2];
221 out[0][0] = in1[0][0] * in2[0][0] + in1[0][1] * in2[1][0] +
222 in1[0][2] * in2[2][0];
223 out[0][1] = in1[0][0] * in2[0][1] + in1[0][1] * in2[1][1] +
224 in1[0][2] * in2[2][1];
225 out[0][2] = in1[0][0] * in2[0][2] + in1[0][1] * in2[1][2] +
226 in1[0][2] * in2[2][2];
227 out[0][3] = in1[0][0] * in2[0][3] + in1[0][1] * in2[1][3] +
228 in1[0][2] * in2[2][3] + in1[0][3];
229 out[1][0] = in1[1][0] * in2[0][0] + in1[1][1] * in2[1][0] +
230 in1[1][2] * in2[2][0];
231 out[1][1] = in1[1][0] * in2[0][1] + in1[1][1] * in2[1][1] +
232 in1[1][2] * in2[2][1];
233 out[1][2] = in1[1][0] * in2[0][2] + in1[1][1] * in2[1][2] +
234 in1[1][2] * in2[2][2];
235 out[1][3] = in1[1][0] * in2[0][3] + in1[1][1] * in2[1][3] +
236 in1[1][2] * in2[2][3] + in1[1][3];
237 out[2][0] = in1[2][0] * in2[0][0] + in1[2][1] * in2[1][0] +
238 in1[2][2] * in2[2][0];
239 out[2][1] = in1[2][0] * in2[0][1] + in1[2][1] * in2[1][1] +
240 in1[2][2] * in2[2][1];
241 out[2][2] = in1[2][0] * in2[0][2] + in1[2][1] * in2[1][2] +
242 in1[2][2] * in2[2][2];
243 out[2][3] = in1[2][0] * in2[0][3] + in1[2][1] * in2[1][3] +
244 in1[2][2] * in2[2][3] + in1[2][3];
258 int tmp = * (
int * ) &f;
260 return * (
float * ) &tmp;
264 #if defined _M_IX86 && !defined C_ONLY
265 #pragma warning (disable:4035)
266 __declspec( naked )
long Q_ftol(
float f )
269 __asm fld dword ptr [esp+4]
274 #pragma warning (default:4035)
289 return a2 + frac * (a1 - a2);
297 a -= 360*(
int)(a/360);
299 a += 360*( 1 + (
int)(-a/360) );
301 a = (360.0/65536) * ((
int)(a*(65536/360.0)) & 65535);
317 for (
i=0 ;
i<3 ;
i++)
348 #if !id386 || defined __linux__
406 if (dist1 >= p->
dist)
411 assert( sides != 0 );
416 #pragma warning( disable: 4035 )
420 static int bops_initialized;
421 static int Ljmptab[8];
427 cmp bops_initialized, 1
429 mov bops_initialized, 1
431 mov Ljmptab[0*4], offset Lcase0
432 mov Ljmptab[1*4], offset Lcase1
433 mov Ljmptab[2*4], offset Lcase2
434 mov Ljmptab[3*4], offset Lcase3
435 mov Ljmptab[4*4], offset Lcase4
436 mov Ljmptab[5*4], offset Lcase5
437 mov Ljmptab[6*4], offset Lcase6
438 mov Ljmptab[7*4], offset Lcase7
442 mov edx,ds:dword ptr[4+12+esp]
443 mov ecx,ds:dword ptr[4+4+esp]
445 mov ebx,ds:dword ptr[4+8+esp]
446 mov
al,ds:
byte ptr[17+edx]
449 fld ds:dword ptr[0+edx]
451 jmp dword ptr[Ljmptab+eax*4]
453 fmul ds:dword ptr[ebx]
454 fld ds:dword ptr[0+4+edx]
456 fmul ds:dword ptr[ecx]
459 fmul ds:dword ptr[4+ebx]
460 fld ds:dword ptr[0+8+edx]
462 fmul ds:dword ptr[4+ecx]
465 fmul ds:dword ptr[8+ebx]
468 fmul ds:dword ptr[8+ecx]
475 fmul ds:dword ptr[ecx]
476 fld ds:dword ptr[0+4+edx]
478 fmul ds:dword ptr[ebx]
481 fmul ds:dword ptr[4+ebx]
482 fld ds:dword ptr[0+8+edx]
484 fmul ds:dword ptr[4+ecx]
487 fmul ds:dword ptr[8+ebx]
490 fmul ds:dword ptr[8+ecx]
497 fmul ds:dword ptr[ebx]
498 fld ds:dword ptr[0+4+edx]
500 fmul ds:dword ptr[ecx]
503 fmul ds:dword ptr[4+ecx]
504 fld ds:dword ptr[0+8+edx]
506 fmul ds:dword ptr[4+ebx]
509 fmul ds:dword ptr[8+ebx]
512 fmul ds:dword ptr[8+ecx]
519 fmul ds:dword ptr[ecx]
520 fld ds:dword ptr[0+4+edx]
522 fmul ds:dword ptr[ebx]
525 fmul ds:dword ptr[4+ecx]
526 fld ds:dword ptr[0+8+edx]
528 fmul ds:dword ptr[4+ebx]
531 fmul ds:dword ptr[8+ebx]
534 fmul ds:dword ptr[8+ecx]
541 fmul ds:dword ptr[ebx]
542 fld ds:dword ptr[0+4+edx]
544 fmul ds:dword ptr[ecx]
547 fmul ds:dword ptr[4+ebx]
548 fld ds:dword ptr[0+8+edx]
550 fmul ds:dword ptr[4+ecx]
553 fmul ds:dword ptr[8+ecx]
556 fmul ds:dword ptr[8+ebx]
563 fmul ds:dword ptr[ecx]
564 fld ds:dword ptr[0+4+edx]
566 fmul ds:dword ptr[ebx]
569 fmul ds:dword ptr[4+ebx]
570 fld ds:dword ptr[0+8+edx]
572 fmul ds:dword ptr[4+ecx]
575 fmul ds:dword ptr[8+ecx]
578 fmul ds:dword ptr[8+ebx]
585 fmul ds:dword ptr[ebx]
586 fld ds:dword ptr[0+4+edx]
588 fmul ds:dword ptr[ecx]
591 fmul ds:dword ptr[4+ecx]
592 fld ds:dword ptr[0+8+edx]
594 fmul ds:dword ptr[4+ebx]
597 fmul ds:dword ptr[8+ecx]
600 fmul ds:dword ptr[8+ebx]
607 fmul ds:dword ptr[ecx]
608 fld ds:dword ptr[0+4+edx]
610 fmul ds:dword ptr[ebx]
613 fmul ds:dword ptr[4+ecx]
614 fld ds:dword ptr[0+8+edx]
616 fmul ds:dword ptr[4+ebx]
619 fmul ds:dword ptr[8+ecx]
622 fmul ds:dword ptr[8+ebx]
629 fcomp ds:dword ptr[12+edx]
632 fcomp ds:dword ptr[12+edx]
647 #pragma warning( default: 4035 )
661 for (
i=0 ;
i<3 ;
i++)
683 float length, ilength;
685 length =
v[0]*
v[0] +
v[1]*
v[1] +
v[2]*
v[2];
686 length =
sqrt (length);
702 float length, ilength;
704 length =
v[0]*
v[0] +
v[1]*
v[1] +
v[2]*
v[2];
705 length =
sqrt (length);
710 out[0] =
v[0]*ilength;
711 out[1] =
v[1]*ilength;
712 out[2] =
v[2]*ilength;
721 vecc[0] = veca[0] + scale*vecb[0];
722 vecc[1] = veca[1] + scale*vecb[1];
723 vecc[2] = veca[2] + scale*vecb[2];
734 out[0] = veca[0]-vecb[0];
735 out[1] = veca[1]-vecb[1];
736 out[2] = veca[2]-vecb[2];
741 out[0] = veca[0]+vecb[0];
742 out[1] = veca[1]+vecb[1];
743 out[2] = veca[2]+vecb[2];
755 cross[0] =
v1[1]*
v2[2] -
v1[2]*
v2[1];
756 cross[1] =
v1[2]*
v2[0] -
v1[0]*
v2[2];
757 cross[2] =
v1[0]*
v2[1] -
v1[1]*
v2[0];
760 double sqrt(
double x);
768 for (
i=0 ;
i< 3 ;
i++)
770 length =
sqrt (length);
784 out[0] = in[0]*scale;
785 out[1] = in[1]*scale;
786 out[2] = in[2]*scale;
828 while (*in && *in !=
'.')
840 static char exten[8];
843 while (*in && *in !=
'.')
848 for (
i=0 ;
i<7 && *in ;
i++,in++)
863 s = in + strlen(in) - 1;
865 while (
s != in && *
s !=
'.')
868 for (s2 =
s ; s2 != in && *s2 !=
'/' ; s2--)
876 strncpy (out,s2+1,
s-s2);
892 s = in + strlen(in) - 1;
894 while (
s != in && *
s !=
'/')
897 strncpy (out,in,
s-in);
914 src = path + strlen(path) - 1;
916 while (*src !=
'/' && src != path)
923 strcat (path, extension);
976 return ((
int)b1<<24) + ((
int)b2<<16) + ((
int)b3<<8) + b4;
994 dat2.b[0] = dat1.b[3];
995 dat2.b[1] = dat1.b[2];
996 dat2.b[2] = dat1.b[1];
997 dat2.b[3] = dat1.b[0];
1013 byte swaptest[2] = {1,0};
1016 if ( *(
short *)swaptest == 1)
1053 static char string[1024];
1055 va_start (argptr,
format);
1056 vsnprintf (
string, 1024,
format, argptr);
1090 while ( (c = *data) <=
' ')
1101 if (c==
'/' && data[1] ==
'/')
1103 while (*data && *data !=
'\n')
1165 for (
i=
size-1 ;
i>0 ;
i-=4096)
1183 return _stricmp (s1, s2);
1185 return strcasecmp (s1, s2);
1204 if (c1 >=
'a' && c1 <=
'z')
1206 if (c2 >=
'a' && c2 <=
'z')
1227 char bigbuffer[0x10000];
1229 va_start (argptr,fmt);
1230 len = vsnprintf (bigbuffer,0x10000,fmt,argptr);
1234 strncpy (dest, bigbuffer,
size-1);
1256 static char value[2][512];
1258 static int valueindex;
1276 o =
value[valueindex];
1278 while (*
s !=
'\\' && *
s)
1286 if (!strcmp (key, pkey) )
1287 return value[valueindex];
1302 if (strstr (key,
"\\"))
1324 while (*
s !=
'\\' && *
s)
1332 if (!strcmp (key, pkey) )
1355 if (strstr (
s,
"\""))
1357 if (strstr (
s,
";"))
1368 if (strstr (key,
"\\") || strstr (
value,
"\\") )
1370 Com_Printf (
"Can't use keys or values with a \\\n");
1374 if (strstr (key,
";") )
1376 Com_Printf (
"Can't use keys or values with a semicolon\n");
1380 if (strstr (key,
"\"") || strstr (
value,
"\"") )
1382 Com_Printf (
"Can't use keys or values with a \"\n");
1388 Com_Printf (
"Keys and values must be < 64 characters.\n");
1397 if (strlen(newi) + strlen(
s) > maxsize)
1399 Com_Printf (
"Info string length exceeded\n");
1410 if (c >= 32 && c < 127)