Using fixed point maths in a physics engine

Please don't post Bullet support questions here, use the above forums instead.
Post Reply
tonemcbride
Posts: 2
Joined: Mon Mar 19, 2007 4:35 pm

Using fixed point maths in a physics engine

Post by tonemcbride »

Hi,

I'm currently working on porting a physics project to a machine without any native floating point support. I'm using ODE (in single floating point mode) and find it works very well on a PC but is very slow when using an emulated floating point system.

I was going to reimplement ODE using a fixed point maths class but would like to know if anyone had any information on this before I go ahead. Ideally I would use a 16:16 system but I'm unsure whether this would be too limited for the scale of numbers being used.

If anyone could give their opinion on the following questions I would be really grateful:

1) Has anyone used fixed-point maths for physics before?

2) Do physics systems require support for NaN/Infinity etc...?

3) What would be a reasonable size to use for the fixed-point (e.g. 32:32, 16:16, 48:16)

Thanks!

Tone
dog
Posts: 44
Joined: Fri Jul 22, 2005 8:00 pm
Location: Santa Monica

Post by dog »

I found that 32:32 was adequate for my needs. My engine did not require NaN support, I have no idea about ODE.
raigan2
Posts: 212
Joined: Sat Aug 19, 2006 11:52 pm

Post by raigan2 »

This is something I'd be very interested to hear about. One tip you might find handy is given near the end of this presentation: http://jet.ro/files/The_neglected_art_o ... 060913.pdf

basically: use a number class which internally implements both floatingpoint and fixedpoint at the same time, so that you can easily detect when problems arise with your fixedpoint code.

dog: did you need 128bit values for intermediate calculations? or did you only really use 16:32?
dog
Posts: 44
Joined: Fri Jul 22, 2005 8:00 pm
Location: Santa Monica

Post by dog »

Yeah. Intermediate 128-bit calculations. The first game that used it had 16:32, but I changed it to 32:32 for a space-sim, which apparently needed it. My first physics sim used 8:8 (but that was on a C-64).

I'll have to be honest and say that when I did this stuff floating point units were not usually available.
tonemcbride
Posts: 2
Joined: Mon Mar 19, 2007 4:35 pm

Post by tonemcbride »

Thanks for all the info guys, its much appreciated!

I really like the idea of running a proper floating point system at the same time to check for errors - hadn't thought about that one :)

Tone
Post Reply