Xiotex - Coder art, reticule and floating point errors

The only place you'll ever hear the truth
User avatar
Byron
level2
level2
Posts: 147
Joined: Tue May 13, 2008 3:48 pm

Xiotex - Coder art, reticule and floating point errors

Postby Byron » Thu Jan 08, 2009 2:06 am

Back in 2001 I was working on a PS2 game which was a combat flight simulator. I was responsible for the flight physics and player controls. One day I left the game playing and the PS2 controller on the desk while I got on with some coding. After a while I looked up to see the on screen representation of the aircraft shaking itself to pieces. It was a puzzle, nobody could figure out why it was doing this. So we repeated the test over and over again with the same results. We eventually discovered what it was. The aircraft had been flying through the virtual world and its position was now at the extreme edges that could be represented by a floating point number so what we were seeing was an error in precision of floating point numbers. For that particular game this was not an issue because once all of the elements of the game were in place the player could never reach those edges. This does however present a problem with Xiotex. When flying through the world after a while rotation starts to get a bit 'jerky' and the reason for this is the same as the PS2 game. The solution is easy though and it involves translating from one coordinate space into another which is local around 0,0,0.

The only visual thing added to the game recently is the draft 'targeting reticule' which is represented by another piece of amazing coder art. The player uses this to target items and AI in the world to get more information or to attack them. I had originally played with a roaming reticule that matched the location of an AI object but it didn't really work that well so I am sticking with a centrally placed system until something better comes to mind. Having the reticule in a consistent central position does present an interesting design challenge though. I want the player to be able to use it to discover what type of AI they are pointing at, it's level, its shield charge and what kind of cargo it is carrying. With the roaming reticule this was easy because the player could use the mouse pointer to click on the object they want to find out about and the reticule would follow that object but now it is central the mouse pointer clicking does not feel the same so I have to come up with another method such as always ray-casting down the centre point of the screen to match with whatever is in the central line or do a sort of auto lock on to the closest object. The ray-cast idea can cause problems with smaller object that might move in and out of the ray-cast at frequent intervals but that can be solved by keeping an object's information in place for a minimum amount of time.

Image
User avatar
Pox
level5
level5
Posts: 1786
Joined: Sat Mar 03, 2007 11:23 am
Location: Melbourne

Postby Pox » Thu Jan 08, 2009 2:27 am

The joys of floating-point... a friend of mine was working on a space sim at one point (not sure whether it's properly abandoned yet :P) and had to do some quite extensive hackery to get smooth movement of small craft yet still maintain massive render distance for distant planetary bodies.

Also, mmmmmm, programmer art.
andrewf
level0
Posts: 8
Joined: Thu Jun 14, 2007 9:55 pm

Postby andrewf » Thu Jan 08, 2009 6:32 am

Have you considered developing it for the iphone?
From what I can tell from this post and your previous one, the iphone could be a great platform for Xiotex..

That would really kick-ass :D
TomF
level0
Posts: 1
Joined: Thu Jan 08, 2009 7:09 am
Contact:

Postby TomF » Thu Jan 08, 2009 8:17 am

If "the origin" doesn't have any particularly awesome meaning for a set of numbers you're storing, you should be using fixed-point instead of floats. Examples include world coordinates and game time. 64-bit fixed-point support is very fast, ubiquitous, and has totally reliable precision - there's no "magic spot" where stuff works differently, and it's got massive range and precision. Whereas float64 support is crap and slow, and float32 has precision with a mind of its own.

I seem to recall a rant about this topic :-) [url]http://www.eelpi.gotdns.org/blog.wiki.html#[[A%20matter%20of%20precision]][/url]
User avatar
Byron
level2
level2
Posts: 147
Joined: Tue May 13, 2008 3:48 pm

Postby Byron » Thu Jan 08, 2009 2:00 pm

TomF wrote:If "the origin" doesn't have any particularly awesome meaning for a set of numbers you're storing, you should be using fixed-point instead of floats. Examples include world coordinates and game time. 64-bit fixed-point support is very fast, ubiquitous, and has totally reliable precision - there's no "magic spot" where stuff works differently, and it's got massive range and precision. Whereas float64 support is crap and slow, and float32 has precision with a mind of its own.

I seem to recall a rant about this topic :-) [url]http://www.eelpi.gotdns.org/blog.wiki.html#[[A%20matter%20of%20precision]][/url]


Tom! Long time since we last talked (2005 I think). As usual, excellent article and it has certainly given me cause to re-think what I am doing. Now I am going to have to go and write a whole heap of fixed point classes.
User avatar
darthkiwi
level1
level1
Posts: 16
Joined: Sat Jan 05, 2008 12:51 pm
Location: On the brink of insanity.

Postby darthkiwi » Thu Jan 08, 2009 3:04 pm

See, this is what I like about Introversion. It sounds like you got the go-ahead to make Xiotex because you thought it was cool, and you're more than willing to take criticism in the name of improving the game.
Cthulhu fhtagn.
OrR
level1
level1
Posts: 74
Joined: Wed Mar 23, 2005 12:06 am

Postby OrR » Thu Jan 08, 2009 3:26 pm

If you use fixed point stuff and Open GL, it might not be too difficult to get this game to run on the Pandora... Please make it cross platform! :)
skull13
level3
level3
Posts: 340
Joined: Sun Apr 16, 2006 10:51 pm

Postby skull13 » Thu Jan 08, 2009 3:38 pm

Vendetta Online has this issue, but its so subtle that it takes a week of flying straight at top speed for it to appear. Also, the more I look at this, the more it reminds me of a LAN demo of a game in progress called Parsec. It was meant to be a multiplayer space fight game, but the production was stopped. If you want the source code, its right here. Its C++ from 2003, so its changed a lot, but it may give you ideas!

Return to “Introversion Blog”

Who is online

Users browsing this forum: No registered users and 3 guests