From d29fab1a404032f4abbcaec0007220a628c72b16 Mon Sep 17 00:00:00 2001 From: march3 Date: Fri, 17 Mar 2023 14:05:43 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=AA=E9=98=B3=E7=B3=BB=E4=B8=89=E4=BD=93?= =?UTF-8?q?=E6=A8=A1=E6=8B=9F=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- simulators/ursina/ursina_ui.py | 12 ++++++++---- simulators/ursina_simulator.py | 4 ++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/simulators/ursina/ursina_ui.py b/simulators/ursina/ursina_ui.py index 7d166c0..61a54f5 100644 --- a/simulators/ursina/ursina_ui.py +++ b/simulators/ursina/ursina_ui.py @@ -161,10 +161,14 @@ class UrsinaUI: def callback_action(b=body): self.bodies_button_list_click(b) - distance_to_entity = distance(body.planet, camera) - d = distance_to_entity / UrsinaConfig.SCALE_FACTOR / AU - name = f"{body.name}\t距离:{d:.4f}天文单位" - button_dict[name] = callback_action + if body.appeared: + distance_to_entity = distance(body.planet, camera) + d = distance_to_entity / UrsinaConfig.SCALE_FACTOR / AU + name = f"{body.name}\t距离:{d:.4f}天文单位" + button_dict[name] = callback_action + else: + name = f"{body.name}\t距离太远,找不到了" + button_dict[name] = lambda: self.bodies_button_list_click(None) if hasattr(self, "bodies_button_list"): destroy(self.bodies_button_list) diff --git a/simulators/ursina_simulator.py b/simulators/ursina_simulator.py index 35e1813..bea805d 100644 --- a/simulators/ursina_simulator.py +++ b/simulators/ursina_simulator.py @@ -62,8 +62,8 @@ class UrsinaSimulator(Simulator): def on_searching_bodies(self, **kwargs): views = [] for view in self.body_views: - if view.appeared: - views.append(view) + # if view.appeared: + views.append(view) return views -- GitLab