Giter Site home page Giter Site logo

Comments (2)

jrouwe avatar jrouwe commented on June 2, 2024 2

Hello,

This is a known issue. Currently the sample app uses the VSYNC to display frames but it uses a fixed time step of 60 Hz to simulate physics. I didn't want to implement any interpolation to go to a higher frequency as then you wouldn't see the exact output of the physics engine anymore and I also didn't want to support a variable delta time since that messes with the determinism of the simulation.

In the menu "Physics Settings" / "Update Frequency" you can set the fixed tick rate and if you match it to your monitors refresh rate you should get a simulation that runs normal.

I think I will implement a change that just delays the rendering of the next frame until 1/60th of a second has passed since the last frame to fix things for high frequency monitors.

from joltphysics.

cuppajoeman avatar cuppajoeman commented on June 2, 2024

I have a limited understanding about how the samples work, keep this in mind.

From what I can tell the driver to all the samples is the class SamplesApp located in Samples/SamplesApp.cpp, in this file we have the following method:

void SamplesApp::StepPhysics(JobSystem *inJobSystem)

Open this up, and go down a few lines, you'll see that they define delta_time as 1/mUpdateFrequency and use that to update the physics system.

which uses mUpdateFrequency which is defined in the header file:

float mUpdateFrequency = 60.0f; // Physics update frequency

Thus from what I've seen you're correct about these samples being frame rate dependent. In order to fix this we would need to a method to come up with a dynamic delta_time based on how much time has passed since the last physics update.

When scrolling through SamplesApp.cpp I thought I might have seen code which can control the update frequency with a slider. If this is true, then perhaps you can use a slider to choose an update frequency which will make the samples not "fast" on your computer. Otherwise you can always hardcode a value for your update frequency and recompile.

If you actually wanted frame independent simulation Glen has a good article on this: https://gafferongames.com/post/fix_your_timestep/ and I have an implementation of this on my site here: https://cuppajoeman.com/toolbox/game_dev/game_loop/.

Not sure what your experience is with contributing and c++, but I think the best case could be to have an option which can enable frame independent simulation in the samples app, which could be contributed via a pull request.

from joltphysics.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.