Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is this a deterministic physical engine? #77

Open
hejiang123 opened this issue Apr 27, 2021 · 5 comments
Open

Is this a deterministic physical engine? #77

hejiang123 opened this issue Apr 27, 2021 · 5 comments

Comments

@hejiang123
Copy link

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

@Phong13
Copy link
Owner

Phong13 commented Apr 27, 2021

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.

@hejiang123
Copy link
Author

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

@Phong13
Copy link
Owner

Phong13 commented Apr 27, 2021

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.

@hejiang123
Copy link
Author

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

@Phong13
Copy link
Owner

Phong13 commented Apr 29, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants