Author Topic: Airplane Flight Height Patch for simutrans-extended  (Read 2768 times)

0 Members and 1 Guest are viewing this topic.

Offline Phystam

Airplane Flight Height Patch for simutrans-extended
« on: September 11, 2017, 04:08:04 PM »
Hi!
Today is 9.11. I pray for the souls of the victims...
By the way, in the simutrans world, the airplanes fly at very low altitude and collide with many buildings very frequently...
So, to improve this issue ( and save the innocent citizens in simutrans world! ), I developed a patch called "AFH Patch."
The detailed behavior is shown in following video.
Let's discuss it!

Offline Phystam

Re: Airplane Flight Height Patch for simutrans-extended
« Reply #1 on: September 13, 2017, 07:35:33 AM »
The attached file is the AFHP-patch file, this is the corrected version from the youtube demo version.
This patch do not change the compatibility in this version.
In this version, you can change the altitude from "SET_FLIGHT_HEIGHT" global constant in "vehicle/simvehicle.h".

In the future, I want to change the altitude depending on the flight top speed, or setting in "simuconf.tab".
I prefer the former method not to break the compatibility and the reality.
Small aircrafts like Cessna should fly low altitude, on the other hand, large aircrafts like Boeing should fly very high altitude.

So I would like to ask you to do this, how high is the height per half-height in the simutrans-extended world?
If the "meter_per_tile" is 50m? 125m? 500m?

Offline THLeaderH

Re: Airplane Flight Height Patch for simutrans-extended
« Reply #2 on: September 13, 2017, 07:53:33 AM »
This is so fantastic! I want this feature in simutrans standard too 8)

Offline Phystam

Re: Airplane Flight Height Patch for simutrans-extended
« Reply #3 on: September 13, 2017, 03:42:09 PM »
And this is the download link of AFH-Patched binary file for Linux [ubuntu 14.04, 64bit]. I think it is available for debian-base 64bit linux system. In this version, the flight height is defined as 20. Please check it in your linux environment ;)

Offline DrSuperGood

Re: Airplane Flight Height Patch for simutrans-extended
« Reply #4 on: September 13, 2017, 10:41:50 PM »
How does this solve the graphics problem? The reason aircraft in Simutrans fly so low is because the graphic engine will only show the sprite up to a certain altitude above ground for performance reasons (or so I have read?), with the plane becoming invisible when it exceeds this altitude.

Offline sheldon_cooper

Re: Airplane Flight Height Patch for simutrans-extended
« Reply #5 on: September 14, 2017, 03:04:15 AM »
this is great, when I started playing simutrans, one of the old versions, the planes were flying high for some reason, now with the new versions, they fly low.

How does this solve the graphics problem? The reason aircraft in Simutrans fly so low is because the graphic engine will only show the sprite up to a certain altitude above ground for performance reasons (or so I have read?), with the plane becoming invisible when it exceeds this altitude.

It depends on the players, many use zoon +, -, to enlarge the screen in a more dynamic game, in this, with the airplanes flying at that time, it will not be a problem, and will not be having those bugs, of the planes entering the property (unless if the property is really high ???)

Offline DrSuperGood

Re: Airplane Flight Height Patch for simutrans-extended
« Reply #6 on: September 14, 2017, 05:00:47 AM »
Quote
It depends on the players, many use zoon +, -, to enlarge the screen in a more dynamic game, in this, with the airplanes flying at that time, it will not be a problem, and will not be having those bugs, of the planes entering the property (unless if the property is really high )
As far as I could understand the problem is that the graphic engine only looks for sprites up to a certain number of units above ground. If the plane flys above this limit its sprite is not drawn on the screen. This is why requests for better aircraft flight logic have been repeatedly denied in standard as there was no reasonable or non regressive solution.

EDIT: Just noticed this was for extended. Maybe extended removed such sprite draw limit?

Offline Phystam

Re: Airplane Flight Height Patch for simutrans-extended
« Reply #7 on: September 15, 2017, 01:33:39 AM »
I don't know about the graphic limits in Standard, but in my opinion, the airplanes should fly higher if there's no or few limit to draw the graphics.
In my simple test, there are no bugs except for the tracing zoom window (I think it is out of range of drawing) even if SET_FLIGHT_HEIGHT = 50.
SET_FLIGHT_HEIGHT = 20 and 30 looks very nice performance including the tracing window.

