Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
QuanyiLi committed Nov 13, 2023
1 parent c715169 commit e73c73d
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 17 deletions.
14 changes: 7 additions & 7 deletions metadrive/component/block/base_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class BaseBlock(BaseObject, PGDrivableAreaProperty, ABC):
ID = "B"

def __init__(
self, block_index: int, global_network: NodeRoadNetwork, random_seed, ignore_intersection_checking=False
self, block_index: int, global_network: NodeRoadNetwork, random_seed, ignore_intersection_checking=False
):
super(BaseBlock, self).__init__(str(block_index) + self.ID, random_seed, escape_random_seed_assertion=True)
# block information
Expand Down Expand Up @@ -82,12 +82,12 @@ def _sample_topology(self) -> bool:
raise NotImplementedError

def construct_block(
self,
root_render_np: NodePath,
physics_world: PhysicsWorld,
extra_config: Dict = None,
no_same_node=True,
attach_to_world=True
self,
root_render_np: NodePath,
physics_world: PhysicsWorld,
extra_config: Dict = None,
no_same_node=True,
attach_to_world=True
) -> bool:
"""
Randomly Construct a block, if overlap return False
Expand Down
3 changes: 2 additions & 1 deletion metadrive/engine/base_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def has_task(self, object_id):
return True if object_id in self._object_tasks else False

def spawn_object(
self, object_class, pbr_model=True, force_spawn=False, auto_fill_random_seed=True, record=True, **kwargs
self, object_class, pbr_model=True, force_spawn=False, auto_fill_random_seed=True, record=True, **kwargs
):
"""
Call this func to spawn one object
Expand Down Expand Up @@ -264,6 +264,7 @@ def reset(self):
_debug_memory_usage = False

if _debug_memory_usage:

def process_memory():
import psutil
import os
Expand Down
15 changes: 8 additions & 7 deletions metadrive/engine/core/terrain.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def reset(self, center_position):
)
heightfield_to_modify = heightfield_base[start:end, start:end, ...]
heightfield_base[start:end, start:end,
...] = np.where(drivable_region, self._terrain_offset, heightfield_to_modify)
...] = np.where(drivable_region, self._terrain_offset, heightfield_to_modify)

# generate collision mesh
if self.use_mesh_terrain:
Expand Down Expand Up @@ -169,12 +169,12 @@ def generate_plane_collision_terrain(self):
self._node_path_list.append(np)

def _generate_mesh_vis_terrain(
self,
size,
heightfield: Texture,
attribute_tex: Texture,
target_triangle_width=10,
engine=None,
self,
size,
heightfield: Texture,
attribute_tex: Texture,
target_triangle_width=10,
engine=None,
):
"""
Given a height field map to generate terrain and an attribute_tex to texture terrain, so we can get road/grass
Expand Down Expand Up @@ -546,6 +546,7 @@ def mesh_terrain(self):
"""
return self._mesh_terrain


# Some useful threads
# GeoMipTerrain:
# https://discourse.panda3d.org/t/texture-mapping-according-with-vertex-position-terrain-generation/28929
Expand Down
2 changes: 1 addition & 1 deletion metadrive/manager/object_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def set_state(self, state: dict, old_name_to_current=None):
current_name = old_name_to_current[name]
name_obj = self.engine.get_objects([current_name])
assert current_name in name_obj and name_obj[current_name
].class_name == class_name, "Can not restore mappings!"
].class_name == class_name, "Can not restore mappings!"
# Restore some internal states
name_obj[current_name].lane = self.engine.current_map.road_network.get_lane(
name_obj[current_name].lane.index
Expand Down
2 changes: 1 addition & 1 deletion metadrive/tests/vis_env/vis_metadrive_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
# "controller": "joystick",
# "show_coordinates": True,
# "random_agent_model": False,
"debug_static_world":True,
"debug_static_world": True,
"manual_control": True,
"use_render": True,
"use_mesh_terrain": False,
Expand Down

0 comments on commit e73c73d

Please sign in to comment.