Simulation speed fluctuates between iterations
Posted: Wed Jan 01, 2014 4:07 pm
I have an 'Entity' that falls from one point to another in a simulation under the force of gravity (0, -10, 0).
If the window in which the simulation runs loses focus then the object will move much faster than if the window has focus.
If the object is reset to its original position and orientation once reaching its destination, and its linear velocity and angular velocity also are reset to (0, 0, 0), then the object will slow down once it has undergone a variable number of iterations.
Why is the speed of the physics simulation fluctuating in these scenarios and how can I prevent it from happening?
My current settings for the simulation are:
If the window in which the simulation runs loses focus then the object will move much faster than if the window has focus.
If the object is reset to its original position and orientation once reaching its destination, and its linear velocity and angular velocity also are reset to (0, 0, 0), then the object will slow down once it has undergone a variable number of iterations.
Why is the speed of the physics simulation fluctuating in these scenarios and how can I prevent it from happening?
My current settings for the simulation are:
Code: Select all
BEPUphysics.Settings.CollisionDetectionSettings.DefaultMargin = 0.04f;
BEPUphysics.Settings.CollisionResponseSettings.BouncinessVelocityThreshold = 1f;
BEPUphysics.Settings.CollisionResponseSettings.MaximumPenetrationRecoverySpeed = 10f;
BEPUphysics.Settings.CollisionResponseSettings.PenetrationRecoveryStiffness = 0.2f; //0.8f;
BEPUphysics.Settings.MotionSettings.CoreShapeScaling = 0.99f;
//BEPUphysics.Settings.MotionSettings.UseExtraExpansionForContinuousBoundingBoxes = false;
// Set gravity for physics space
space.ForceUpdater.Gravity = new BEPUutilities.Vector3(0f, -10f, 0f);
// To prevent tunnelling, allow the simulation to run at greater frame rates (Default: 1f / 60f : 60FPS)
space.TimeStepSettings.TimeStepDuration = 1f / 120f;
space.BufferedStates.Enabled = false;
// Increase collision response iterations to improve stability
space.Solver.IterationLimit = 20;