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