gravField = new GravitationalField(new InfiniteForceFieldShape(), position, 1000 * 0.5f, 10000, game.Space.BroadPhase.QueryAccelerator);
// Force entities in range to wake up
gravField.ForceWakeUp = true;
I've also enclosed the field in a spherical shape to create a planet with gravity type of effect:
It looks like there are pretty intense forces being applied. Turning up normal gravity to 50x or 100x without decreasing the time step exhibits similar behavior. The problem is that there's such great acceleration involved that any tiny motion or usually-smooth oscillation is amplified into violent jitter.
A lower cap on the force/acceleration applied should help avoid this problem.
The "MaxForce" property is equivalent to capping the acceleration, assuming the objects involved have equal mass. I went ahead and changed it to MaxAcceleration in the development version (http://bepuphysics.codeplex.com/SourceC ... evelopment) for ease of tuning, though the change was very tiny.
You could also change the field to use a linear falloff instead of a inverse square falloff. That would pull further objects with more force while not requiring immense forces once the objects get close. In the GravitationalField class, there's a commented implementation of this.
I still have the same problems with the build of the latest development fork, but with new errors.
If I use the linear or quadratic falloff then bad things happen when moving the field. NaN errors and all my entities disappear. This didn't happen before.
I'm surprised it didn't happen before; if the 'singularity' was unprotected, it produces a NaN. You can wrap the impulse calculation in a protective if to stop that. The development version has it now too.
Picking a good/reasonable value for the MaxAcceleration should avoid the jittering. What values and configuration are failing?
That would be expected behavior. A max acceleration of 100 is very high (10x normal gravity for the usual scale of objects). With the lower multiplier, the gravity is lower (quite a bit below 100, most likely). With the higher multiplier, the gravity is higher (closer to or hitting the MaxAcceleration).
The trick would be to pick a multiplier which has the desired medium/long range pull, possibly using linear instead of quadratic falloff, and then capping acceleration so near objects don't jitter or approach infinite acceleration as they approach the singularity.