Floating point precision problems

SamJ

17-02-2011 07:28:15

Hi. I'm currently testing several physic libraries and I have a question about nxogre/physx.

My world is a large world, which means the coordinates of the objects are sometimes very far from the origin. Since physx uses floating point precision (afaik) this introduces problems in the simulation with coordinates far from the origin.

Newton, bullet and ode are open source and you can rebuild them with double precision, so that is not a problem.

Havok is closed source and uses floating precision, but they provide an example of how to shift the coordinates of the world periodically to keep coords close to the origin and avoid this problem.

I haven't found any information about either double precision physx libs or coordinate system re-centering/shifting. Is it possible at all? Has anyone tried?

Thanks in advance.

betajaen

17-02-2011 13:38:42

I haven't seen any, no.

Although; Is recentering/shifting a floating point operation, or just dividing the world in to quads/cells, and moving one to the cell to another is just simply teleporting across the opposite side of a fixed bounds world?

SamJ

17-02-2011 14:23:02

I'm not sure if I understand you. In the havok demo for world recentering they iterate all the objects at the low level (havok exposes everything) translating all the elements. You can do this every time your character gets too far from the origin. Then you sum the offset when you apply the positions given by havok to your scenenodes.

betajaen

17-02-2011 14:48:16

Sounds a bit like I was thinking.

Your world is divided into cells say (1000,1000,1000) each. The physics simulation also has bounds (1000,1000,1000), so the physics simulation only exists in one cell, the centre one. Outsides of the bounds are visible but not simulated by the physics simulation; cells very far away are rendering in low detail. When you cross a boundary (say -500,0,0), the cell is moved to the center, the physics objects of the old cell are deleted, and the new ones are created. Your teleported to the otherside at (500,0,0). To make it more realistic, you'd have a 2nd/3rd scene on the non-active cells, which are offset from the center (but internally at 0,0,0). Both simulations are running, but when the boundary is changed the primary scene is deleted, and the 2nd scene is copied into the primary one then deleted.

SamJ

18-02-2011 06:01:07

No. There are no cells in the Havok example. It's only one world. You shift the coordinate origin every once in a while, remove the objects that are now "outside" and add the objects that are now inside. Only one scene, all the time.

I suppose they don't partition the space because that would inevitably cause bugs in the borders of the worlds.

Also what you tell me doesn't help me. You are describing the concept of partitioning with no relation to physx. I get partitioning/paging, I already implemented paging for my terrain and for my water planes for example. The point is, is it possible to make that in physx without simulation problems in objects changing from one cell to other? I'm suspecting not. Then, is it possible to shift the coordinate system like havok?

Or do these cells you talk about translate to an actual physx feature that I missed? Otherwise I don't see how you are telling me anything practical, sorry if I misunderstood you. Thanks anyway.

betajaen

18-02-2011 07:52:42

No, PhysX doesn't support coordinate shifting like Havok does, nor the paging cell idea I have.