Remove fast PRNG, it won't be necessary.

This commit is contained in:
Mari the Deer 2026-02-23 16:18:38 +01:00
commit 4c847db83d
2 changed files with 2 additions and 70 deletions

View file

@ -7,12 +7,6 @@ Struct SWWMProjectionData
int viewx, viewy, vieww, viewh;
}
Struct SWWMFRNGState
{
bool init;
uint x, y, z, w, v, d;
}
extend Class SWWMUtility
{
// cache some data that requires trig and quat math
@ -450,68 +444,6 @@ extend Class SWWMUtility
double yscale = dist*len;
return angle, pitch, yscale;
}
// XORWOW-based PRNG, the best and fastest we can really use in ZScript due to lack of 64-bit integers
private static uint XORWOW( SWWMFRNGState &rss )
{
if ( !rss.init )
{
rss.x = 123456789;
rss.y = 362436069;
rss.z = 521288629;
rss.w = 88675123;
rss.v = 5783321;
rss.d = 6615241;
rss.init = true;
}
uint t = rss.v;
uint s = rss.x;
rss.v = rss.w;
rss.w = rss.z;
rss.z = rss.y;
rss.y = s;
t ^= t>>2;
t ^= t<<1;
t ^= s^(s<<4);
rss.x = t;
rss.d += 362437;
return t+rss.d;
}
// the public-callable functions
static uint FastRand( SWWMFRNGState &rss, uint mod = 0 )
{
uint rslt = XORWOW(rss);
if ( mod ) return rslt%mod;
return rslt;
}
static int FastRandRange( SWWMFRNGState &rss, int low, int high )
{
if ( low >= high ) ThrowAbortException("FastRandomRange called with low >= high");
uint range = uint(high-low);
int rslt = int(FastRand(rss,range));
return low+rslt;
}
static double FastFRand( SWWMFRNGState &rss )
{
uint rslt = XORWOW(rss);
return rslt/double(uint.max);
}
static Vector3 FastVRand( SWWMFRNGState &rss )
{
double ang = FastFRand(rss)*360;
double pt = 90-FastFRand(rss)*180;
return (cos(ang)*cos(pt),sin(ang)*cos(pt),-sin(pt));
}
static Vector2 FastVRand2D( SWWMFRNGState &rss )
{
double ang = FastFRand(rss)*360;
return (cos(ang),sin(ang));
}
}
// ultrafast PRNG for a bunch of UI stuff