Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Stuttering with Interpolation (Sprites + Views)  (Read 1275 times)

0 Members and 1 Guest are viewing this topic.

Rutin

  • Newbie
  • *
  • Posts: 5
    • View Profile
Stuttering with Interpolation (Sprites + Views)
« on: July 05, 2018, 11:18:52 pm »
I'm having a problem with stutters during interpolation. Depending on what I'm doing it can happen every 10+ seconds, other times it will happen every few seconds, or more frequent.

I noticed when I use a view and move it the same thing will happen but more often.

In my sample code I have one sprite and background with interpolation, but the stutter will happen.

Now I'm wondering if this is an error in my code which I don't see, or is SFML clock causing an issue between frames which is causing a hiccup? It's not as noticeable with just a tiny sprite, but when you're drawing tiles and using a view for a camera the hiccup is every few seconds.

At the start of my Logic for Input I set the Prev Pos to the Current, then once in the Draw part I interpolate like so:

interpolation = float(mainClock.getElapsedTime().asMilliseconds() + skipTicks - nextTick) / float(skipTicks);

                        mySpritePositionDraw = mySpritePositionPrior + (interpolation * (mySpritePosition - mySpritePositionPrior));
                        mySprite.setPosition(sf::Vector2f(mySpritePositionDraw));
                        mainWindow.draw(mySprite);
 

Problem Fixed - was Joystick polling from SFML 2.4.2
« Last Edit: July 06, 2018, 12:39:23 am by Rutin »

Rutin

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Stuttering with Interpolation (Sprites + Views)
« Reply #1 on: July 06, 2018, 12:37:08 am »
I just did an update from SFML 2.4.2 to SFML 2.5.0 and the problem appears to be gone.... I looked more into this and I found that other people had this same issue due to joystick polling.

I noticed on the 2.5.0 change log:

[Windows] Replaced time-based joystick poll with a hardware event handler

This must've been my issue.