mirror of
https://github.com/TombEngine/TombEngine.git
synced 2025-04-28 15:57:59 +03:00
Revert "Add simple safety checks to RNG"
This reverts commit 202c94f02e
.
This commit is contained in:
parent
a74bb4e584
commit
19be42911c
2 changed files with 10 additions and 22 deletions
|
@ -8,33 +8,21 @@
|
|||
|
||||
namespace TEN::Math::Random
|
||||
{
|
||||
static auto Generator = std::mt19937();
|
||||
static std::mt19937 Engine;
|
||||
|
||||
int GenerateInt(int min, int max)
|
||||
int GenerateInt(int low, int high)
|
||||
{
|
||||
if (min >= max)
|
||||
{
|
||||
TENLog("Attempted to generate integer with minimum value greater than maximum value.", LogLevel::Warning);
|
||||
return min;
|
||||
}
|
||||
|
||||
return (((Generator() / (Generator.max()) / (max - min + 1)) + 1) + min);
|
||||
return (Engine() / (Engine.max() / (high - low + 1) + 1) + low);
|
||||
}
|
||||
|
||||
float GenerateFloat(float min, float max)
|
||||
float GenerateFloat(float low, float high)
|
||||
{
|
||||
if (min >= max)
|
||||
{
|
||||
TENLog("Attempted to generate float with minimum value greater than maximum value.", LogLevel::Warning);
|
||||
return min;
|
||||
}
|
||||
|
||||
return ((((max - min) * Generator()) / Generator.max()) + min);
|
||||
return ((high - low) * Engine() / Engine.max() + low);
|
||||
}
|
||||
|
||||
short GenerateAngle(short min, short max)
|
||||
short GenerateAngle(short low, short high)
|
||||
{
|
||||
return (short)GenerateInt(min, min);
|
||||
return (short)GenerateInt(low, high);
|
||||
}
|
||||
|
||||
Vector2 GenerateDirection2D()
|
||||
|
|
|
@ -6,9 +6,9 @@ namespace TEN::Math::Random
|
|||
{
|
||||
// Value generation
|
||||
|
||||
int GenerateInt(int min = 0, int max = SHRT_MAX);
|
||||
float GenerateFloat(float min = 0.0f, float max = 1.0f);
|
||||
short GenerateAngle(short min = SHRT_MIN, short max = SHRT_MAX);
|
||||
int GenerateInt(int low = 0, int high = SHRT_MAX);
|
||||
float GenerateFloat(float low = 0.0f, float high = 1.0f);
|
||||
short GenerateAngle(short low = SHRT_MIN, short high = SHRT_MAX);
|
||||
|
||||
// 2D geometric generation
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue