PathEdge cleanup

This commit is contained in:
firestarsdog
2026-09-27 23:13:35 -04:00
parent b1e7a5c46e
commit da7af42e49
3 changed files with 13 additions and 2 deletions
+3
View File
@@ -76,6 +76,7 @@ class ModelRenderer(Widget):
self._adjacent_path_vertices = [np.empty((0, 2), dtype=np.float32), np.empty((0, 2), dtype=np.float32)]
# Outer path polygon for edge rendering
self._track_edge_vertices = np.empty((0, 2), dtype=np.float32)
self._path_edge_width = 0.0
# Initialize ModelPoints objects
self._path = ModelPoints()
@@ -254,6 +255,8 @@ class ModelRenderer(Widget):
else:
path_width *= 0.50
self._path_edge_width = path_width * path_edge_width_pct
unclipped_max_distance = np.clip(path_x_array[-1], MIN_DRAW_DISTANCE, MAX_DRAW_DISTANCE)
unclipped_max_idx = self._get_path_length_idx(self._lane_lines[0].raw_points[:, 0], unclipped_max_distance)
@@ -207,8 +207,8 @@ class StarPilotOnroadView(AugmentedRoadView):
mr = self.model_renderer
if mr._path.projected_points.size:
# Path edges (always rendered if track_edge_vertices exist)
if mr._track_edge_vertices.size >= 4:
# The default path-edge width is zero, which produces no visible strip.
if mr._path_edge_width > 0.0 and mr._track_edge_vertices.size >= 4:
render_path_edges(mr)
# Render adjacent lanes (incorporates both adjacent path and blind spot warnings)
@@ -51,6 +51,7 @@ def _load_starpilot_onroad_view(monkeypatch):
dummy_widget = type("DummyWidget", (), {})
color = SimpleNamespace(r=0, g=0, b=0, a=255)
stub_module("openpilot.selfdrive.ui.onroad.starpilot.pip_sidecam", PipSideCamera=dummy_widget)
stub_module("openpilot.selfdrive.ui.onroad.augmented_road_view", AugmentedRoadView=AugmentedRoadView)
stub_module(
"openpilot.selfdrive.ui.onroad.starpilot.starpilot_border",
@@ -192,6 +193,7 @@ def test_starpilot_road_overlays_use_the_parent_scissor(monkeypatch):
view.model_renderer = SimpleNamespace(
_path=SimpleNamespace(projected_points=SimpleNamespace(size=1)),
_track_edge_vertices=SimpleNamespace(size=4),
_path_edge_width=0.3,
)
view._font_bold = object()
view._get_border_width = lambda: 0
@@ -209,3 +211,9 @@ def test_starpilot_road_overlays_use_the_parent_scissor(monkeypatch):
view._render_extra_road_overlays(object())
assert events == ["path_edges", "adjacent_lanes", "stopping_point"]
events.clear()
view.model_renderer._path_edge_width = 0.0
view._render_extra_road_overlays(object())
assert events == ["adjacent_lanes", "stopping_point"]