Adventures in Hi-Fi Line of Sight!

It has been a while since the last update as I had decided to take a break from home development to free up some time for my many other hobbies. However, I’m now back!

My intention is not to add any new functionality, at least not just yet. Instead I want to concentrate on fixing all known issues and putting what I have through the wringer to make sure that everything is working as designed.

The first thing through the wringer is the Line Of Sight system. This system had many speed optimizations made to it, so it had to be thoroughly tested. It was during this testing that I found many subtle bugs.

Some of these had been introduced as the result of the optimizations, whilst others were down to the quantized nature of the terrain and the units (the old system could only handle elevations and unit heights in whole numbers only).

This limitation inevitably lead to heights and elevations that got rounded up. For example, a 1.8 metre high infantry unit would have its height rounded up to two metres.

There was code in place to try and mitigate this limitation, but it kept failing with many corner cases. So I kept adding more and more code, only to find other corner cases creeping out of the woodwork.

In the end I decided that instead of fighting the system, I would change it. As a result, terrain elevations and unit heights can now be specified up to 5 decimal places – assuming that you really want to do that sort of thing…. 😯

However, the more practical upshot of this modification is that units with a height of 1.8 metres are treated as units with that height, with no kind of mathematical workarounds having to be implemented! As a result, many of the subtle bugs that were in the system have simply disappeared! 🙂

Line of Sight is massively important to this game as I want to simulate the confusion of battle. The only way I can do this is by showing the player exactly what they would see on the battlefield if they were there. Hence the need for the high fidelity Line of Sight routines.

The Ancient Armies Line of Sight system has so many unique features that I have put together a new video that can be viewed at the end of this blog post.

For those that are challenged in the video department, here are some screenshots showing off some of these features:

The fidelity of the Line of Sight system is now so high, that the eye level for the Line of Sight tool has to be set, as different units can see different things due to their differing eye levels. Here it is shown in its default mode which is simulating the view from an Infantry unit.

The fidelity of the Line of Sight system is now so high, that the eye level for the Line of Sight tool has to be set. This is because different units can see differing things due to their varying eye levels. This screenshot shows the tool in its default mode which is simulating the view from an Infantry unit.

Here we are showing the Line of Sight tool being used on the 2 metre wall. The Line of Sight tool has its eye level set to that of an Infantry unit. As such its Line of Sight through the wall is blocked.

Here we are showing the Line of Sight tool being used on a 2 metre wall using its default settings.  The Line of Sight in this example is blocked as the wall is too high for an infantryman to peer over (Green is visible, Red is blocked).

The Line of Sight tool is now configurable by right clicking on its tool-button. This reveals a dialog window that can be used to set the tool's eye level height. This functionality had to be added due to the high fidelity of the Line of Sight system!

However, by right clicking on the Line of Sight tool’s tool-button, one is now presented with the opportunity to configure it! We are now going to select the simulated view point for a Cavalry unit…

Our Line of Sight tool is now set to simulate the view from a Cavalry unit. Lets see what happens now...

Our Line of Sight tool is now configured to simulate the view from a Cavalry unit. Lets see what happens with the 2 metre wall now…

This is the Line of Sight tool being used on the same 2 metre wall. This time, the eye level of the Line of Sight tool has been set to that of a cavalry unit. In this case it can see right over the wall.

Bingo! In this case our simulated viewpoint can see right over the wall! Cool eh? 😎

Unit Line of Sight phase 1 - Here the Blue Infantry unit to the South on the hill can see all three Infantry units (1 Blue and 2 Red), plus the Red Cavalry unit, thanks to its vantage point on the hill. What would happen if it decided to climb down to the bottom of the hill?

Over the next three pictures I’ll show the practical effects of simulating eye level. Here the Blue Infantry unit to the South on the hill can see all three Infantry units (1 Blue and 2 Red), plus the Red Cavalry unit at the back. This is thanks to its vantage point on the hill. But what would happen if the Infantry unit decided to climb down to the bottom of the hill?

Unit Line of Sight phase 2 - The Blue unit to the south has now moved off the hill onto ground level. From here it cannot see either Red Infantry unit because its own Blue Infantry unit to the North is blocking its view. Note that the Red Cavalry unit is taller than the intervening infantry units, so it can still be seen.

The Blue Infantry unit to the South has now moved Northwards off the hill and onto ground level. From here it cannot see either of the Red Infantry units because its own Blue Infantry unit to the North is blocking the view. Note that the Red Cavalry unit is taller than the intervening infantry units, so it can still be seen.

Unit Line of Sight phase 3 - The blue unit in the middle has rotated enough that the blue unit to the South of it can once again view the Red Infantry unit to the North. Note, one cannot see the 2nd Red Infantry unit because it is blocked by the first Red unit. However, the Red Cavalry unit is taller than the intervening infantry units, hence why it is still visible.

However, the Blue unit in the middle has been rotated enough so that the Blue unit to the South of it can once again view the Red Infantry unit to the North. Note, that it cannot see the 2nd Red Infantry unit because it is blocked by the first Red unit. However, the Red Cavalry unit is taller than the intervening infantry units, hence why it is still visible. Had our Blue Infantry unit been a Cavalry unit it would have been able to view all the units shown above due to its height advantage.

Here is where the clutter visibility for a map is set from within the map editor. In this case, this map has a clutter distance of 1000 metres and a max visibility of 8000 metres when on a hill.

Now for a discussion about another unique Ancient Armies feature – Terrain Clutter. Terrain Clutter can be set on a per map basis within the map editor as shown above. In this example, the map has a clutter distance of 1000 metres and a max visibility of 8000 metres when on a hill. This means that a unit at ground level can only see up to 1000 metres away unless the target unit is on a hill. Terrain Clutter represents micro ground undulations and foliage that are too small to show on a map, yet large enough to affect Line of Sight.

Ground clutter in action! Here we have set the ground clutter for this map to 1000 metres and set the viewer down at ground level. We can see for a 1000 metres along the ground, then our Line of Sight is blocked by the ground clutter. Only the front of the hill is high enough to rise above the clutter and allow things to be seen again.

Ground clutter in action! Here we have set the ground clutter for this map to 1000 metres and set the viewer down at the bottom left corner of the map at ground level. We can see for a 1000 metres along the ground (the green), then our Line of Sight is blocked by the ground clutter (in red). Only the front of the hill to the North is high enough to rise above the clutter and to allow observation to carry on again.

In this follow up screen shot, out observer has moved further back onto the hill (the observer is bottom left). From the vantage point of the hill, the observer can see right through all the ground level clutter. As a result, the observer's view is now only blocked when it reaches the crest of the hill.

In this follow up screen shot, our observer has moved further back onto the hill to the South (the observer is bottom left). From the new vantage point, the observer can see right through all of the intervening ground clutter. As a result, the observer’s view is now unimpeded at ground level and only becomes blocked when it reaches the crest of the hill.

These screenshots only show a small percentage of the Ancient Armies Line of Sight system’s features. If you want a full in-depth overview, take a look at the new video below (best viewed in HD):

That’s it for this week. Next, I will take a look at a few minor Line of Sight issues and after that I will take a closer look at irregular units – as I’m sure that something isn’t quite right with those 🙂

Laters

RobP

 

Advertisements

2 thoughts on “Adventures in Hi-Fi Line of Sight!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s