diff --git a/changelog b/changelog index b2063464da4..89b2865b7dc 100644 --- a/changelog +++ b/changelog @@ -40,6 +40,8 @@ Version 1.13.0-dev: * Fix bug #21761: wesnoth.synchronize_choice will now give a warning when the table returned by the user-specified function is not completely valid, when wesnoth is running in debug mode (--debug command line flag). + * Graphics: + * Smooth unit movement over terrain with elevation (e.g. keeps/bridges) * Units: * Increased the experience requirement for the Rami from 32 to 39 * Increased the experience requirement for the Saree from 56 to 64 diff --git a/src/unit.cpp b/src/unit.cpp index 50b63b7be54..a3559016767 100644 --- a/src/unit.cpp +++ b/src/unit.cpp @@ -1917,6 +1917,13 @@ void unit::redraw_unit() display &disp = *display::get_singleton(); const gamemap &map = disp.get_map(); + const map_location dst = loc_.get_direction(facing_); + const int xsrc = disp.get_location_x(loc_); + const int ysrc = disp.get_location_y(loc_); + const int xdst = disp.get_location_x(dst); + const int ydst = disp.get_location_y(dst); + int d2 = disp.hex_size() / 2; + if ( hidden_ || disp.is_blindfolded() || !is_visible_to_team(disp.get_teams()[disp.viewing_team()],disp.show_everything(),map) ) { clear_haloes(); @@ -1933,11 +1940,14 @@ void unit::redraw_unit() if (refreshing_) return; refreshing_ = true; - + anim_->update_last_draw_time(); frame_parameters params; const t_translation::t_terrain terrain = map.get_terrain(loc_); const terrain_type& terrain_info = map.get_terrain_info(terrain); + const t_translation::t_terrain terrain_dst = map.get_terrain(dst); + const terrain_type& terrain_dst_info = map.get_terrain_info(terrain_dst); + // do not set to 0 so we can distinguish the flying from the "not on submerge terrain" // instead use -1.0 (as in "negative depth", it will be ignored by rendering) params.submerge= is_flying() ? -1.0 : terrain_info.unit_submerge(); @@ -1949,7 +1959,12 @@ void unit::redraw_unit() if (loc_ == disp.selected_hex() && params.highlight_ratio == 1.0) { params.highlight_ratio = 1.5; } - int height_adjust = static_cast(terrain_info.unit_height_adjust() * disp.get_zoom_factor()); + + // Todo: calculate unit offset without processing the whole get_current_params + double offset = anim_->get_current_params(params).offset; + int height_adjust = static_cast((terrain_info.unit_height_adjust() * (1.0 - offset) + + terrain_dst_info.unit_height_adjust() * offset) * + disp.get_zoom_factor()); if (is_flying() && height_adjust < 0) { height_adjust = 0; } @@ -1989,18 +2004,6 @@ void unit::redraw_unit() const frame_parameters adjusted_params = anim_->get_current_params(params); - - - const map_location dst = loc_.get_direction(facing_); - const int xsrc = disp.get_location_x(loc_); - const int ysrc = disp.get_location_y(loc_); - const int xdst = disp.get_location_x(dst); - const int ydst = disp.get_location_y(dst); - int d2 = disp.hex_size() / 2; - - - - const int x = static_cast(adjusted_params.offset * xdst + (1.0-adjusted_params.offset) * xsrc) + d2; const int y = static_cast(adjusted_params.offset * ydst + (1.0-adjusted_params.offset) * ysrc) + d2;