Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust the scaling automatically in TopDownRenderer #776

Merged
merged 1 commit into from
Nov 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading