yoshinoToylogic / bulletsharp

Automatically exported from code.google.com/p/bulletsharp
MIT License
0 stars 0 forks source link

Determinism #36

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Hi!
I have a problem with determinism. When I try to run a simulation a couple of 
times(stopping and starting the .exe) I dont get the same results. I read that 
the native Bullet library supports determinism, but does BulletSharp support it 
too? If so are there something related to that in the demos?

Thanks for your time!

Original issue reported on code.google.com by kilki...@gmail.com on 23 Dec 2011 at 6:15

GoogleCodeExporter commented 8 years ago
From what i've gathered from the Bullet forums, determinism is not supported, 
because Bullet uses floating point numbers for which there is always some 
variance and the only way to have determinism is to use fixed-point math, which 
Bullet doesn't do. It would be a nice thing to have though.

As far as BulletSharp is concerned, there shouldn't be any difference since 
there is a 1:1 mapping of the classes.

You can try to find more info on the forums, but this is all I know. 
http://bulletphysics.org/Bullet/phpBB3/search.php?keywords=determinism&submit=Se
arch

Original comment by andres.traks on 23 Dec 2011 at 8:56

GoogleCodeExporter commented 8 years ago
Well I have searched through the forums and found that some people were able to 
achieve it but it isn't working for me. I guess there is something wrong with 
my code. Thanks for the help!

Original comment by kilki...@gmail.com on 23 Dec 2011 at 9:16

GoogleCodeExporter commented 8 years ago
Did you try the SortedOverlappingBroadphase as suggested here 
http://code.google.com/p/bullet/issues/detail?id=188&can=1&start=100 ?

OverlappingPairCache cache = new SortedOverlappingPairCache();
Broadphase = new DbvtBroadphase(cache);

Original comment by andres.traks on 25 Dec 2011 at 7:03

GoogleCodeExporter commented 8 years ago
Yes I did but unfortunately it didn't do the job. Here is my collision world 
setup:

            collisionConf = new DefaultCollisionConfiguration();
            dispatcher = new CollisionDispatcher(collisionConf);

            OverlappingPairCache cache = new SortedOverlappingPairCache();
            var broadphase = new DbvtBroadphase(cache);
            World = new DiscreteDynamicsWorld(dispatcher, broadphase, new SequentialImpulseConstraintSolver(), collisionConf);
            World.Gravity = gravity;

            World.Broadphase.OverlappingPairCache.SetInternalGhostPairCallback(new GhostPairCallback());

And my test of determinism involves:
1)starting the .exe
2)measuring the state in given time.
3)restarting the .exe and measure the state in the same time

I understand that when I measure the states by the time they took place they 
can be slightly off - but this is not the case - after only 5 seconds in the 
simulation I have results differring by alot (a ball with r=15x is about 10~15x 
off its position from the last simulation). Is it posible that because I am 
using this structure for the shapes of the static objects(mass = 0) that the 
simulation is non-deterministic:

private static BvhTriangleMeshShape GetTriangleMesh(int[] indices, Vector3[] 
vertecies)
        {
            StridingMeshInterface meshInterface = new TriangleIndexVertexArray(indices, vertecies);
            return new BvhTriangleMeshShape(meshInterface, false);
        }

Also: every frame i use ApplyCentralImpulse() for the ball to move. Can this be 
the problem. Thanks!

Original comment by kilki...@gmail.com on 25 Dec 2011 at 10:37