From 54aa20d7c5c98d35b677f193ea51b166144b9038 Mon Sep 17 00:00:00 2001 From: Ying-Li Niu <64801511@qq.com> Date: Fri, 12 Jun 2026 07:24:38 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20display.txt=20=E7=BC=BA=E5=A4=B1=20alpha?= =?UTF-8?q?=20=E9=80=8F=E6=98=8E=E5=BA=A6=E5=8F=82=E6=95=B0=EF=BC=8Cdraw.p?= =?UTF-8?q?y=20=E8=AF=BB=E5=8F=96=E4=B8=8D=E5=88=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit alpha(盒子透明度)未写入 display.txt header, draw.py 回退到默认 0.2 而非 input.txt 配置值。 现在 alpha 通过 header 字段正确传递。 Python 引擎:alpha 支持单值或数组 → 逗号分隔字符串 外部引擎:从 trajectory.txt 读取 alpha 值 --- compute.py | 3 ++- draw.py | 2 +- dynamics.py | 3 ++- examples/case06/input/input.txt | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/compute.py b/compute.py index 16e9811..6fbb319 100644 --- a/compute.py +++ b/compute.py @@ -1459,7 +1459,8 @@ def run_simulation(save_trajectory=0): "damping_force": str(DAMPING_FORCE), "gravity_strength": str(GRAVITY_STRENGTH), "driving_force": str(DRIVING_FORCE), - "use_marker": str(use_marker)} + "use_marker": str(use_marker), + "alpha": ",".join(str(a) for a in (alpha if isinstance(alpha, list) else [alpha]))} ) print(f"[compute] display.txt 已保存至: {disp_path} ({n_frames_actual} 帧)") diff --git a/draw.py b/draw.py index 76a7ad8..3c48389 100644 --- a/draw.py +++ b/draw.py @@ -105,7 +105,7 @@ box_color_b = float(h.get("box_color_b", 0.85)) # 图形界面无关的几何参数(不参与物理计算,仅用于场景外观) # =========================================================================== -info_margin = 36 +info_margin = 8 axis_length = 10.0 initial_camera = { diff --git a/dynamics.py b/dynamics.py index 1df4c03..c3740d2 100644 --- a/dynamics.py +++ b/dynamics.py @@ -245,7 +245,8 @@ def run_case(config_path, runtime_base, input_dir="input", output_dir="output", "damping_force": str(data.get("damping_force", 0)), "gravity_strength": str(data.get("gravity_strength", 1.0)), "driving_force": str(data.get("driving_force", 0)), - "use_marker": str(config.get("use_marker", 0))} + "use_marker": str(config.get("use_marker", 0)), + "alpha": str(data.get("alpha", 0.2))} n_frames = len(indices) compute.save_display_txt( diff --git a/examples/case06/input/input.txt b/examples/case06/input/input.txt index 041513b..cef3232 100644 --- a/examples/case06/input/input.txt +++ b/examples/case06/input/input.txt @@ -88,7 +88,7 @@ use_marker: 1 # ── 显示参数 ────────────────────────────────── # 盒子透明度:单个数值(统一)或 6 个数的数组,按 [-x,+x,-y,+y,-z,+z] 顺序 -alpha: [0.0, 0.0, 0.0, 0.0, 0.0, 0.5] +alpha: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0] # 小球颜色 # 小球半径从 coord_file 的 radius 列读取