#1679: Bug causing jerky arc rotation -------------------------------------+-------------------------------------- Reporter: bornemix | Type: bug Status: new | Priority: major Milestone: unspecified | Component: Engine: GUI Version: svn/trunk | Keywords: Operating_system: All/Non-Specific | Blockedby: Blocking: | -------------------------------------+-------------------------------------- This patch covers three issues, all of whom are concerned with arc rotation (drag mouse on screen with right mouse button held down ingame).
CHANGE NUMBER ONE A bug which causes jerky rotation. The order of the divider "/" in the following code, in a total of 6 places, makes the camera rotate only every 2 steps: (display.c:1309) {{{ player.r.y = rotInitial + (rotX - mouseX())/2 * DEG(1); }}} Please note that (rotX - mouseX()) equals deltaX, that is, the horizontal distance which the mouse has travelled so far while holding down RMB. Although: Making the camera rotate 1 degree every pixel makes the camera movement jerky. So the developers decided to add "/2" which you see after deltaX. (that's the error) As such, (rotX - mouseX())/2 becomes half of deltaX, that is, 1 pixel becomes 0.5 degrees and such - YEAH RIGHT!!! :) Because deltaX is an integer (that is, an integer minus another integer), the result of its division ("/2") is also an integer: {{{ 1 / 2 = 0; 2 / 2 = 1; 3 / 2 = 1; 4 / 2 = 2; 4 / 2 = 2; }}} See now why the camera moves so jerky? Instead, we should let the division be last, so that we let a bigger number be divided lest it's integer result loose unnecessary precision: {{{ (rotX - mouseX()) * DEG(1) / 2 }}} This, and on 5 places more after line 1309. CHANGE NUMBER TWO This involves the dragging distance treshold which a user must surpass in order to initiate his dragging. As it is now, 8px on either direction, is a bit high. I changed it to 2px, which may be a bit low. ISSUE NUMBER THREE The surpass of the draggin treshold is also initiated independently of each axis, which is bad. To begin making your rotation on both axises, that is, to beign an arc rotate, you must surpass the treshold on BOTH axises. Surpassing only one axis will activate one axis and one axis only. That is, just rotating vertically (with the mouse moving a little in horizantal, naturally) will yield a strict movement vertically. The effect becomes very unnatural and feels very unintuitive. To surpass this, I took both conditions and made them into one variable: mouseHasSurpassedDraggingTreshold. --- I hope this is something you want to implement, and it would encourage me as a developer to send more patches if you accepted at least some of it :-) -- Ticket URL: <http://developer.wz2100.net/ticket/1679> Warzone 2100 Trac <http://developer.wz2100.net/> The Warzone 2100 Project _______________________________________________ Warzone-dev mailing list Warzone-dev@gna.org https://mail.gna.org/listinfo/warzone-dev