From 8b00d67febf133e89f6a0bfabc41feed555dc4a9 Mon Sep 17 00:00:00 2001 From: chai Date: Sat, 12 Jan 2019 21:48:33 +0800 Subject: =?UTF-8?q?*=E5=8E=BB=E6=8E=89=E6=96=87=E4=BB=B6=E5=89=8D=E7=BC=80?= =?UTF-8?q?je=5F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/libjin/math/je_random.cpp | 54 ------------------------------------------- 1 file changed, 54 deletions(-) delete mode 100644 src/libjin/math/je_random.cpp (limited to 'src/libjin/math/je_random.cpp') diff --git a/src/libjin/math/je_random.cpp b/src/libjin/math/je_random.cpp deleted file mode 100644 index b9313d2..0000000 --- a/src/libjin/math/je_random.cpp +++ /dev/null @@ -1,54 +0,0 @@ -#include -#include "je_math.h" -#include "je_random.h" - -namespace JinEngine -{ - namespace Math - { - - RandomGenerator::RandomGenerator(uint32 seed) - : mSeed(seed) - { - } - - uint32 RandomGenerator::rand() - { - unsigned int next = mSeed; - uint32 result; - - next *= 1103515245; - next += 12345; - result = (unsigned int)(next / 65536) % 2048; - - next *= 1103515245; - next += 12345; - result <<= 10; - result ^= (unsigned int)(next / 65536) % 1024; - - next *= 1103515245; - next += 12345; - result <<= 10; - result ^= (unsigned int)(next / 65536) % 1024; - - mSeed = next; - - return result; - } - - uint32 RandomGenerator::rand(uint32 min, uint32 max) - { - uint32 n = rand(); - return n % (max - min + 1) + min; - } - - float RandomGenerator::randf(float min, float max, int ac) - { - float floor = 0, ceil = max + reverse(min); - uint32 a = pow(10.f, ac); - uint32 n = rand(floor*a, ceil*a); - return (float)n / a + min; - } - - } -} \ No newline at end of file -- cgit v1.1-26-g67d0