package alternativa.engine3d.core;

class MeshMath {

/**
	public function test():Void {
		var m = flash.Memory;
		var x:Float;
		for (n in 0...1000000) {
			x = n;
			//1/m.sqrt(x);
			//invSqrt(n);
			var half = 0.5 * x;
	 		m.setFloat(0,x);
		    var i = m.getI32(0);
		    i = 0x5f3759df - (i>>1);
		    m.setI32(0,i);
		    x = m.getFloat(0);
		    x = x * (1.5 - half*x*x);
		}
		return;
	}
	
	
	
	
	
	public function inverseSqrt(n:Float):Float {
		return 1/Math.sqrt(n);
	}
	
	public function prepare() {
	    var b = new flash.utils.ByteArray();
	    b.length = 1024;
	    flash.Memory.select(b);
	}
	
	inline function invSqrt( x : Float ) : Float {
	    var half = 0.5 * x;
	    flash.Memory.setFloat(0,x);
	    var i = flash.Memory.getI32(0);
	    i = 0x5f3759df - (i>>1);
	    flash.Memory.setI32(0,i);
	    x = flash.Memory.getFloat(0);
	    x = x * (1.5 - half*x*x);
	    return x;
	}
**/
}