From c5724c3955aaa0135aebf8875b70a8f91358d582 Mon Sep 17 00:00:00 2001 From: Martin Taibr Date: Mon, 12 Nov 2018 23:27:46 +0100 Subject: [PATCH] comment NaN handling --- qcsrc/lib/deglobalization.qh | 15 +++++++++++---- qcsrc/lib/vector.qh | 5 +++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/qcsrc/lib/deglobalization.qh b/qcsrc/lib/deglobalization.qh index 1097035bf..d9417b489 100644 --- a/qcsrc/lib/deglobalization.qh +++ b/qcsrc/lib/deglobalization.qh @@ -20,13 +20,20 @@ #ifdef GAMEQC STATIC_INIT(globals) { // set to NaN to more easily detect uninitialized use - // TODO when all functions are wrapped and the raw functions are not used anymore, - // assert that the global vectors are NaN before calling the raw functions - // to make sure nobody (even builtins) is accidentally using them - NaN is the most likely value to expose remaining usages + // TODO when all functions are wrapped and the raw functions are not used anymore, + // assert that the global vectors are NaN before calling the raw functions + // to make sure nobody (even builtins) is accidentally using them - NaN is the most likely value to expose remaining usages + + // TODO make sure `isnan` actually works - potential compiler bug: + //LOG_INFOF("%f\n", 0.0/0.0 == 0.0/0.0); + //LOG_INFOF("%f\n", 0.0/0.0 != 0.0/0.0); + //float x = 0.0/0.0; + //LOG_INFOF("%f\n", x == x); + //LOG_INFOF("%f\n", x != x); + v_forward = VEC_NAN; v_right = VEC_NAN; v_up = VEC_NAN; - // FIXME check this is actually NaN } #endif diff --git a/qcsrc/lib/vector.qh b/qcsrc/lib/vector.qh index eae8d4397..d49322efb 100644 --- a/qcsrc/lib/vector.qh +++ b/qcsrc/lib/vector.qh @@ -109,6 +109,11 @@ noref vector _vec3; #define VEC_NAN vec3(FLOAT_NAN, FLOAT_NAN, FLOAT_NAN); +ERASEABLE +bool is_all_nans(vector v) { + return isnan(v.x) && isnan(v.y) && isnan(v.z); +} + ERASEABLE vector Rotate(vector v, float a) { -- 2.39.2