Phong13 / BulletSharpUnity3d

A fork of the BulletSharp project to make the Bullet Physics Engine usable from C# code in Unity3d

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is this a deterministic physical engine?

hejiang123 opened this issue · comments

Hello, I'm trying to develop a frame synchronization game. So the physical system must be deterministic. Is bullet sharpunity3d deterministic?

It is deterministic on the same hardware using the same version of BulletSharpUnity3D. I think this is about the same as recent versions of PhysX.

Have you looked at the new UnityPhysics?

https://docs.unity3d.com/Packages/com.unity.physics@0.6/manual/index.html

It strives to be fully deterministic, even across different hardware.

In order to ensure the consistency of different platforms. I still plan to replace the floating-point numbers in the source code with fixed-point numbers. Do you have any suggestions? I don’t know how to replace the C language library

The C language lib is this github project.

https://github.com/Phong13/BulletSharpPInvoke

You would need to modify it, re-build it and then add it your fork of the BulletSharpUnity3d project.

I took a look at the C source code. It seems that modification is not an easy task. But I really want to use the physics engine BulletSharpUnity3d in the project. What do I need to do to achieve computing consistency on all platforms? Can you give me some suggestions? Thank you very much

Achieving consistency across all platforms is a technical challenge. These are the things you need to watch out for:

  • You need to compile for all platforms with 'ansi' compiler flag. This "should" fix any differences caused by hardware.
  • You need to be careful everywhere there is multithreading or GPU calculations. Calcs can happen in a different order on different hardware. You may need to sort results after an operation like this.
  • Look at collections in the code. If there is any chance that objects can get added in a different order you need to sort the collection before it gets used. Take a carful look at how the 'contact manifolds' are collected. I think you may need to do this here.

If it were me, I would take a look at the Unity Physics package. It is fully open source and is designed to be fully interoperable across many platforms.