D9790: Fix slowdown issue

Frederik Schwarzer noreply at phabricator.kde.org
Wed Jan 10 21:40:00 UTC 2018


schwarzer added a comment.


  In https://phabricator.kde.org/D9790#189002, @helfferich wrote:
  
  > Do you mean switching the interval/substeps/speed? Or switching from a change in timer interval to the substeps?
  >
  > I'll try to explain:
  >
  > 1. Why change the interval? The basic loop is: Move ball -> Check for collisions -> Change direction, perform actions, according to collisions, etc. -> Move ball -> ... The speed determines how far the ball is moved during the "Move ball". If the ball is moved too far, the collision detection might be inaccurate (E.g. the extreme case is the ball moving through a brick with no detected collision). To avoid such bugs, we move the ball only half the distance, but twice as often.
  > 2. Why use substeps now? In the original code, this was done by cutting the gameTimer interval in half. However, this broke during the port to QML, because QML timer have a minimum interval of 16ms. Cutting it in half to 8ms does not have any effect. The alternative approach is to keep the gameTimer interval, but perform the basic loop twice.
  
  
  Thanks for the explanation. That made it more clear. :)
  
  > I hope this made it a little bit more clear. I am still wondering if the new approach has performance issues (moving the balls sequentially, instead of in parallel), but I don't think it matters as the collision detection, which is much more costly, is done sequentially as well.
  
  I played on a five years old laptop and when the "cut" came, the ball felt more smooth. In general it is better than before the change here.

REPOSITORY
  R393 KBreakout

REVISION DETAIL
  https://phabricator.kde.org/D9790

To: helfferich, #kde_games
Cc: schwarzer, #kde_games
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-games-devel/attachments/20180110/43caa0b6/attachment.html>


More information about the kde-games-devel mailing list