What to do are:
 ・drawing test with high buildings
 ・drawing test with highly elevated ways

Offline jamespetts

  • Simitrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 15858
  • Total likes: 407
  • Helpful: 177
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Airplane Flight Height Patch for simutrans-extended
« Reply #8 on: September 16, 2017, 05:40:18 PM »
Thank you very much for your work on this, and apologies for the delay in replying: I have been spending a lot of time catching up with things after being on holiday in the last week.

This is a very interesting patch, and it certainly looks better having the aircraft fly higher. I have not had a chance to test it in detail at this juncture; however, I notice that the aircraft in the video touches down part-way along the runway rather than at the beginning of the runway, which does not seem correct, as aircraft in reality will always touch down near the beginning of the runway. Also, have you changed the code in Simutrans-Extended which causes aircraft to lift off when they have reached their minimum runway length irrespective of the actual length of the runway? From the video, this does not appear to be working in this version.

As to the flying height graphics issues, I have not modified this from Standard; indeed, the graphics engine is more or less completely unaltered from Standard, and I know very little about how the graphics in Simutrans work, so cannot comment in any detail on this.

May I suggest that you test this by trying to have aircraft fly over high mountains with your patch and see what happens? One possibility (although I am not sure how to code this) to resolve this issue would be to have aircraft maintain the maximum of a fixed height above sea level (no matter what the height of the terrain) and a fixed height of one or two tiles above the terrain, so that aircraft do not crash into mountains. This would also avoid the currently very annoying effect where aircraft jump up and down when flying over any undulations in the terrain.

Thank you again for your work on this - it is much appreciated.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Offline Phystam

Re: Airplane Flight Height Patch for simutrans-extended
« Reply #9 on: September 16, 2017, 07:18:54 PM »
Thank you very much for your reply!

Actually, the video is very preliminary version so I posted the improved patch file and binary file than video version.
It is normal performance that aircraft touches down at the beginning of the runway.

This is the latest version of AFHPatch binary for windows 64bit.
Please put it in your simutrans directory with libwinpthread-1.dll.
https://1drv.ms/f/s!An79lcCxORLxhe19nTTFE822bfx1Hg
Features:
 - the altitude depends on the top speed of the aircraft.
Code: [Select]
   altitude = top_speed[km/h] / 33
   if the altitude is less than 5, altitude = 5
   if the altitude is larger than 30, altitude = 30
   slower aircraft flies lower, and faster aircraft flies higher. the factor 33 is roughly estimated value.
 - the compatibility is still kept.
 - aircraft touches down at the beginning of the runway, around "touch down zone".
 - calculation time is negligible order.

If you find some bugs, please report it!

Offline jamespetts

  • Simitrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 15858
  • Total likes: 407
  • Helpful: 177
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Airplane Flight Height Patch for simutrans-extended
« Reply #10 on: September 16, 2017, 08:33:08 PM »
Thank you for this. Have you been able to test the issue with mountains discussed above yet?
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Offline Phystam

Re: Airplane Flight Height Patch for simutrans-extended
« Reply #11 on: September 17, 2017, 05:40:56 AM »
Hello!
I made a video for the latest version.
In this version, low mountains will not affect the aircraft.
Watch here:

Offline jamespetts

  • Simitrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 15858
  • Total likes: 407
  • Helpful: 177
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Airplane Flight Height Patch for simutrans-extended
« Reply #12 on: September 17, 2017, 09:21:21 AM »
Very interesting, thank you for that! Have you had a chance to test whether the graphic for the aircraft disappears over very high mountains/plateaux yet, as discussed by Dr. Supergood above?
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Offline Phystam

Re: Airplane Flight Height Patch for simutrans-extended
« Reply #13 on: September 17, 2017, 11:07:43 AM »
Quote
Have you had a chance to test whether the graphic for the aircraft disappears over very high mountains/plateaux yet, as discussed by Dr. Supergood above?
Although I tested with the highest mountain in simutrans, the graphic for the aircraft would not disappear.
However aircraft collides with high mountains because aircraft can move up only by half slope, not full slope. Actually there are no effects in this game, and we usually use relatively low mountains so we will not see it.
I have not tested this issue with master branch of Extended yet but I think there is same issue in master branch.

