I am working on making the transition between different sectors of space completely seamless. It will be a work in progress for a while, but when finished we will have a shockingly large and awesome infinite seamless world.
Why sector boundaries
Before talking about the process of stitching sectors together, I should probably explain why they were ever apart to begin with.
These big infinite space games always come into the problem of storing positions in floating point numbers because when your position vector gets too big (far from the center of the map) 32 bits stops being enough data to store where you are and movement gets jerky and twitchy. In Wayward Terran Frontier positions are stored as single precision (32 bit) because that's what the graphics API likes and at the scale we want even double precision isn't enough.
In order to make the universe infinite we created sectors with integer coordinates, and then the size of each sector is bounded by the limits of single precision floating point values. As is always the case, our infinite universe isn't actually truly infinite because it is bound by the limitations of signed integers multiplied by the limitations of single precision floating point numbers(arbitrarily chosen at +-100000.0)...a staggering size no doubt. Maybe some day I'll dedicate a tiny corner of the WTF universe to store a minecraft world or two.
Fun fact: a Minecraft block is 2 pixels wide in Wayward Terran Frontier and a Minecraft world would cover a square region 600 sectors tall.
Other fun fact: our universe map generates as images on the GPU in square regions which are 512x512 pixels tall, with each pixel ultimately turning into a sector. You'd need to generate 4 regions to fit a Minecraft world.
Final fun fact: space ships go a lot faster than a human can walk
Since of course we can't fit infinite sectors in memory we store sectors to disk when you aren't looking at them. This makes it hard to render them, but of course there's no point being able to see them since every item in that sector has the wrong position until you are in that sector, so why bother right? This issue extends to all things in a sector: since there is an entire coordinate space for objects inside every sector, it's hard for things like AI to search for enemies across sectors, or bullets to hit across sectors. Those items simply don't exist in the same reference frame.
Until now
I've just rewritten the session logic, world data structures, faction logic, and many other things to make session loading smoother. Before, crossing the boundary of a session would trigger a new session object to be constructed and the old session object to be deconstructed. Of course reading and writing from the hard disk was always done asynchronously, but to an intermediary format that wasn't a full session. There was a significant lag during the transition when the intermediary format was translated into a full session. All of this was to support the fact that only 1 session object could ever exist at once.
The primary change of the new system removes the restriction of having only a single session active at any one time, and makes creating the session just another asynchronous step to be taken in preparation of the player's movements. Now sectors near the player are loaded from the disk asynchronously, and sectors immediately adjacent to the player get turned into sessions asynchronously. When the player crosses that border, they simply swap one reference and there is zero lag.
Other benefits
The existence of other sectors in memory has other benefits as well like allowing us to render them, or giving us the power to properly simulate things the player isn't looking at. It is still an engineering challenge because everything you do across sectors needs to work in multiple coordinate systems at once.
Initially terrain, stations, and ships will be rendered across sector boundaries so you can see the rocks you might fly into before entering a session. In the future I may even try to get bullets and AI logic to work across boundaries, but not in the first release because that's going to be a hell of a challenge on its own. Yes I will simply accept that this is likely to cause lots of bug reports: "I saw a ship but it didn't see me!" and that sort of thing.
We can also now run full simulations of things when needed. I have all sorts of evil plans for that feature in the future. For example if I were to make wild speculative gestures (which should in no way be taken as an indication of planned content or future development goals) I'd say I could do something like having battle wreckage created the easy way (simulating actual battles), or allow AI to have more complex off-screen behaviors like mining or construction.
Note that the extent to which I will be able to render and update sectors other than the player's is going to weigh very heavily on machine performance. I may even need to set up some simulation complexity slider that lets you tune down the draw distance on a slow computer. Having more CPU cores and memory will actually make a pretty big difference for off-screen simulations since my framework allows literally all of it to be offloaded to another thread (or threads). Initially I suspect the default settings will try to be relatively tame, using as little extra resources as it can, but I chose PC as my platform because I wanted to abuse the best hardware available, and abuse it we shall.
Other things we're working on
Aside from this and power management systems we have a few other projects in the works.
- Jan is experimenting with some crazy unreasonably awesome looking secret backdrop eye candy project. (our hope is that in combination with seamless boarders the visuals should make your brain explode)
- I have made some upgrades to how the game handles missiles to support different sizes of missile, different types of ordinance, rendering missile magazines and launchers in a way that displays the ordinance type, etc.
- I have added some new missile types and missile related module types to the game engine.
- I have started initial work on a new top secret project relating to interesting things you might find when exploring taverns.
- I have drawn onto a napkin some designs which may allow future workshop mods to add stations into the single player game world similar to how flotillas work, but also with the power to place them manually into the world to be created as part of world generation.