vegastrike  0.5.1.r1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
fastmath.cpp File Reference
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

Go to the source code of this file.

Classes

union  FastSqrtUnion
 
struct  Vec3
 

Macros

#define FP_BITS(fp)   ( ( *(DWORD*) &(fp) ) )
 
#define FP_ABS_BITS(fp)   ( (FP_BITS( fp )&0x7FFFFFFF) )
 
#define FP_SIGN_BIT(fp)   ( (FP_BITS( fp )&0x80000000) )
 
#define FP_ONE_BITS   ( (0x3F800000) )
 
#define __forceinline   inline
 
#define FP_INV(r, p)
 
#define FP_INV2(r, p)
 
#define FP_EXP(e, p)
 
#define FP_NORM_TO_BYTE(i, p)
 

Typedefs

typedef int DWORD
 
typedef union FastSqrtUnion FastSqrtUnion
 

Functions

unsigned long FP_NORM_TO_BYTE2 (float p)
 
unsigned long FP_NORM_TO_BYTE3 (float p)
 
void build_sqrt_table ()
 
float fastsqrt (float n)
 
__forceinline void FloatToInt (int *int_pointer, float f)
 
int Stupodmain (int argc, char *argv[])
 
float CylTest_CapsFirst (const Vec3 &pt1, const Vec3 &pt2, float lengthsq, float radius_sq, const Vec3 &testpt)
 

Variables

float two = 2.0f
 

Macro Definition Documentation

#define __forceinline   inline

Definition at line 23 of file fastmath.cpp.

#define FP_ABS_BITS (   fp)    ( (FP_BITS( fp )&0x7FFFFFFF) )

Definition at line 20 of file fastmath.cpp.

#define FP_BITS (   fp)    ( ( *(DWORD*) &(fp) ) )

Definition at line 19 of file fastmath.cpp.

#define FP_EXP (   e,
 
)
Value:
do { \
int _i; \
e = -1.44269504f*(float) 0x00800000*(p); \
_i = (int) e+0x3F800000; \
e = *(float*) &_i; \
} \
while (0)

Definition at line 59 of file fastmath.cpp.

#define FP_INV (   r,
 
)
Value:
do { \
int _i = 2*FP_ONE_BITS-*(int*) &(p); \
r = *(float*) &_i; \
r = r*(2.0f-(p)*r); \
} \
while (0)

Definition at line 27 of file fastmath.cpp.

#define FP_INV2 (   r,
 
)
Value:
do { \
__asm {mov eax, 0x7F000000}; \
__asm {sub eax, dword ptr[p]}; \
__asm {mov dword ptr[r], eax}; \
__asm {fld dword ptr[p]}; \
__asm {fmul dword ptr[r]}; \
__asm {fsubr[two]}; \
__asm {fmul dword ptr[r]}; \
__asm {fstp dword ptr[r]}; \
} \
while (0)

Definition at line 44 of file fastmath.cpp.

#define FP_NORM_TO_BYTE (   i,
 
)
Value:
do { \
float _n = (p)+1.0f; \
i = *(int*) &_n; \
if (i >= 0x40000000) i = 0xFF; \
else if (i <= 0x3F800000) \
i = 0; \
else i = ( (i)>>15 )&0xFF; \
} \
while (0)

Definition at line 68 of file fastmath.cpp.

#define FP_ONE_BITS   ( (0x3F800000) )

Definition at line 22 of file fastmath.cpp.

#define FP_SIGN_BIT (   fp)    ( (FP_BITS( fp )&0x80000000) )

Definition at line 21 of file fastmath.cpp.

Typedef Documentation

typedef int DWORD

Definition at line 16 of file fastmath.cpp.

Function Documentation

void build_sqrt_table ( )

Definition at line 98 of file fastmath.cpp.

float CylTest_CapsFirst ( const Vec3 pt1,
const Vec3 pt2,
float  lengthsq,
float  radius_sq,
const Vec3 testpt 
)

Definition at line 197 of file fastmath.cpp.

float fastsqrt ( float  n)
inline

Definition at line 124 of file fastmath.cpp.

__forceinline void FloatToInt ( int *  int_pointer,
float  f 
)

Definition at line 136 of file fastmath.cpp.

unsigned long FP_NORM_TO_BYTE2 ( float  p)
inline

Definition at line 79 of file fastmath.cpp.

unsigned long FP_NORM_TO_BYTE3 ( float  p)
inline

Definition at line 85 of file fastmath.cpp.

int Stupodmain ( int  argc,
char *  argv[] 
)

Definition at line 141 of file fastmath.cpp.

Variable Documentation

float two = 2.0f

Definition at line 42 of file fastmath.cpp.