Rev 18 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 18 | Rev 20 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | #ifndef MACROS_H |
1 | #ifndef MACROS_H |
2 | #define MACROS_H |
2 | #define MACROS_H |
3 | - | ||
4 | #define DR_JOIN2(A,B) A##B |
- | |
5 | #define DR_JOIN(A,B) DR_JOIN2(A, B) |
- | |
6 | #define DR_STATIC_ASSERT(V) typedef int DR_JOIN(dr_static_assert_, __COUNTER__)[(V)?1:-1] |
- | |
7 | 3 | ||
8 | #define VEHICLE_TYPE_FROM_ID(id) ((tVehicle_type)(id >> 8)) |
4 | #define VEHICLE_TYPE_FROM_ID(id) ((tVehicle_type)(id >> 8)) |
9 | #define VEHICLE_INDEX_FROM_ID(id) ((id)&0x00ff) |
5 | #define VEHICLE_INDEX_FROM_ID(id) ((id)&0x00ff) |
10 | 6 | ||
11 | // |
7 | //#define VEC3_TRANSLATE(mat) (*(br_vector3*)(&mat->m[3][0])) |
12 | 8 | ||
13 | #define SLOBYTE(x) (*((signed char*)&(x))) |
9 | #define SLOBYTE(x) (*((signed char*)&(x))) |
14 | 10 | ||
15 | #define STR_STARTS_WITH(haystack, needle) strncmp(haystack, needle, strlen(needle)) |
11 | #define STR_STARTS_WITH(haystack, needle) strncmp(haystack, needle, strlen(needle)) |
16 | #define STR_ENDS_WITH(haystack, needle) strcmp(haystack + strlen(haystack) - strlen(needle), needle) |
12 | #define STR_ENDS_WITH(haystack, needle) strcmp(haystack + strlen(haystack) - strlen(needle), needle) |
Line 22... | Line 18... | ||
22 | #define COUNT_OF(array) (sizeof((array)) / sizeof((array)[0])) |
18 | #define COUNT_OF(array) (sizeof((array)) / sizeof((array)[0])) |
23 | #define LEN(array) (sizeof((array)) / sizeof((array)[0])) |
19 | #define LEN(array) (sizeof((array)) / sizeof((array)[0])) |
24 | 20 | ||
25 | #define DEG_TO_RAD(degrees) ((degrees)*3.141592653589793 / 180.0) |
21 | #define DEG_TO_RAD(degrees) ((degrees)*3.141592653589793 / 180.0) |
26 | 22 | ||
27 | #define V11MODEL(model) ((( |
23 | #define V11MODEL(model) (((v11model*)model->prepared)) |
28 | #define CAR(c) ((tCar_spec*)c) |
24 | #define CAR(c) ((tCar_spec*)c) |
29 | 25 | ||
30 | #define Vector3Div(v1, v2, v3) \ |
26 | #define Vector3Div(v1, v2, v3) \ |
31 | do { \ |
27 | do { \ |
32 | (v1)->v[0] = (v2)->v[0] / (v3)->v[0]; \ |
28 | (v1)->v[0] = (v2)->v[0] / (v3)->v[0]; \ |
Line 42... | Line 38... | ||
42 | ((V1)->v[0] == (V2)->v[0] && (V1)->v[1] == (V2)->v[1] && (V1)->v[2] == (V2)->v[2]) |
38 | ((V1)->v[0] == (V2)->v[0] && (V1)->v[1] == (V2)->v[1] && (V1)->v[2] == (V2)->v[2]) |
43 | #define Vector3EqualElements(V, A, B, C) \ |
39 | #define Vector3EqualElements(V, A, B, C) \ |
44 | ((V)->v[0] == (A) && (V)->v[1] == (B) && (V)->v[2] == (C)) |
40 | ((V)->v[0] == (A) && (V)->v[1] == (B) && (V)->v[2] == (C)) |
45 | #define Vector3IsZero(V) Vector3EqualElements((V), 0.f, 0.f, 0.f) |
41 | #define Vector3IsZero(V) Vector3EqualElements((V), 0.f, 0.f, 0.f) |
46 | #define Vector3AddFloats(V1, V2, X, Y, Z) \ |
42 | #define Vector3AddFloats(V1, V2, X, Y, Z) \ |
47 | do { \ |
- | |
48 | (V1)->v[0] = (V2)->v[0] + (X); \ |
- | |
49 | |
43 | do { (V1)->v[0] = (V2)->v[0] + (X); (V1)->v[1] = (V2)->v[1] + (Y); (V1)->v[2] = (V2)->v[2] + (Z); } while (0) |
50 | (V1)->v[2] = (V2)->v[2] + (Z); \ |
- | |
51 | } while (0) |
- | |
52 | #define SwapValuesUsingTemporary(V1, V2, T) \ |
44 | #define SwapValuesUsingTemporary(V1, V2, T) \ |
53 | do { \ |
45 | do { \ |
54 | (T) = (V1); \ |
46 | (T) = (V1); \ |
55 | (V1) = (V2); \ |
47 | (V1) = (V2); \ |
56 | (V2) = (T); \ |
48 | (V2) = (T); \ |