Skip to content

Commit

Permalink
Adjust the scaling automatically in TopDownRenderer (#776)
Browse files Browse the repository at this point in the history
To avoid a special case where the map is too large, adjust the scaling automatically in TopDownRenderer
  • Loading branch information
pengzhenghao authored Nov 19, 2024
1 parent ee5e1f8 commit 0624f72
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion metadrive/engine/top_down_renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ def draw_top_down_map_native(
y_len = b_box[3] - b_box[2]
max_len = max(x_len, y_len)
# scaling and center can be easily found by bounding box
scaling = scaling if scaling is not None else (film_size[1] / max_len - 0.1)
if scaling is None:
scaling = (film_size[1] / max_len - 0.1)
else:
scaling = min(scaling, (film_size[1] / max_len - 0.1))
surface.scaling = scaling
centering_pos = ((b_box[0] + b_box[1]) / 2, (b_box[2] + b_box[3]) / 2)
surface.move_display_window_to(centering_pos)
Expand Down Expand Up @@ -280,6 +283,7 @@ def __init__(
film_size=self.film_size,
semantic_broken_line=self.semantic_broken_line
)
self.scaling = self._background_canvas.scaling

# (2) frame is a copy of the background so you can draw movable things on it.
# It is super large as the background.
Expand Down

0 comments on commit 0624f72

Please sign in to comment.