From 64fab6d1e5c81852878cf6d13a778fea7d071430 Mon Sep 17 00:00:00 2001 From: zakk Date: Sat, 27 Aug 2005 18:11:08 +0000 Subject: From ludwig: This one fixes a rendering error git-svn-id: svn://svn.icculus.org/quake3/trunk@12 edf5b092-35ff-0310-97b2-ce42778d08ea --- code/game/q_math.c | 12 +++++++----- code/qcommon/cm_trace.c | 12 +++++++----- 2 files changed, 14 insertions(+), 10 deletions(-) (limited to 'code') diff --git a/code/game/q_math.c b/code/game/q_math.c index bb0faf6..53412e1 100755 --- a/code/game/q_math.c +++ b/code/game/q_math.c @@ -551,15 +551,17 @@ void VectorRotate( vec3_t in, vec3_t matrix[3], vec3_t out ) */ float Q_rsqrt( float number ) { - long i; + union { + float f; + int i; + } t; float x2, y; const float threehalfs = 1.5F; x2 = number * 0.5F; - y = number; - i = * ( long * ) &y; // evil floating point bit level hacking - i = 0x5f3759df - ( i >> 1 ); // what the fuck? - y = * ( float * ) &i; + t.f = number; + t.i = 0x5f3759df - ( t.i >> 1 ); // what the fuck? + y = t.f; y = y * ( threehalfs - ( x2 * y * y ) ); // 1st iteration // y = y * ( threehalfs - ( x2 * y * y ) ); // 2nd iteration, this can be removed diff --git a/code/qcommon/cm_trace.c b/code/qcommon/cm_trace.c index 6eb9931..eb9b14f 100755 --- a/code/qcommon/cm_trace.c +++ b/code/qcommon/cm_trace.c @@ -131,15 +131,17 @@ SquareRootFloat ================ */ float SquareRootFloat(float number) { - long i; + union { + float f; + int i; + } t; float x, y; const float f = 1.5F; x = number * 0.5F; - y = number; - i = * ( long * ) &y; - i = 0x5f3759df - ( i >> 1 ); - y = * ( float * ) &i; + t.f = number; + t.i = 0x5f3759df - ( t.i >> 1 ); + y = t.f; y = y * ( f - ( x * y * y ) ); y = y * ( f - ( x * y * y ) ); return number * y; -- cgit v1.2.3