User:Monster Iestyn/Source Code Documentation/tables.h

From SRB2 Wiki
Jump to navigation Jump to search
This article or section is incomplete. It doesn't have all of the necessary core information on this topic. Please help the SRB2 Wiki by finishing this article.
Online link GitHub entry
File type C header file
#include guard __TABLES__

Includes

Externs

Data name Data type Non-extern location(s) Description
finesine[5*FINEANGLES/4] fixed_t t_fsin.c The fine angle-to-sine array used by FINESINE.
*finecosine fixed_t tables.c The fine angle-to-cosine array used by FINECOSINE. This is actually used as a pointer to &finesine[FINEANGLES/4], as it uses the same values as finesine but shifted.
finetangent[FINEANGLES/2] fixed_t t_ftan.c The fine angle-to-tangent array used by FINETANGENT.
tantoangle[SLOPERANGE+1] angle_t t_tan2a.c The tan/slope value-to-angle array.

The angle_t type

typedef UINT32 angle_t;
Macro Angle (degrees) Hexadecimal Decimal
ANG1 0x00B60B61 11930465
ANG2 0x016C16C1 23860929
ANG10 10º 0x071C71C7 119304647
ANG15 15º 0x0AAAAAAB 178956971
ANG20 20º 0x0E38E38E 238609294
ANG30 30º 0x15555555 357913941
ANG60 60º 0x2AAAAAAB 715827883
ANG64h 64.5º 0x2DDDDDDE 769514974
ANG105 105º 0x4AAAAAAB 1252698795
ANG210 210º 0x95555555 2505397589
ANG255 255º 0xB5555555 3042268501
ANG340 340º 0xF1C71C72 4056358002
ANG350 350º 0xF8E38E39 4175662649
Macro Angle (degrees) Hexadecimal Decimal
ANGLE_11hh 11.25º 0x08000000 134217728
ANGLE_22h 22.5º 0x10000000 268435456
ANGLE_45 45º 0x20000000 536870912
ANGLE_67h 67.5º 0x30000000 805306368
ANGLE_90 90º 0x40000000 1073741824
ANGLE_112h 112.5º 0x50000000 1342177280
ANGLE_135 135º 0x60000000 1610612736
ANGLE_157h 157.5º 0x70000000 1879048192
ANGLE_180 180º 0x80000000 2147483648
ANGLE_202h 202.5º 0x90000000 2415919104
ANGLE_225 225º 0xA0000000 2684354560
ANGLE_247h 247.5º 0xB0000000 2952790016
ANGLE_270 270º 0xC0000000 3221225472
ANGLE_292h 292.5º 0xD0000000 3489660928
ANGLE_315 315º 0xE0000000 3758096384
ANGLE_337h 337.5º 0xF0000000 4026531840
ANGLE_MAX ~360º 0xFFFFFFFF 4294967295

Fine angles

Macro Defined as Description
FINEANGLES 8192 The number of fine angles in a full circle.
FINEMASK FINEANGLES-1

(8191)

Used to limit integers representing fine angles to values between 0 and 8191.

e.g. x & FINEMASK

ANGLETOFINESHIFT 19 The number of bits to shift angle_t down to fine angles, or vice versa.
FINEANGLE_C(x)
((FixedAngle((x)*FRACUNIT)>>ANGLETOFINESHIFT) & FINEMASK)
Converts an angle in degrees to fine angles
FINE_FRACBITS 16 The number of fractional bits used by the tables' values in tables.c. This macro is used particularly by the trig function macro definitions in case FRACBITS is not 16.

Tangent (slope) values

Macro Defined as Description
SLOPERANGE 2048 The maximum value a slope value can have.
SLOPEBITS 11 The number of bits in a slope value.
DBITS FRACBITS-SLOPEBITS

(5)

The number of bits to shift fixed_t down to slope values, or vice versa.

Trigonometric function macros

Macro Defined as Description
FINESINE(n)
(finesine[n]>>(FINE_FRACBITS-FRACBITS))
Returns the sine of the given fine angle, as a fixed_t value
FINECOSINE(n)
(finecosine[n]>>(FINE_FRACBITS-FRACBITS))
Returns the cosine of the given fine angle, as a fixed_t value
FINETANGENT(n)
(finetangent[n]>>(FINE_FRACBITS-FRACBITS))
Returns the tangent (note: shifted forward by 90°) of the given fine angle, as a fixed_t value

Functions

Prototypes

Function name Return type Params Defined in Attributes Description
SlopeDiv unsigned unsigned num,
unsigned den
tables.c FUNCMATH
SlopeDivEx UINT64 unsigned int num,
unsigned int den
tables.c Only called by R_PointToAngleEx.
AngleFixed fixed_t angle_t af tables.c FUNCMATH
FixedAngle angle_t fixed_t fa tables.c FUNCMATH
FixedAngleC angle_t fixed_t fa,
fixed_t factor
tables.c FUNCMATH
FixedAcos angle_t fixed_t x tables.c FUNCMATH
Fixed point vector functions
FV2_AngleBetweenVectors angle_t const vector2_t *Vector1,
const vector2_t *Vector2
tables.c Returns the angle between two vectors
FV3_AngleBetweenVectors angle_t const vector3_t *Vector1,
const vector3_t *Vector2
tables.c Returns the angle between two vectors
FV2_InsidePolygon boolean const vector2_t *vIntersection,
const vector2_t *Poly,
const INT32 vertexCount
tables.c Checks if a point is inside a polygon
FV3_InsidePolygon boolean const vector3_t *vIntersection,
const vector3_t *Poly,
const INT32 vertexCount
tables.c Checks if a point is inside a polygon
FV3_IntersectedPolygon boolean const vector3_t *vPoly,
const vector3_t *vLine,
const INT32 vertexCount,
vector3_t *collisionPoint
tables.c Checks if a line is intersecting a polygon
FV3_Rotate void vector3_t *rotVec,
const vector3_t *axisVec,
const angle_t angle
tables.c Rotates a vector around another vector
Fixed point matrix functions
FM_Rotate void matrix_t *dest,
angle_t angle,
fixed_t x,
fixed_t y,
fixed_t z
tables.c

Inline functions

Function name Return type Params Attributes Description
InvAngle angle_t angle_t a FUNCMATH,
FUNCINLINE,
static,
ATTRINLINE