Offline Phystam

Re: Airplane Flight Height Patch for simutrans-extended
« Reply #14 on: September 17, 2017, 11:22:11 AM »
I confirmed this issue in master branch. there is same behavior which aircraft collides high mountains while crossing.

Offline jamespetts

  • Simitrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 15858
  • Total likes: 407
  • Helpful: 177
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Airplane Flight Height Patch for simutrans-extended
« Reply #15 on: September 17, 2017, 11:59:53 AM »
Thank you very much for testing this: that is most helpful. Are you able to put your code on Github? That would be most helpful for further testing and integration.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Offline Yona-TYT

Re: Airplane Flight Height Patch for simutrans-extended
« Reply #16 on: September 17, 2017, 01:37:24 PM »
This is so fantastic! I want this feature in simutrans standard too 8)

It's already two, hehehe... 
But the project is very interesting.  ;D

Offline Phystam

Re: Airplane Flight Height Patch for simutrans-extended
« Reply #17 on: September 17, 2017, 02:02:39 PM »

Offline jamespetts

  • Simitrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 15858
  • Total likes: 407
  • Helpful: 177
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Airplane Flight Height Patch for simutrans-extended
« Reply #18 on: September 17, 2017, 03:17:50 PM »
Thank you very much for that. I have now had a chance to test this - see the AFHP branch on my Github repository where I have merged your latest code. However, I think that I may not have the latest version: I have version 2.1, whereas the video refers to version 2.2, and some of the latest updates (the aircraft always landing at the beginning of the runway and the aircraft not jumping up and down when going over hills in flight, for instance) do not appear to be implemented.

Also, there appear to be some issues: have a look at this saved game, for instance. Watch the aircraft coming into land at Manthorne Airport: you will see that they almost come to a halt over the hangar before speeding up again and touching down on the runway.

Thank you again for your work so far - it is much appreciated.

Edit: This patch also appears to cause aircraft incorrectly to claim that the runway is too short and refuse to land in some cases: see the above saved game, and watch Concorde approaching Manthorne airport, for instance.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Offline Phystam

Re: Airplane Flight Height Patch for simutrans-extended
« Reply #19 on: September 17, 2017, 04:28:49 PM »
What I say as v2.2 is included in v2.1 branch. I am sorry that I confused you.
As you say, I saw the very slow aircraft while landing. I think it is caused by taxi way whose topspeed is 20km/h, this should be ignored.
I'm now working for this issue...

Offline jamespetts

  • Simitrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 15858
  • Total likes: 407
  • Helpful: 177
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Airplane Flight Height Patch for simutrans-extended
« Reply #20 on: September 17, 2017, 04:42:47 PM »
Excellent, thank you. I should be grateful if you could also look into the issue with the false detection of runways being too short, too.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Offline Phystam

Re: Airplane Flight Height Patch for simutrans-extended
« Reply #21 on: September 18, 2017, 03:06:11 PM »
Thank you very much for your comments!
I solved some known issues such as landing top speed above taxiways, the incorrect reservation behavior and so on.
The AFHP-v3 executable and the github branch is available here:
https://1drv.ms/f/s!An79lcCxORLxhe19nTTFE822bfx1Hg
https://github.com/Phystam/simutrans-extended/tree/merged-AFHP-v3
This patch is based on your merged branch.
Please check and test it!

Offline jamespetts

  • Simitrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 15858
  • Total likes: 407
  • Helpful: 177
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Airplane Flight Height Patch for simutrans-extended
« Reply #22 on: September 18, 2017, 05:41:50 PM »
Thank you very much for your progress with this. I have now had a chance to test it. The glideslope issues at Manthorne do now appear to have been addressed: thank you for that. Likewise, I cannot see any incorrect reports of runways being too short for aircraft any longer.

However, I notice some new issues, which can all be reproduced with the existing air-test-3 game. Firstly, have a look at convoy no. 6, the red ford Trimotor departing from Manthorne airport. This does not take off properly, but rather seems to take to the air at an odd angle to the runway. If you wait/fast forward, it will do the same thing at Crobury Airfield when it takes off from there, too.

