[mathlib] Remove suspicious IS_NAN

The implementation looks wrong (more like infinity). Where it was used
is currently disabled, but the usages were replaced with C99's isnan.
This commit is contained in:
Bill Currie 2022-03-19 12:35:01 +09:00
parent 65af7fb4a4
commit 0f30f0a133
4 changed files with 6 additions and 13 deletions

View file

@ -50,13 +50,9 @@
# define M_PI 3.14159265358979323846 // matches value in gcc v2 math.h
#endif
extern int nanmask;
#define EQUAL_EPSILON 0.001
#define RINT(x) (floor ((x) + 0.5))
#define IS_NAN(x) (((*(int *) (char *) &x) & nanmask) == nanmask)
#define Blend(a,b,blend) ((1 - (blend)) * (a) + (blend) * (b))
#include "QF/math/vector.h"

View file

@ -47,7 +47,6 @@
#include "QF/set.h"
#include "QF/sys.h"
VISIBLE int nanmask = 255 << 23;
static vec3_t _vec3_origin = { 0, 0, 0 };
VISIBLE const vec_t * const vec3_origin = _vec3_origin;
static quat_t _quat_origin = { 0, 0, 0, 0 };

View file

@ -88,18 +88,17 @@ void
SV_CheckVelocity (edict_t *ent)
{
float wishspeed;
// int i;
// bound velocity
#if 0
for (i = 0; i < 3; i++) {
if (IS_NAN (SVvector (ent, velocity)[i])) {
for (int i = 0; i < 3; i++) {
if (isnan (SVvector (ent, velocity)[i])) {
Sys_Printf ("Got a NaN velocity on %s\n",
PR_GetString (&sv_pr_state, SVstring (ent,
classname)));
SVvector (ent, velocity)[i] = 0;
}
if (IS_NAN (SVvector (ent, origin)[i])) {
if (isnan (SVvector (ent, origin)[i])) {
Sys_Printf ("Got a NaN origin on %s\n",
PR_GetString (&sv_pr_state, SVstring (ent,
classname)));

View file

@ -87,18 +87,17 @@ void
SV_CheckVelocity (edict_t *ent)
{
float wishspeed;
// int i;
// bound velocity
#if 0
for (i = 0; i < 3; i++) {
if (IS_NAN (SVvector (ent, velocity)[i])) {
for (int i = 0; i < 3; i++) {
if (isnan (SVvector (ent, velocity)[i])) {
Sys_Printf ("Got a NaN velocity on %s\n",
PR_GetString (&sv_pr_state, SVstring (ent,
classname)));
SVvector (ent, velocity)[i] = 0;
}
if (IS_NAN (SVvector (ent, origin)[i])) {
if (isnan (SVvector (ent, origin)[i])) {
Sys_Printf ("Got a NaN origin on %s\n",
PR_GetString (&sv_pr_state, SVstring (ent,
classname)));