Where Am I?

A thread on FlightSim.com’s FSX forum caught my attention recently. In short the person was frustrated that when you drift off the runway while using ATC in FS2004 you get told to “contact ground”. In this user’s case he was doing pattern work and likely just got a little sloppy. He wanted ATC to be smart enough to recognize this and let him straighten out and take off again. It got me thinking.

 

First off, though, I know from personal experience this would not be “as real as it gets”. I’ve been (mis-)fortunate enough to “depart the paved surface” 4 times in my flying career. Three of those were in my own aircraft (a Maule M7-235-C) at my home airport, which is uncontrolled. The other happened in my instructor’s J-3 while I was a student pilot and returning from my first solo long cross-country flight. My route took me from Seattle to Bellingham with a stop in Arlington and I had been fighting strong headwinds on the return leg (watching traffic on I-5 outpace me). All in all I’d been flying for almost 3 hours when I started my final approach. Exhausted, I committed the cardinal sin of tail wheel landings by relaxing my concentration (as well as my “dancing feet”). I don’t remember whether I caught a gust or was just not tracking straight but immediately after touching down the tail bounced and started to wander around toward the nose. Luckily I kept the tail behind the nose but did wander off the runway a few feet before coming to a stop. The tower controller was kind enough to ask me if I was alright (after which he asked if I had run over any runway lights) before giving me my taxi clearance. So, even a few feet off the runway is enough to get the attention of ATC.

 

But I digress. (Yes, I know. This shocks you.) Anyway, to understand the problem it helps to know a little about how ATC works in Flight Sim, specifically that ATC does not store very much information about your intentions. Instead it tracks and continuously computes your state. What do I mean by state? In the case of ATC state is information such as: are you on the ground or in the air? Have you requested flight following? Do you have an active flight plan? Do you owe ATC a response to a clearance?

 

Why does it work this way? Because you can do things in the game that you can’t do in the real world. For example, consider what happens when you first launch a flight. You’re sitting at the end of the runway and the ATC menu options (at a controlled airport) are to contact ground or tune ATIS. Suppose you then enter slew mode, jump up to a thousand feet, and switch back to flying. If ATC simply thought you were about to contact ground it would be pretty confused to suddenly see you in the air! Instead it re-computes your state and offers you a set of appropriate options. In this case it shows you the nearest airport list so you can contact the tower and ask for landing clearance if you’d like. So the moral is that just because you tell ATC what you intend to do doesn’t mean ATC can trust you!

 

One suggestion in the thread was to have more tolerance in FlightSim for where the aircraft is in relation to the pavement. This got me thinking about how the game engine determines where the aircraft is in the world. It’s a far more interesting and difficult problem than I thought it was the first time I had to consider it.

 

Ignoring the third dimension for a second let’s think about an aircraft sitting on the ground at an airport. Where is it, really? Is it on the runway? How do we know? In this case we can simplify things by reducing the aircraft down to a single reference point and perform a point-in-polygon computation against the rectangular runway. Point-in-polygon queries are very common in any 2D or 3D game and by themselves they are very fast math operations. But you need to be careful not to make too many of them or make them too often otherwise you might drag down performance. The “is the aircraft on the runway?” calculation is nice because the runway is a simple polygon. Extend the same logic to taxiways and aprons and the number of calculations explodes. That’s why it’s much easier for ATC to ask “is the aircraft on the runway?” than “is the aircraft on a taxiway?” or “is the aircraft near a runway?”

 

Another issue is where the data for these polygons is stored. The game engine in Flight Sim is made up of a number of independent but related systems. In order for ATC to know whether the aircraft is on the runway it needs to have access to data structures that represent the aircraft and runway in 2D space. Some of this data is also needed to do things like render the runway on top of the terrain—a completely different system. Where should this data be stored? The simulation system? The terrain system? Some other system? It doesn’t make sense to duplicate it yet each system needs the data for different reason. For example, taxiway data (a network of nodes and lines) is passed to a system that constructs 2D polygons used to render the airport but the elements significant to ATC aren’t retained. Furthermore, the airport renderer may do things like add extra polygons at intersections to create smooth curves. ATC cannot query for this information. The sim engine can, since it needs to know whether the aircraft is on a hard surface or not, but it doesn’t distinguish a hard surface taxiway from runways, apron, roads, helipads, etc.

 

And, hey, let’s not go into having a third dimension to deal with complicates things!

 

In summary, a lot of effort goes into designing interdependent systems and data structures in order to find the right balance of functionality and performance (as defined by memory usage and CPU cycles). As long as we need to make tradeoffs to find this balance there will always be situations where the game doesn’t behave like you would expect or desire. But do trust that with every version we try to take advantage of greater hardware capabilities and programming techniques to make Flight Sim more and more like the real world.