Also, the Concorde aircraft seems to be displaying some very odd behaviour, in that it appears to be constantly flying towards Manthorne Airport and then teleporting back a few tiles. I do not know whether this is related to the runway length issue from the earlier version of this code. I do know that the runway at Manthorne Airport is only just long enough for Concorde to land there. I also notice that some aircraft still touch down part-way along the runway: have a look at Crobury Airfield, for instance: if you wait until just before the red Ford Trimotor leaves, you will see a turboprop aircraft landing: this will touch down about a third of the way along the runway.

In any event, thank you very much for your work on this. It does really look better when aircraft fly higher and then have an extended glideslope when coming into land. Once the remaining issues are solved, this should be a splendid addition to the code.

Edit: Also, one other thing that I forgot to mention: I see that you modified the makefile so that the minGW build is now a 64-bit Windows build. I should be very grateful if you could revert that change, as the nightly build server builds a 32-bit Windows executable; if you want a 64-bit Windows executable, may I suggest that you create a separate makefile entry for 64-bit minGW so that both 32-bit and 64-bit options are available?

Thank you again for your work on this.
« Last Edit: September 18, 2017, 11:03:10 PM by jamespetts »
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Offline Phystam

Re: Airplane Flight Height Patch for simutrans-extended
« Reply #23 on: September 19, 2017, 03:23:34 AM »
Thank you very much for your report! I pushed the fixed version --- please test it.
However the teleporting of the Concorde cannot be reproduced finally... Please re-schedule for this aircraft. I think the touchdown point is incorrect due to the previous version.
And the Makefile has been changed in order to compile with both 64bit and 32bit. Use "OSTYPE=mingw64" or "OSTYPE=mingw32" instead of "OSTYPE=mingw".

Anyway, I am glad for the merging of this patch!

Offline jamespetts

  • Simitrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 15858
  • Total likes: 407
  • Helpful: 177
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Airplane Flight Height Patch for simutrans-extended
« Reply #24 on: September 19, 2017, 09:19:23 AM »
Thank you for your work on this. I have now merged your latest changes into the AFHP branch on my Github repository. The issue with aircraft taking off diagonally appears not to be fully fixed, however: if you take the same convoy (no. 6, the red Ford Trimotor) and, while it is taxiing at Manthorne Airport from the runeay at which it landed towards the main terminal complex, change its schedule to send it back towards Crobury, the same takeoff at an angle to the runway as before can be observed.

Also, I have noticed that, for higher flying aircraft (I tested with Concorde and the Dreamliner), the image is not correctly displayed in the convoy information window: instead, the dark grey background colour is displayed, with a small fragment of the land below. Perhaps this relates to the issue discussed by Dr. Supergood above?

Thank you again for your work on this - it is appreciated.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Offline Phystam

Re: Airplane Flight Height Patch for simutrans-extended
« Reply #25 on: September 20, 2017, 03:59:53 PM »
Finally I solved the convoy window issue!
Please see my github branch: https://github.com/Phystam/simutrans-extended/tree/merged-AFHP-v4
I changed only 2 points in gui/components/gui_world_view_t.cc, the limitation of object drawing.
So I propose to obsolete the upper limit of drawing convoy, like this:
Code: [Select]
gui_world_view_t.cc:L181

  if( 0 <= yypos + raster && yypos - raster * 2 < size.h ) {
#ifdef MULTI_THREAD
    plan->display_obj( pos.x + off_x, pos.y + yypos, raster, false, hmin, hmax, 0 );
#else
    plan->display_obj( pos.x + off_x, pos.y + yypos, raster, false, hmin, hmax );
#endif
  }
to
Code: [Select]
gui_world_view_t.cc:L181

  if( 0 <= yypos + raster ) { // <- obsoleted upper limit
#ifdef MULTI_THREAD
    plan->display_obj( pos.x + off_x, pos.y + yypos, raster, false, hmin, hmax, 0 );
#else
    plan->display_obj( pos.x + off_x, pos.y + yypos, raster, false, hmin, hmax );
#endif
  }
