14 #define NULL (RVALUE, null_entity)
17 #define NULL (RVALUE, world)
20 #include "lib/accumulate.qh"
21 #include "lib/misc.qh"
22 #include "lib/static.qh"
23 #include "lib/vector.qh"
25 void(vector) _vectorvectors;
28 STATIC_INIT(globals) {
29 _vectorvectors = vectorvectors;
31 // set to NaN to more easily detect uninitialized use
37 /// Same as the `makevectors` builtin but uses the provided locals instead of the `v_*` globals.
38 /// Always use this instead of raw `makevectors` to make the data flow clear.
39 /// It's 2018, they even teach that globals are bad at my uni... though for some reason they never explained why. Sigh.
40 #define MAKEVECTORS(angles, forward, right, up) MACRO_BEGIN { \
41 makevectors(angles); \
42 forward = v_forward; \
45 v_forward = VEC_NAN; \
50 // Same as `MAKEVECTORS` but also creates the locals for convenience.
51 #define MAKEVECTORS_NEW(angles, forward, right, up) \
52 vector forward = '0 0 0'; \
53 vector right = '0 0 0'; \
54 vector up = '0 0 0'; \
55 MAKEVECTORS(angles, forward, right, up);
57 #define VECTOR_VECTORS(forward_in, forward, right, up) MACRO_BEGIN { \
58 _vectorvectors(forward_in); \
59 forward = v_forward; \
62 v_forward = VEC_NAN; \
67 #define VECTOR_VECTORS_NEW(forward_in, forward, right, up) \
68 vector forward = '0 0 0'; \
69 vector right = '0 0 0'; \
70 vector up = '0 0 0'; \
71 VECTOR_VECTORS(forward_in, forward, right, up);
73 #define vectorvectors DO_NOT_USE_GLOBALS
75 // FIXME find a good place for this
76 // FIXME MAKE_VECTORS because current naming sucks
77 // FIXME ban vectorvectors
79 // TODO when raw makevectors and similar functions are not used anywhere else anymore,
80 // assert that the global vectors are NaN before calling makevectors in MAKEVECTORS
81 // to make sure nobody (even builtins) is accidentally using them - NaN is the most liekly value to expose values clearly
82 // also uncomment these:
83 //#define makevectors DO_NOT_USE_GLOBALS
84 //#define v_forward DO_NOT_USE_GLOBALS
85 //#define v_right DO_NOT_USE_GLOBALS
86 //#define v_up DO_NOT_USE_GLOBALS