PhysicsSimulator.Update Overloaded Method

Apr 9, 2010 at 2:38 AM

I'm confused on what I need to do.  I want to let the PhysicsSimulator update as often as possible.  So I was thinking that the overloaded PhysicsSimulator.Update with two floats would do what I need to do.  But I can't figure it out.  One's labeled as "The delta time" and the other as "The real delta time", which is confusing.

I tried a few things on my own like:

 

physicsSimulator.Update(TimeManager.SecondDifference, TimeManager.SecondDifference);
physicsSimulator.Update(10f, TimeManager.SecondDifference);

The first one gave unstable results, the second one gives me NullReferenceExceptions. 

 

Can someone explain the meaning of the two variables and what I need to do to allow the physics simulator to operate at non-uniform intervals?

Apr 9, 2010 at 10:58 PM

Has anyone ever used the physics simulator in another thread?  Is information about the physics simulator documented somewhere? Because the manual basically only covers the things you can make.

Developer
Apr 10, 2010 at 3:01 PM

To answer your first question:

        /// <summary>
        /// Updates the physics simulator with the specified time change.
        /// </summary>
        /// <param name="dt">The delta time.</param>
        /// <param name="dtReal">The real delta time.</param>
        public void Update(float dt, float dtReal)

The "dt" is the physics time step. Normally this should be fixed at say 1 / 60 (60 fps) or 1 / 100 (100 fps).
The "dtReal" is used for the controllers, if any,that are a part of the simulation. normally you should pass-
(float)gameTime.ElapsedTime.TotalSeconds;

Now for the second question:

There was an example of how to use this engine in a separate thread - AdvancedSamplesXNA - but somehow it got removed.This is a very delicate topic as multithreading really needs to be built into an engine from the ground up.
I will say that it is possible, but the added complexity rarely makes up for the 10 -15% performance improvement.

Apr 10, 2010 at 6:52 PM

So the engine pretty much has to run at uniform intervals.

Alright, thanks!  I guess I'll just move as much of my own code (AI and stuff) onto another thread and leave farseer on the main thread, that should be fine.