summaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2007-06-03 14:19:43 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2007-06-03 14:19:43 +0000
commit448f04aff1e2b96287f37755ef1b12d9339ea135 (patch)
tree69e6b8a1107c9c31288ca5563cdc2f0208e69a3d /src/utils
parentd6c5974dcedc33177c99196b3b94d220346c5f8f (diff)
downloadmana-448f04aff1e2b96287f37755ef1b12d9339ea135.tar.gz
mana-448f04aff1e2b96287f37755ef1b12d9339ea135.tar.bz2
mana-448f04aff1e2b96287f37755ef1b12d9339ea135.tar.xz
mana-448f04aff1e2b96287f37755ef1b12d9339ea135.zip
Fixed warning about strict-aliasing rules and don't die on warnings by default.
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/fastsqrt.h13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/utils/fastsqrt.h b/src/utils/fastsqrt.h
index 8ba6f8ce..8da1d354 100644
--- a/src/utils/fastsqrt.h
+++ b/src/utils/fastsqrt.h
@@ -9,15 +9,16 @@
float fastInvSqrt(float x)
{
- float xhalf = 0.5f*x;
- int i = *(int*)&x;
- i = 0x5f375a86- (i>>1);
- x = *(float*)&i;
- x = x*(1.5f-xhalf*x*x);
+ union { int i; float x; } tmp;
+ float xhalf = 0.5f * x;
+ tmp.x = x;
+ tmp.i = 0x5f375a86 - (tmp.i >> 1);
+ x = tmp.x;
+ x = x * (1.5f - xhalf * x * x);
return x;
}
float fastSqrt(float x)
{
- return 1.0f/fastInvSqrt(x);
+ return 1.0f / fastInvSqrt(x);
}