Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Sometimes when the mouse polling rate and the screen refresh rate are not of a good ratio, updating the display based on the mouse position can result in a jerky effect.</p> <p>You have vertical sync on, correct? And if you turn it of the mouse movement is smoother at the expense of tearing?</p> <p>One option is to use a smoothing function, that "lags" the values you use for the mouse position just a tiny bit behind the real mouse position</p> <p>The gist of it goes like this:</p> <pre><code>float use_x,use_y; // position to use for displaying float springiness = 50; // tweak to taste. void smooth_mouse(float time_d,float realx,float realy) { double d = 1-exp(log(0.5)*springiness*time_d); use_x += (realx-use_x)*d; use_y += (realy-use_y)*d; } </code></pre> <p>This is an <a href="http://en.wikipedia.org/wiki/Exponential_decay" rel="nofollow">exponential decay</a> function. You call it every frame to establish what to use for a mouse position. The trick is getting the right value for <code>springiness</code>. To be pedantic, <code>springiness</code> is the number of times the distance between the real mouse position and the used position will halve. For smoothing mouse movement, a good value for <code>springiness</code> is probably 50-100.</p> <p><code>time_d</code> is the interval since the last mouse poll. Pass it the real time delta (in fractional seconds) if you can, but you can get away with just passing it <code>1.0/fps</code>.</p> <p>If you have a WebGL-capable browser you can see a live version <a href="http://knobbits.org/webgl/widgets.html" rel="nofollow">here</a> - look for a class called <code>GLDraggable</code> in <code>viewer.js</code>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload