mirror of
https://github.com/glest/glest-source.git
synced 2025-08-18 14:11:15 +02:00
Ported streflop code to win32
This commit is contained in:
@@ -18,7 +18,7 @@
|
||||
|
||||
#include "util.h"
|
||||
#include "math_util.h"
|
||||
#include "random.h"
|
||||
#include "randomgen.h"
|
||||
#include "FileReader.h"
|
||||
#include "ImageReaders.h"
|
||||
|
||||
@@ -631,7 +631,7 @@ float splatDist(Vec2i a, Vec2i b){
|
||||
|
||||
void Pixmap2D::splat(const Pixmap2D *leftUp, const Pixmap2D *rightUp, const Pixmap2D *leftDown, const Pixmap2D *rightDown){
|
||||
|
||||
Random random;
|
||||
RandomGen random;
|
||||
|
||||
assert(components==3 || components==4);
|
||||
|
||||
|
@@ -12,7 +12,7 @@
|
||||
#include "sound_player_ds8.h"
|
||||
|
||||
#include <cassert>
|
||||
//#include <cmath>
|
||||
#include <cmath>
|
||||
//#include "streflop.h"
|
||||
|
||||
#include "util.h"
|
||||
|
45
source/shared_lib/sources/util/randomgen.cpp
Normal file
45
source/shared_lib/sources/util/randomgen.cpp
Normal file
@@ -0,0 +1,45 @@
|
||||
#include "randomgen.h"
|
||||
#include <cassert>
|
||||
|
||||
#include "leak_dumper.h"
|
||||
|
||||
namespace Shared { namespace Util {
|
||||
|
||||
// =====================================================
|
||||
// class RandomGen
|
||||
// =====================================================
|
||||
|
||||
const int RandomGen::m= 714025;
|
||||
const int RandomGen::a= 1366;
|
||||
const int RandomGen::b= 150889;
|
||||
|
||||
RandomGen::RandomGen(){
|
||||
lastNumber= 0;
|
||||
}
|
||||
|
||||
void RandomGen::init(int seed){
|
||||
lastNumber= seed % m;
|
||||
}
|
||||
|
||||
int RandomGen::rand(){
|
||||
lastNumber= (a*lastNumber + b) % m;
|
||||
return lastNumber;
|
||||
}
|
||||
|
||||
int RandomGen::randRange(int min, int max){
|
||||
assert(min<=max);
|
||||
int diff= max-min;
|
||||
int res= min + static_cast<int>(static_cast<float>(diff+1)*RandomGen::rand() / m);
|
||||
assert(res>=min && res<=max);
|
||||
return res;
|
||||
}
|
||||
|
||||
float RandomGen::randRange(float min, float max){
|
||||
assert(min<=max);
|
||||
float rand01= static_cast<float>(RandomGen::rand())/(m-1);
|
||||
float res= min+(max-min)*rand01;
|
||||
assert(res>=min && res<=max);
|
||||
return res;
|
||||
}
|
||||
|
||||
}}//end namespace
|
Reference in New Issue
Block a user