]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
use NaN instead of resetting to old value
authorMartin Taibr <taibr.martin@gmail.com>
Tue, 6 Nov 2018 11:24:27 +0000 (12:24 +0100)
committerMartin Taibr <taibr.martin@gmail.com>
Tue, 6 Nov 2018 11:24:42 +0000 (12:24 +0100)
qcsrc/client/csqcmodel_hooks.qc
qcsrc/lib/float.qh
qcsrc/lib/vector.qh

index 961fc77572d2faea847fbefc8f2ec4d614b01736..86c672c239dddcec01af824319ec4a0ac2be5686 100644 (file)
@@ -541,7 +541,8 @@ void CSQCModel_Effects_Apply(entity this)
        if(this.csqcmodel_modelflags & MF_ROTATE)
        {
                this.renderflags |= RF_USEAXIS;
-               MAKEVECTORS(makevectors, this.angles + '0 100 0' * fmod(time, 3.6), v_forward, v_right, v_up);
+               makevectors(this.angles + '0 100 0' * fmod(time, 3.6));
+               //MAKEVECTORS(makevectors, this.angles + '0 100 0' * fmod(time, 3.6), v_forward, v_right, v_up);
        }
        if(this.csqcmodel_modelflags & MF_TRACER)
                tref = EFFECT_TR_WIZSPIKE.m_id;
index b4d1f0bd768c785f103ad3886f5453769e10c2ff..fa4ff77b5a1fee7cfb7d6c4f8312999aec33e53c 100644 (file)
@@ -2,3 +2,4 @@
 
 const float FLOAT_MAX = 340282346638528859811704183484516925440.0f;
 const float FLOAT_EPSILON = 0.00000011920928955078125f;
+const float FLOAT_NAN = 0.0 / 0.0;
index 7e393e6e4b8fa9d84970cb1f73ca46d1ae322cdc..2900a0f9041b4bef3727bc0b4ab8efe94c9b9ae3 100644 (file)
@@ -1,5 +1,23 @@
 #pragma once
 
+#include "lib/float.qh"
+#include "lib/misc.qh"
+#include "lib/static.qh"
+
+//pseudo prototypes:
+// vector vec2(vector v); // returns a vector with just the x and y components of the given vector
+// vector vec2(float x, float y); // returns a vector with the given x and y components
+
+noref vector _vec2;
+#define vec2(...) EVAL(OVERLOAD(vec2, __VA_ARGS__))
+#define vec2_1(v) (_vec2 = (v), _vec2.z = 0, _vec2)
+#define vec2_2(x, y) (_vec2_x = (x), _vec2_y = (y), _vec2)
+
+noref vector _vec3;
+#define vec3(_x, _y, _z) (_vec3.x = (_x), _vec3.y = (_y), _vec3.z = (_z), _vec3)
+
+#define VEC_NAN vec3(FLOAT_NAN, FLOAT_NAN, FLOAT_NAN);
+
 noref vector _vlen2;
 #define vlen2(v) (_vlen2 = (v), dotproduct(_vlen2, _vlen2))
 
@@ -93,31 +111,27 @@ float boxinsidebox(vector smins, vector smaxs, vector bmins, vector bmaxs) { ret
 #define YAW(v) ((v).y)
 #define ROLL(v) ((v).z)
 
+#ifdef GAMEQC
+STATIC_INIT(globals) {
+       // set to NaN to more easily detect uninitialized use
+       v_forward = VEC_NAN;
+       v_right = VEC_NAN;
+       v_up = VEC_NAN;
+}
+#endif
+
+// TODO when raw makevectors in not used anywhere else, assert that the global vectors are NaN before calling makevectors here
+// to make sure nobody is accidentally using them
 #define MAKEVECTORS(f, angles, forward, right, up) MACRO_BEGIN { \
-       vector old_forward = v_forward; \
-       vector old_right = v_right; \
-       vector old_up = v_up; \
        f(angles); \
        forward = v_forward; \
        right = v_right; \
        up = v_up; \
-       v_forward = old_forward; \
-       v_right = old_right; \
-       v_up = old_up; \
+       v_forward = VEC_NAN; \
+       v_right = VEC_NAN; \
+       v_up = VEC_NAN; \
 } MACRO_END
 
-//pseudo prototypes:
-// vector vec2(vector v); // returns a vector with just the x and y components of the given vector
-// vector vec2(float x, float y); // returns a vector with the given x and y components
-
-noref vector _vec2;
-#define vec2(...) EVAL(OVERLOAD(vec2, __VA_ARGS__))
-#define vec2_1(v) (_vec2 = (v), _vec2.z = 0, _vec2)
-#define vec2_2(x, y) (_vec2_x = (x), _vec2_y = (y), _vec2)
-
-noref vector _vec3;
-#define vec3(_x, _y, _z) (_vec3.x = (_x), _vec3.y = (_y), _vec3.z = (_z), _vec3)
-
 ERASEABLE
 vector Rotate(vector v, float a)
 {