Submodels: Fix wind being applied twice on init
For FGAIBallistic objects affected by wind, speed vector denotes airspeed. However, submodels initialize the speed vector using ground speed of the parent aircraft, instead of its airspeed. In effect, this means that wind is added to the initial airspeed, or 'wind is applied twice on initialization'. This was very noticeable when releasing a submodel with strong sidewind: the submodel immediately starts drifting laterally at the speed of wind. Fix the issue by subtracting wind vector from initial speed in FGSubmodelMgr::transform for submodels affected by wind.
This commit is contained in:
parent
43d32e809c
commit
fa09c3a6e2
1 changed files with 7 additions and 0 deletions
|
@ -391,6 +391,13 @@ void FGSubmodelMgr::transform(submodel *sm)
|
|||
IC.wind_from_east = _user_wind_from_east_node->getDoubleValue();
|
||||
IC.wind_from_north = _user_wind_from_north_node->getDoubleValue();
|
||||
|
||||
// For submodels affected by wind, convert ground speed to airspeed by subtracting wind.
|
||||
// Since the wind frame is inverted (wind_*from*_{east,north}), the wind values are added.
|
||||
if (sm->wind) {
|
||||
IC.speed_east_fps += IC.wind_from_east;
|
||||
IC.speed_north_fps += IC.wind_from_north;
|
||||
}
|
||||
|
||||
userpos.setLatitudeDeg(IC.lat);
|
||||
userpos.setLongitudeDeg(IC.lon);
|
||||
userpos.setElevationFt(IC.alt);
|
||||
|
|
Loading…
Add table
Reference in a new issue