- static unsigned int a = 18000, b = 30903;
- seed_x = a * ( seed_x & 65535 ) + ( seed_x >> 16 );
- seed_y = b * ( seed_y & 65535 ) + ( seed_y >> 16 );
- return ( ( seed_x << 16 ) + ( seed_y & 65535 ) );
+ // Use the initial value to initialize the seed to arbitrary values.
+ // This causes the algorithm to produce consistent results each time for the same frame number.
+ seed->x = 521288629 + init - ( init << 16 );
+ seed->y = 362436069 - init + ( init << 16 );
+}
+
+static inline unsigned int fast_rand( rand_seed* seed )
+{
+ static unsigned int a = 18000, b = 30903;
+ seed->x = a * ( seed->x & 65535 ) + ( seed->x >> 16 );
+ seed->y = b * ( seed->y & 65535 ) + ( seed->y >> 16 );
+ return ( ( seed->x << 16 ) + ( seed->y & 65535 ) );