Are there something inconvenient with this modification? ( I don't know it so I have used the upper limit as size.h * 3 currently)

Offline jamespetts

  • Simitrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 15858
  • Total likes: 407
  • Helpful: 177
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Airplane Flight Height Patch for simutrans-extended
« Reply #26 on: September 20, 2017, 09:11:11 PM »
Splendid, thank you for that. From what I understand, the reason for this limitation is that it is thought that, without the limitation, the graphics code would take too much CPU power. Are you able to profile the game before and after this change to check whether the CPU usage increases significantly with your change?
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Offline Phystam

Re: Airplane Flight Height Patch for simutrans-extended
« Reply #27 on: September 21, 2017, 09:54:52 AM »
Thank you for your comment. Actually, in my experiment, there's no change in CPU usage with my poor linux machine [scientific linux 6.0 i686, Intel(R) Core(TM)2 Duo CPU E7400  @ 2.80GHz], and they were around 40% both with your save data while tracing the Concorde.
I think that the convoy objects above a certain tile are at most less than 5 objects, usually only 1 object, so the calculation steps of drawing objects will not increase without the limitation!

Offline jamespetts

  • Simitrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 15858
  • Total likes: 407
  • Helpful: 177
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Airplane Flight Height Patch for simutrans-extended
« Reply #28 on: September 23, 2017, 08:49:13 PM »
Thank you very much for testing this, and apologies for the delay in replying. My own tests using MSVS 2015's profiler show a potential, but small, increase in CPU usage in dr_flush_screen from ~5% to ~6-7%. This is probably tolerable given the great improvement that this patch makes to aircraft flight. I have merged your v4 branch into my AFHP branch.

However, there is still an issue with runway length. In this saved game, there is a Lockheed Tristar waiting at the airport. Its minimum runway length is a little over 2,400m. The runway at that and its destination airport is 2,500m long - just long enough for the aircraft to take off and land. On the master branch, this aircraft takes off and lands without problem. However, on the AFHP branch, the aircraft will refuse to depart the airport, citing "no route".

I should be grateful if you could look into this. Thank you for your work on this so far.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Offline sheldon_cooper

Re: Airplane Flight Height Patch for simutrans-extended
« Reply #29 on: September 26, 2017, 12:39:39 AM »
Hello, where can I find a compatible version with my windows? (use Windows 7, 32 bit) ..

Offline jamespetts

  • Simitrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 15858
  • Total likes: 407
  • Helpful: 177
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Airplane Flight Height Patch for simutrans-extended
« Reply #30 on: September 26, 2017, 07:10:06 AM »
There is no binary version released for this yet, but, once it us ready, it will be incorporated into the main version.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Offline Phystam

Re: Airplane Flight Height Patch for simutrans-extended
« Reply #31 on: September 28, 2017, 03:18:31 PM »
Hello, and I'm sorry for late response.
I am now in southern coast of France in order to attend a summer school so it is difficult to connect the internet.
I will restart to develop and debug this patch after going back to Japan (~4th Oct.)!
Be looking forward to incorporation of this patch!

P.S.> I'm sorry, I have not prepared the 32bit minGW yet, so I cannot build win 32bit version.

Offline jamespetts

  • Simitrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 15858
  • Total likes: 407
  • Helpful: 177
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Airplane Flight Height Patch for simutrans-extended
« Reply #32 on: September 28, 2017, 06:09:46 PM »
Splendid, thank you. Enjoy the summer school and France!
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Offline Phystam

Re: Airplane Flight Height Patch for simutrans-extended
« Reply #33 on: October 08, 2017, 07:43:27 AM »
Hi, I found the reason why the aircraft says "no route".
In Extended edition, we cannot build runway close to the edge of your map. But this patch requires more landing distance than ever before.
The Lockheed aircraft cannot find the route to Bushney airport because the airport located very close to the edge in your save data.
Therefore I resolved this issue by indicating "airport too close to the edge" in addition to "no route".
I reflected this change in "merged-AFHP-v4" branch of my repository.

Offline jamespetts

  • Simitrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 15858
  • Total likes: 407
  • Helpful: 177
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Airplane Flight Height Patch for simutrans-extended
« Reply #34 on: October 08, 2017, 10:04:59 AM »
Thank you very much for checking this: that is most helpful. I am currently away from home and cannot easily check the code until I get back to-morrow; can I ask whether your patch also prohibits building a runway in any place where aircraft will not be able to land on it?
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.