Search found 3 matches

by ManaTux
19 Aug 2008, 02:13
Forum: TMW Classic
Topic: some (useful) remarks about particleemitter
Replies: 0
Views: 900

some (useful) remarks about particleemitter

in fact about randomness in general... The use of rand() should be avoided. Not because of poor randomness, of course you don't need better quality, but because of performance. The overhead caused by repeated function calls can be significant for particles generation. I would recommend to replace ra...
by ManaTux
18 Aug 2008, 22:02
Forum: TMW Classic
Topic: some (useless) remarks about particle.cpp
Replies: 2
Views: 1176

Re: some (useless) remarks about particle.cpp

the point was not to remove the slow division, but the slow modulo :)
and most of all replace three calls to rand with one.

But I agree with you, it might be less readable.
by ManaTux
18 Aug 2008, 20:54
Forum: TMW Classic
Topic: some (useless) remarks about particle.cpp
Replies: 2
Views: 1176

some (useless) remarks about particle.cpp

just looked at the code... SIN45 is already defined in <cmath> ----> #define SIN45 M_SQRT1_2 in addTextSplashEffect three call to rand and three modulos... can be done more efficiently: instead of newParticle->setVelocity(((rand() % 100) - 50) / 200.0f, // X ((rand() % 100) - 50) / 200.0f, // Y ((ra...