Fixed for division by zero issue.

This commit is contained in:
Robert Osfield 2009-03-13 11:01:11 +00:00
parent 9a4e17b766
commit a8aad71d03

View File

@ -40,11 +40,11 @@ void osgParticle::FluidProgram::execute(double dt)
osg::Vec3 wind_force = - relative_wind * Area * (_viscosityCoefficient + _densityCoefficient*relative_wind.length()); osg::Vec3 wind_force = - relative_wind * Area * (_viscosityCoefficient + _densityCoefficient*relative_wind.length());
osg::Vec3 wind_accel = wind_force * particle->getMassInv(); osg::Vec3 wind_accel = wind_force * particle->getMassInv();
double critical_dt2 = relative_wind.length2()/wind_accel.length2();
double compenstated_dt = dt; double compenstated_dt = dt;
if (critical_dt2 < dt*dt) if (relative_wind.length2() < dt*dt*wind_accel.length2())
{ {
// osg::notify(osg::NOTICE)<<"** Could be critical: dt="<<dt<<" critical_dt="<<sqrtf(critical_dt2)<<std::endl; // osg::notify(osg::NOTICE)<<"** Could be critical: dt="<<dt<<" critical_dt="<<sqrtf(critical_dt2)<<std::endl;
double critical_dt2 = relative_wind.length2()/wind_accel.length2();
compenstated_dt = sqrtf(critical_dt2)*0.8f; compenstated_dt = sqrtf(critical_dt2)*0.8f;
} }