cleanup
This commit is contained in:
@@ -1112,7 +1112,7 @@ void showmapstats()
|
||||
conoutf(" The mean height is: %.2f", Mh);
|
||||
if (Hhits) conoutf(" Height check is: %d", Hhits);
|
||||
if (MA) conoutf(" The max area is: %d (of %d)", MA, Ma);
|
||||
if (m_flags && F2F < 1000) conoutf(" Flag-to-flag distance is: %d", (int)fSqrt(F2F));
|
||||
if (m_flags && F2F < 1000) conoutf(" Flag-to-flag distance is: %d", (int)sqrtf(F2F));
|
||||
if (item_fail) conoutf(" There are one or more items too close to each other in this map");
|
||||
}
|
||||
COMMAND(showmapstats, "");
|
||||
|
||||
@@ -1,51 +1,3 @@
|
||||
// Fast Inverse Sqrt
|
||||
// http://www.gamedev.net/community/forums/topic.asp?topic_id=139956
|
||||
// http://www.lomont.org/Math/Papers/2003/InvSqrt.pdf
|
||||
// http://www.mceniry.net/papers/Fast%20Inverse%20Square%20Root.pdf
|
||||
// http://en.wikipedia.org/wiki/Fast_inverse_square_root
|
||||
#define UFINVSQRT(x) union { int d; float f; } u; u.f = x; u.d = 0x5f3759df - (u.d >> 1)
|
||||
inline float ufInvSqrt (float x) { UFINVSQRT(x); return u.f; } // about 3.5% of error
|
||||
inline float fInvSqrt (float x) { UFINVSQRT(x); return 0.5f * u.f * ( 3.00175f - x * u.f * u.f ); } // about 0.1% of error
|
||||
inline float fSqrt (float x) { return x * fInvSqrt(x); }
|
||||
inline float ufSqrt (float x) { return x * ufInvSqrt(x); }
|
||||
inline float fACos( float x )
|
||||
{
|
||||
int s = 1;
|
||||
float y, r = 0;
|
||||
if ( x < 0 )
|
||||
{
|
||||
s = -1;
|
||||
r = 2.0f;
|
||||
y = 1.0f + x;
|
||||
}
|
||||
else y = 1.0f - x;
|
||||
UFINVSQRT(y);
|
||||
u.f = 0.5f * u.f * ( 3.0f - y * u.f * u.f );
|
||||
u.f = y * 0.5f * u.f * ( 3.0f - y * u.f * u.f );
|
||||
return 1.57079632f * ( r + s * u.f * ( 0.9003163f + y * ( 0.07782684f + y * ( 0.006777598f + y * 0.015079262f ) ) ) );
|
||||
}
|
||||
#undef UFINVSQRT
|
||||
|
||||
template <typename T> inline T pow2(T x) { return x*x; }
|
||||
|
||||
// Fast Cosine
|
||||
// inspired after http://www.devmaster.net/forums/showthread.php?t=5784
|
||||
#define FCOS \
|
||||
x = fabs(x); \
|
||||
int s = 1; \
|
||||
if ( x > 1.0f ) \
|
||||
{ \
|
||||
int n = 0.5f * ( x + 1.0f ); \
|
||||
x -= 2 * n; \
|
||||
s = 1 - 2 * (n%2); \
|
||||
} \
|
||||
float y = ( 1.0f - x*x ); \
|
||||
return s * y * ( 0.7853982f + y * 0.2146018f )
|
||||
inline float fCos(float x) { x *= 0.636619772f; FCOS; }
|
||||
inline float fSin(float x) { x *= 0.636619772f; x -= 1.0f; FCOS; }
|
||||
#undef FCOS
|
||||
|
||||
inline float ufS2C(float x) { x *= x; return x < 1.0f ? ufSqrt(1.0f - x) : 0.0f; }
|
||||
|
||||
struct vec
|
||||
{
|
||||
@@ -86,12 +38,6 @@ struct vec
|
||||
float magnitude() const { return sqrtf(squaredlen()); }
|
||||
vec &normalize() { div(magnitude()); return *this; }
|
||||
|
||||
// should NOT be used
|
||||
float fmag() const { return fSqrt(squaredlen()); }
|
||||
float ufmag() const { return ufSqrt(squaredlen()); }
|
||||
float fmagxy() const { return fSqrt(x*x + y*y); }
|
||||
float ufmagxy() const { return ufSqrt(x*x + y*y); }
|
||||
|
||||
float dist(const vec &e) const { vec t; return dist(e, t); }
|
||||
float dist(const vec &e, vec &t) const { t = *this; t.sub(e); return t.magnitude(); }
|
||||
|
||||
|
||||
@@ -610,7 +610,7 @@ void moveplayer(physent *pl, int moveres, bool local, int curtime)
|
||||
if(pl->type!=ENT_BOUNCE && hitplayer)
|
||||
{
|
||||
vec dr(hitplayer->o.x-pl->o.x,hitplayer->o.y-pl->o.y,0);
|
||||
float invdist = ufInvSqrt(dr.sqrxy()),
|
||||
float invdist = 1.0f / dr.magnitudexy(),
|
||||
push = (invdist < 10.0f ? dr.dotxy(d)*1.1f*invdist : dr.dotxy(d) * 11.0f);
|
||||
|
||||
pl->o.x -= f*d.x*push;
|
||||
|
||||
@@ -1674,7 +1674,7 @@ int calcscores() // skill eval
|
||||
loopv(clients) if(clients[i]->type!=ST_EMPTY)
|
||||
{
|
||||
clientstate &cs = clients[i]->state;
|
||||
sum += clients[i]->at3_score = cs.points > 0 ? ufSqrt((float)cs.points) : -ufSqrt((float)-cs.points);
|
||||
sum += clients[i]->at3_score = cs.points > 0 ? sqrtf((float)cs.points) : -sqrtf((float)-cs.points);
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
@@ -55,6 +55,8 @@ static inline T min(T a, T b)
|
||||
return a < b ? a : b;
|
||||
}
|
||||
|
||||
template <typename T> inline T pow2(T x) { return x*x; }
|
||||
|
||||
static inline float round(float x) { return floor(x + 0.5f); }
|
||||
|
||||
#define clamp(x,minval,maxval) (max(minval, min(x, maxval)))
|
||||
|
||||
Reference in New Issue
Block a user