mail[Wesnoth-commits] r33742 - /trunk/src/unit_display.cpp


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by alinktomine on March 17, 2009 - 04:35:
Author: alink
Date: Tue Mar 17 04:35:11 2009
New Revision: 33742

URL: http://svn.gna.org/viewcvs/wesnoth?rev=33742&view=rev
Log:
Finally fully fix bug #13179 (Unit's move have sometimes a jumpy start)
Fully clear the black stripes before the move and revert r33610.
Also added comment with debug code for objectively evaluate smoothness.

Modified:
    trunk/src/unit_display.cpp

Modified: trunk/src/unit_display.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit_display.cpp?rev=33742&r1=33741&r2=33742&view=diff
==============================================================================
--- trunk/src/unit_display.cpp (original)
+++ trunk/src/unit_display.cpp Tue Mar 17 04:35:11 2009
@@ -72,12 +72,25 @@
         animator.pause_animation();
        disp->scroll_to_tiles(a,b,game_display::ONSCREEN,true,0.0,false);
         animator.restart_animation();
-       new_animation_frame(); //fix bug #13179: Unit's move have sometimes a 
jumpy start
+
+       // useless now, previous short draw() just did one
+       // new_animation_frame();
+
        int target_time = animator.get_animation_time_potential();
+
+               // target_time must be short to avoid jumpy move
+               // std::cout << "target time: " << target_time << "\n";
+       // we round it to the next multile of 150
        target_time += 150;
        target_time -= target_time%150;
-       if(  target_time - animator.get_animation_time_potential() < 100 ) 
target_time +=150;
+
+       // This code causes backwards teleport because the time > 150 causes 
offset > 1.0
+       // which will not match with the following -1.0
+       // if(  target_time - animator.get_animation_time_potential() < 100 ) 
target_time +=150;
+       
        animator.wait_until(target_time);
+               // debug code, see unit_frame::redraw()
+               // std::cout << "   end\n";
        map_location arr[6];
        get_adjacent_tiles(a, arr);
        unsigned int i;
@@ -135,7 +148,21 @@
                // If it does not fit we might be able to do a better scroll 
later.
                disp->scroll_to_tiles(path, game_display::ONSCREEN, true, 
true,0.0,false);
        }
-        disp->draw();
+       // We need to clear big invalidation before the move and have a 
smooth animation
+       // (mainly black stripes and invalidation after canceling atatck 
dialog)
+       // Two draw calls are needed to also redraw the previously 
invalidated hexes
+       // We use update=false because we don't need delay here (no time 
wasted)
+       // and no screen refresh (will be done by last 3rd draw() and it 
optimizes
+       // the double blitting done by these invalidations)
+    disp->draw(false);
+       disp->draw(false);
+
+       // The last draw() was still slow, and its inital 
new_animation_frame() call
+       // is now old, so we do another draw() to get a fresh one
+       // TODO: replace that by a new_animation_frame() before starting anims
+       //       don't forget to change the previous draw(false) to true
+       disp->draw(true);
+
        for(size_t i = 0; i+1 < path.size(); ++i) {
 
                invisible = 
teams[temp_unit.side()-1].is_enemy(int(disp->viewing_team()+1)) &&




Related Messages


Powered by MHonArc, Updated Tue Mar 17 05:00:19 2009