Renamed _A and _B to make them more meanigful

This commit is contained in:
Robert Osfield 2005-04-04 20:25:57 +00:00
parent ed0f780321
commit 9e5d905b05
2 changed files with 13 additions and 13 deletions

View File

@ -41,7 +41,7 @@ namespace osgParticle
inline void setFluidViscosity(float v)
{
_viscosity = v;
_A = 6 * osg::PI * _viscosity;
_viscosityCoefficient = 6 * osg::PI * _viscosity;
}
/// Get the viscosity of the fluid.
@ -51,7 +51,7 @@ namespace osgParticle
inline void setFluidDensity(float d)
{
_density = d;
_B = 0.2f * osg::PI * _density;
_densityCoefficeint = 0.2f * osg::PI * _density;
}
/// Get the density of the fluid.
@ -65,15 +65,15 @@ namespace osgParticle
inline const osg::Vec3& getWind() const { return _wind; }
/// Set the acceleration vector.
inline void setAcceleration(const osg::Vec3& v) { _acceleration = v; }
inline void setAcceleration(const osg::Vec3& v) { _viscosityCoefficientcceleration = v; }
/// Get the acceleration vector.
inline const osg::Vec3& getAcceleration() const { return _acceleration; }
inline const osg::Vec3& getAcceleration() const { return _viscosityCoefficientcceleration; }
/** Set the acceleration vector to the gravity on earth (0, 0, -9.81).
The acceleration will be multiplied by the <CODE>scale</CODE> parameter.
*/
inline void setToGravity(float scale = 1.0f) { _acceleration.set(0, 0, -9.81f*scale); }
inline void setToGravity(float scale = 1.0f) { _viscosityCoefficientcceleration.set(0, 0, -9.81f*scale); }
/// Set the fluid parameters as for air (20°C temperature).
inline void setFluidToAir()
@ -99,13 +99,13 @@ namespace osgParticle
virtual void execute(double dt);
osg::Vec3 _acceleration;
osg::Vec3 _viscosityCoefficientcceleration;
float _viscosity;
float _density;
osg::Vec3 _wind;
float _A;
float _B;
float _viscosityCoefficient;
float _densityCoefficeint;
};

View File

@ -8,12 +8,12 @@ osgParticle::FluidProgram::FluidProgram():
osgParticle::FluidProgram::FluidProgram(const FluidProgram& copy, const osg::CopyOp& copyop):
Program(copy, copyop),
_acceleration(copy._acceleration),
_viscosityCoefficientcceleration(copy._viscosityCoefficientcceleration),
_viscosity(copy._viscosity),
_density(copy._density),
_wind(copy._wind),
_A(copy._A),
_B(copy._B)
_viscosityCoefficient(copy._viscosityCoefficient),
_densityCoefficeint(copy._densityCoefficeint)
{
}
@ -32,11 +32,11 @@ void osgParticle::FluidProgram::execute(double dt)
float Volume = Area*radius*four_over_three;
// compute force due to gravity + boyancy of displacing the fluid that the particle is emersed in.
osg::Vec3 force = _acceleration * (particle->getMass() - _density*Volume);
osg::Vec3 force = _viscosityCoefficientcceleration * (particle->getMass() - _density*Volume);
// compute force due to friction
osg::Vec3 relative_wind = particle->getVelocity()-_wind;
force -= relative_wind * Area * (_A + _B*relative_wind.length());
force -= relative_wind * Area * (_viscosityCoefficient + _densityCoefficeint*relative_wind.length());
// divide force by mass to get acceleration.
force *= particle->getMassInv()*dt;