Fixed bug related with Pygame surface too large (#1657)

This commit is contained in:
manishthani 2019-05-22 17:31:44 +02:00 committed by Néstor Subirón
parent faa164557f
commit 85b96ce12a
2 changed files with 10 additions and 1 deletions

View File

@ -23,7 +23,7 @@
* Fixed wrong units in VehiclePhysicsControl's center of mass
* Several optimizations to the RPC server, now supports a bigger load of async messages
* Exposed 'is_invincible' for pedestrians
* Added sidewalks and improved lane markings in `no_rendering_mode.py`
* Fixed bug related with Pygame error of surface too large, added sidewalks and improved lane markings in `no_rendering_mode.py`
## CARLA 0.9.5

View File

@ -449,6 +449,15 @@ class MapImage(object):
self.width = max(max_x - min_x, max_y - min_y)
self._world_offset = (min_x, min_y)
# Maximum size of a Pygame surface
width_in_pixels = (1 << 14) - 1
# Adapt Pixels per meter to make world fit in surface
surface_pixel_per_meter = int(width_in_pixels / self.width)
if surface_pixel_per_meter > PIXELS_PER_METER:
surface_pixel_per_meter = PIXELS_PER_METER
self._pixels_per_meter = surface_pixel_per_meter
width_in_pixels = int(self._pixels_per_meter * self.width)
self.big_map_surface = pygame.Surface((width_in_pixels, width_in_pixels)).convert()