Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
20 | pmbaty | 1 | #ifndef BR_DEFS_H |
2 | #define BR_DEFS_H |
||
3 | |||
4 | // Inspired by BRender SDK includes (https://rr2000.cwaboard.co.uk/R4/BRENDER/BRENDER.zip) |
||
5 | |||
6 | #include <math.h> // sqrtf |
||
7 | |||
8 | #define PI 3.14159265358979323846 |
||
9 | #define TAU 6.283185307179586 |
||
10 | |||
11 | #define BR_MAC3(a, b, c, d, e, f) ((a) * (b) + (c) * (d) + (e) * (f)) |
||
12 | #define BR_SQR3(a, b, c) ((a) * (a) + (b) * (b) + (c) * (c)) |
||
13 | |||
14 | #define BrAngleToRadian(a) ((br_scalar)((a) * (PI / 32768.0))) // a * 0.00009587379924285257 |
||
15 | #define BrRadianToAngle(r) ((br_angle)(long)((r) * (32768.0 / PI))) // r * 10430.378350470453 |
||
16 | |||
17 | #define BR_VECTOR3(a, b, c) \ |
||
18 | { a, b, c } |
||
19 | |||
20 | #define BR_VECTOR4(a, b, c, d) \ |
||
21 | { a, b, c, d } |
||
22 | |||
23 | #define BR_COLOUR_RGB(r, g, b) \ |
||
24 | ((((unsigned int)(r)) << 16) | (((unsigned int)(g)) << 8) | ((unsigned int)(b))) |
||
25 | |||
26 | #define BR_ALPHA(c) (((c) >> 24) & 0xFF) |
||
27 | |||
28 | #define BR_ANGLE_DEG(deg) ((br_angle)((deg)*182)) |
||
29 | #define BR_ANGLE_RAD(rad) ((br_angle)((rad)*10430)) |
||
30 | |||
31 | #define BrDegreeToRadian(d) ((br_scalar)((d) * (PI / 180.0))) |
||
32 | #define BrRadianToDegree(r) ((br_scalar)((r) * (180.0 / PI))) |
||
33 | |||
34 | #define BrDegreeToAngle(d) ((br_angle)(long)((d) * (65536.0f / 360.0f))) // "d * 182.044444444" |
||
35 | #define BrAngleToDegrees(a) ((br_angle)(long)((a) * (360.0f / 65536.0f))) // "d * 0.0054931640625" |
||
36 | |||
37 | #define BR_SCALAR(x) ((br_scalar)(x)) |
||
38 | |||
39 | #define BR_COLOUR_RGBA(r, g, b, a) \ |
||
40 | ((((unsigned int)(a)) << 24) | (((unsigned int)(r)) << 16) | (((unsigned int)(g)) << 8) | ((unsigned int)(b))) |
||
41 | |||
42 | #define BR_LENGTH2(a, b) ((br_scalar)sqrtf((a) * (a) + (b) * (b))) |
||
43 | #define BR_LENGTH3(a, b, c) ((br_scalar)sqrtf((a) * (a) + (b) * (b) + (c) * (c))) |
||
44 | #define BR_SCALAR_EPSILON 1.192092896e-7f |
||
45 | #define BR_SCALAR_MAX 3.402823466e+38f |
||
46 | #define BR_SCALAR_MIN (-3.402823466e+38f) |
||
47 | |||
48 | #define BR_SIMPLEHEAD(l) (void*)(((br_simple_list*)(l))->head) |
||
49 | #define BR_SIMPLENEXT(n) (void*)(((br_simple_node*)(n))->next) |
||
50 | #define BR_FOR_SIMPLELIST(list, ptr) for ((ptr) = BR_SIMPLEHEAD(list); (ptr); (ptr) = BR_SIMPLENEXT(ptr)) |
||
51 | #define BR_SIMPLEREMOVE(n) ((void*)BrSimpleRemove((br_simple_node*)(n))) |
||
52 | |||
53 | #define V_X 0 |
||
54 | #define V_Y 1 |
||
55 | #define V_Z 2 |
||
56 | #define V_W 3 |
||
57 | |||
58 | #define BR_FONTF_PROPORTIONAL 1 |
||
59 | |||
60 | #define BR_SIN(a) ((br_scalar)sinf(BrAngleToRadian(a))) |
||
61 | #define BR_COS(a) ((br_scalar)cosf(BrAngleToRadian(a))) |
||
62 | #define BR_TAN(a) ((br_scalar)tanf(BrAngleToRadian(a))) |
||
63 | #define BR_ASIN(a) BrRadianToAngle(asin(a)) |
||
64 | #define BR_ACOS(a) BrRadianToAngle(acos(a)) |
||
65 | #define BR_ATAN2(a, b) BrRadianToAngle(atan2((a), (b))) |
||
66 | #define BR_ATAN2FAST(a, b) BrRadianToAngle(atan2((a), (b))) |
||
67 | |||
68 | #define BR_ASIZE(a) (sizeof(a) / sizeof((a)[0])) |
||
69 | |||
70 | #if BR_ENDIAN_BIG |
||
71 | |||
72 | #define BrHtoNL(x) (x) |
||
73 | #define BrHtoNS(x) (x) |
||
74 | #define BrHtoNF(x) (x) |
||
75 | |||
76 | #else |
||
77 | |||
78 | #define BrHtoNL(x) BrSwap32(x) |
||
79 | #define BrHtoNS(x) BrSwap16(x) |
||
80 | #define BrHtoNF(x) BrSwapFloat(x) |
||
81 | |||
82 | #endif |
||
83 | |||
84 | #endif /* BR_DEFS_H */ |