Hi. I am currently developing a 3d game.
I was generating random terrain and everything works perfectly. I am using the default_random_engine class for Perlin Noise terrain generation.
std::default_random_engine random;
random.seed(someValue);
Just calling random.seed(someValue) takes a while to execute. And of course I am calling this more that a hundred times once (not in a loop). So that takes a lot of time (more that 5-6 seconds). While on the other hand, srand(someValue) takes no time to execute, why is that the case?
If std::default_random_engine is a typedef for std::mt19937, or some other engine with a large state, it isn't surprising that seeding takes quite a bit of time.
Reseeding a random engine is mainly useful if you want a predictable result, but otherwise common practice is to seed once and then keep using the same engine throughout the whole run of the application without ever seeding again.
If you have to reseed often I suggest choosing an engine with a small state that you know is fast to seed (e.g. std::minstd_rand).
@helios, in the method Perlin Noise, this is necessary. And by the way, for terrain generation you need a rectangle with multiple vertices, the more vertices, the bigger the quad.