I think maybe I can share some experiences on my graphics coding about irrlicht.
I want to talk about the CParticleGravityAffector. The original version is as below:
Code: Select all
void CParticleGravityAffector::affect(u32 now, SParticle* particlearray, u32 count)
{
if (!Enabled)
return;
f32 d;
for (u32 i=0; i<count; ++i)
{
d = (now - particlearray[i].startTime) / TimeForceLost;
if (d > 1.0f)
d = 1.0f;
if (d < 0.0f)
d = 0.0f;
d = 1.0f - d;
particlearray[i].vector = particlearray[i].startVector.getInterpolated(Gravity, d);
}
}
// approximate the newton's low
// X = V0 * t + (a + g) * t * t/2
particle-pos = ( particle-vector * ratio + gravity) * t * t / 2;
ratio is to decrease the influence of the particle-vector (as the a component)
I think I got better approximation of gravity this way.
Sorry for some reason, I modify the article to skip some source codes.