Replying to my own message ... I see a couple simple code cleanups in my
first patch so don't worry too much about that.  I've been flying tight
level circles in a variety of wind conditions (up to 70 kts) with smoke
turned on and when I come around and start the circle again, I've been
flying into the tail of my own smoke now no matter what the wind is doing.
 So I think that's how it's supposed to work.  It looks *much* better.

Curt.


On Thu, Jul 22, 2010 at 9:55 AM, Curtis Olson wrote:

> On the topic of the partical system and the wind vector not being correct.
>  I have a patch here that seems to be working, and it would be great if a
> few other people could test/review it to see if it makes sense.  This is the
> first time I've dove into the particle system code and the environment
> manager has always been a bit of a beast.  There's probably a better way to
> do this, but as I worked my way through the logic, this is what I ended up
> with that made sense to me.
>
> SIMGEAR PATCH:
>
> diff --git a/simgear/scene/model/particles.cxx
> b/simgear/scene/model/particles.cxx
> index 0803790..acac7df 100644
> --- a/simgear/scene/model/particles.cxx
> +++ b/simgear/scene/model/particles.cxx
> @@ -62,11 +62,13 @@ void GlobalParticleCallback::operator()(osg::Node*
> node, osg::NodeVisitor* nv)
>      osg::Matrix om(toOsg(q));
>      osg::Vec3 v(0,0,9.81);
>      gravity = om.preMult(v);
> +    // NOTE: THIS WIND COMPUTATION DOESN'T SEEM TO AFFECT PARTICLES
>      const osg::Vec3& zUpWind = Particles::getWindVector();
> -    osg::Vec3 w(zUpWind.y(), zUpWind.x(), - zUpWind.z());
> +    osg::Vec3 w(zUpWind.y(), zUpWind.x(), -zUpWind.z());
>      wind = om.preMult(w);
>
> -    //SG_LOG(SG_GENERAL, SG_ALERT, "wind
> vector:"<<w[0]<<","<<w[1]<<","<<w[2]<<"\n");
> +    // SG_LOG(SG_GENERAL, SG_ALERT,
> +    //        "wind vector:" << w[0] << "," <<w[1] << "," << w[2]);
>  }
>
>
> diff --git a/simgear/scene/model/particles.hxx
> b/simgear/scene/model/particles.hxx
> index 6dda343..3fd3ccb 100644
> --- a/simgear/scene/model/particles.hxx
> +++ b/simgear/scene/model/particles.hxx
> @@ -257,6 +257,14 @@ public:
>       * magnitude is the velocity in meters per second.
>       */
>      static void setWindVector(const osg::Vec3& wind) { _wind = wind; }
> +    static void setWindFrom(const double from_deg, const double speed_kt)
> {
> +       double map_deg = 0.0 - from_deg;
> +       double map_rad = map_deg * SG_DEGREES_TO_RADIANS;
> +       double speed_mps = speed_kt * SG_KT_TO_MPS;
> +       _wind[0] = cos(map_rad) * speed_mps;
> +       _wind[1] = sin(map_rad) * speed_mps;
> +       _wind[2] = 0.0;
> +    }
>      static const osg::Vec3& getWindVector() { return _wind; }
>  protected:
>      float shooterExtraRange;
>
> FLIGHTGEAR PATCH:
>
> diff --git a/src/Environment/environment_mgr.cxx
> b/src/Environment/environment_mgr.cxx
> index 15268f9..17d1e36 100644
> --- a/src/Environment/environment_mgr.cxx
> +++ b/src/Environment/environment_mgr.cxx
> @@ -295,7 +295,10 @@ FGEnvironmentMgr::update (double dt)
>    osg::Vec3 windVec(-_environment->get_wind_from_north_fps(),
>                      -_environment->get_wind_from_east_fps(),
>                      _environment->get_wind_from_down_fps());
> -  simgear::Particles::setWindVector(windVec * SG_FEET_TO_METER);
> +  // simgear::Particles::setWindVector(windVec * SG_FEET_TO_METER);
> +  double wind_true_deg = _environment->get_wind_from_heading_deg();
> +  simgear::Particles::setWindFrom( wind_true_deg,
> +                                  _environment->get_wind_speed_kt() );
>  }
>
>  FGEnvironment
>
> Curt.
>
>
> On Thu, Jul 22, 2010 at 4:25 AM, Stuart Buchanan wrote:
>
>> On Wed, Jul 21, 2010 at 5:00 PM, Torsten Dreyer wrote:
>> > I don't know if it's somehow related, but the 3d clouds don't seem to
>> drift
>> > with the wind, either. Flying with  crosswind with a magnitude as your
>> > airspeed let you fly toward the clouds at a 45 degree angle. My setup
>> was:
>> > Wind from 1...@100, flying heading 270 with 100KTS. The clouds came in
>> from
>> > 45degrees out of the right hand side.
>> >
>> > Torsten
>>
>> That's just a missing feature/bug in the 3d clouds, and I don't think
>> it's related
>> to the particles problem. I haven't managed to find the time to fix
>> it, and I'm unlikely
>> to in the near future (baby due end of August), so if anyone is
>> looking for some work...
>>
>> -Stuart
>>
>>
>> ------------------------------------------------------------------------------
>> This SF.net email is sponsored by Sprint
>> What will you do first with EVO, the first 4G phone?
>> Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
>> _______________________________________________
>> Flightgear-devel mailing list
>> Flightgear-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/flightgear-devel
>>
>
>
>
> --
> Curtis Olson: http://baron.flightgear.org/~curt/
>



-- 
Curtis Olson: http://baron.flightgear.org/~curt/
------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel

Reply via email to