From 78e9698f6b2d901e96d7ed8b8da7a3a2ef3f791f Mon Sep 17 00:00:00 2001 From: lisawick Date: Fri, 11 May 2018 11:47:20 -0700 Subject: [PATCH] Add consistent_physics define to use native square root for all platforms. --- cx-src/zpp_nape/util/Math.cx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cx-src/zpp_nape/util/Math.cx b/cx-src/zpp_nape/util/Math.cx index 6a0d786e..4b7eac82 100644 --- a/cx-src/zpp_nape/util/Math.cx +++ b/cx-src/zpp_nape/util/Math.cx @@ -11,7 +11,7 @@ $(mixin global isNaN(x) (x!=x)); class PR(Math) { flibstaticdel(sqrt) public static inline function sqrt(x:Float) { assert(!assert_isNaN(x),"PR(Math).sqrt"); - #if flash10 + #if (flash10 && !consistent_physics) return if(x==0.0) 0.0 else 1/invsqrt(x); #else return Math.sqrt(x); @@ -19,7 +19,7 @@ class PR(Math) { } flibstaticdel(invsqrt) public static inline function invsqrt(x:Float) { assert(!assert_isNaN(x) && x!=0.0,"PR(Math).invsqrt"); - #if flash10 + #if (flash10 && !consistent_physics) Memory.setFloat(0,x); Memory.setI32(0,0x5f3759df - (Memory.getI32(0)>>1)); var x2 = Memory.getFloat(0);