feat: 更新 IntoHole 的球体、滑槽和环境资产

- 为铁球、陶瓷球和木球制作风格化材质,归档 CC0 原始参考
- 更新方形球洞和实心滑槽,统一 90° 弯槽并兼容旧存档
- 用顺流泡沫表示水流方向,为冰块制作三种交错的裂纹
- 同步 Blender 源资产、Godot 加载、工坊和试玩预览
This commit is contained in:
Yanchen
2026-11-19 16:18:41 +08:00
parent 39ff1fd7b4
commit d1141b04c7
467 changed files with 67228 additions and 44624 deletions
+72
View File
@@ -0,0 +1,72 @@
# 水、冰与墙面实验
更新日期:2026-11-17(Asia/Shanghai)。水方块、冰方块及墙面接触的这套数值现已确认,并同步至 [方块设定](../../references/design/blocks.md) 与 [物理系统](../../references/design/physics_system.md)。本目录持续保留可编辑、可运行的测试场景,用于调整各材质小球的质量;不因参数确认而删除,也不迁移为正式关卡。没有新增环境风或泥土方块。
```sh
./scripts/environment.zsh
./scripts/run.zsh test-environment
./scripts/run.zsh capture-environment
```
也可双击 [Environment.command](../../scripts/Environment.command),或运行 [environment.tscn](scenes/environment.tscn)。从下拉菜单选择水流、同高度撞击、静置承重、墙面制动或冰面滑行。空格释放/暂停,T 重置,右键转视角,滚轮缩放。
“在工坊编辑当前布局”会把当前配置复制到工坊,可修改水块位置、方向,保存为工坊草稿。实验 JSON 保留在 [data](data/),不直接覆盖。水块位于非交互方块菜单,冰块位于交互方块菜单;两者沿用现有放置、选择、90° 旋转和存档流程。放置预览和实景水块均用移动的泡沫显示方向,见 [水流对照场景](../water/scenes/flow_preview.tscn)。
## 水块
水块尺寸为 1×1×1 米,无固体碰撞,表面有顺流漂动的泡沫。河床和河岸由独立墙壁方块组成。场景编辑中的水块选择区域仅供选取,不阻挡球。
水流固定为 **5 m/s**,由 [behavior.gd](../../assets/blocks/water/behavior.gd) 的常量定义;关卡只保存位置与朝向,没有逐块速度控件。额外写入的 `flowSpeed` 字段不会被载入为速度,也不保留在再次保存的文件中。
当前测试使用水密度 1000 kg/m³、水中阻力系数 0.47,三种球共用水的作用公式,保持原有质量、尺寸和空气响应配置。浸没体积通过球体竖直截柱与相邻水格范围的并集求得;浮力为排开水的重量,水阻力按相对流速计算。跨格不产生固体接缝,重叠体积不会重复提供浮力。不同流向接缝按浸没部分合成当前有效流速,是首版近似。
当前是由作者铺设的固定水域,不进行水源扩散、水量守恒或河道流体求解。方块朝向指定局部流向;水不能把球穿过实际河岸。没有按球种类硬编码浮沉或锁定沉底球。
三球同时释放后,木球浮起并到达下游;330 kg 陶瓷球与铁球沉到粗糙墙壁河床,仍受水流作用。8 秒模拟时陶瓷球最大水平位移约 1.36 m、速度约 0.10 m/s;铁球位移约 0.38 m、速度约 0.039 m/s。木球到达尽头后会受到岸壁碰撞和摩擦,截图中的最终浸没比例不应当作为自由漂浮平衡比例。水速 5 m/s 不等于小球必须以 5 m/s 运动。
## 冰块
冰块是静态实心 1×1×1 方块。与三种球的接触参数统一采用静摩擦 0.03、动摩擦 0.02、滚动阻力 0.002、恢复系数 0.02;配置见 [physics.json](../../assets/collections/storybook/physics.json)。
破碎按一次真实接触事件的**法向冲量 1000 N·s**判定,接近速度需达到 0.5 m/s 以排除静态接触及低速噪声。冲量是力对碰撞时间的积分,这里不使用依赖物理步长的单帧“力峰值”。同一事件的接触点合并计算,持续承重不累计冲量;预测接触不会提前消耗本次撞击。破碎后移除该冰块的实体碰撞与外观,重置恢复完整冰块及判定状态。
使用原木 60 kg、陶瓷 330 kg、铁球约 890.08 kg 的真实预设,半径均为 0.3 m。从球底距冰面 **1 m** 处同时静止释放,120 Hz 结果如下:
| 小球 | 一次撞击法向冲量 | 结果 |
| --- | ---: | --- |
| 原木球 | 约 291 N·s | 冰块完整。 |
| 陶瓷球 | 约 1602 N·s | 冰块破碎,球落到下层墙面。 |
| 铁球 | 约 4322 N·s | 冰块破碎,球落到下层墙面。 |
对照:铁球静置 10 秒不破碎;3 cm 落差铁球约 509 N·s,不破碎;20 m 落差木球约 1270 N·s,会破碎。阈值不是球种类或静态质量开关。60 / 120 / 240 Hz 下三种球的 1 m 落差判定一致,冲量差异约 2%。这些数值是玩法试验阈值,不代表现实冰材的强度。
Jolt 的接触冲量属于预估值,多物体同时接触时可能不精确。当前同高度实验让每颗球独立撞击自己的冰块,尚不能据此声称多球挤压、堆叠碎裂也完成精确标定。[Godot Jolt 接触冲量说明](https://github.com/godotengine/godot-docs/blob/4.7/tutorials/physics/using_jolt_physics.rst)
## 墙壁减速
所有现用 `wall` 方块与三种球的接触参数均调整为静摩擦 **1.0**、动摩擦 **0.9**、滚动阻力 **0.8**、恢复系数 **0.02**。各面共享同一规则,无需逐块配置;滑槽、球洞、加速方块不因外观接近墙块而继承这些数值。
滑动摩擦由原生接触求解,滚动阻力通过受限力矩耗能;受压墙侧面也参与。没有按位置停止球、修改球质量或添加泥沙机制。当前仍沿用每刚体摩擦近似:同时接触多种表面时选择较粗糙的已配置接触对,不等价于独立逐接触材质求解。
3 m/s 初速的专项测试中,三球从滑动开始约 0.40~0.41 秒、0.52 m 后降至停止容差;从纯滚动开始约 0.54 秒、0.81 m。停止容差为线速度低于 0.05 m/s。相同初态的冰面对照在 2 秒后仍有约 2.4~2.8 m/s。
可视墙面/冰面场景使用相同固定加速块从静止起步(+5 m/s);上述 3 m/s 初态只用于受控制动测量。
## 后续小球质量调校
实际修改 [现用 physics.json](../../assets/collections/storybook/physics.json) 中对应预设的 `massKg`:原木 `wood_game`、陶瓷 `ceramic_game`、铁球 `solid_iron_test`。当前起始质量为 60 / 330 / 890.0760306150601 kg;330 kg 陶瓷球已正式应用,计算阶段的 75 kg 输入与原结果作为历史记录保留。质量改变后,运行时按原半径和惯量模型重新计算转动惯量,不需要重建模型。
每轮先明确预期,优先只改一种球的质量;固定水速、冰块阈值、表面接触参数、几何及对照初态。重跑相关场景,记录浮沉、冲量/破碎、停止时间和距离。三球从相同高度释放,不通过改变初速度或高度抵消质量变化;既有受风、入洞和加速回归仍在 `playtest/materials/`。
`test-environment` 与 `test-balls` 的断言包含当前质量、比例和玩法预期。调整后若失败,应先解释差异并确认新的目标,再更新预期;不能静默覆盖测试中的真实质量或为了通过而降低检查标准。将每轮实际配置、初态与报告保留到 `playtest/artifacts/environment/mass_tuning/<轮次>/`,完整约定见 [质量调校流程](../../references/design/physics_system.md#25-小球质量的持续调校)。
以下数值与报告是 **2026-11-17 陶瓷球采用 330 kg 后的验证记录**,已重新运行环境专项与三球回归。之前的 75 kg 配置和报告保存在 [本轮调校记录](../artifacts/environment/mass_tuning/2026-11-17_ceramic_330/README.md),不作为新质量的运行证据。
## 验证产物
- [环境专项报告](../artifacts/environment/report.json):99 项通过,覆盖水流方向、不可覆盖固定速度、浸没与接缝、浮沉、暂停、冲击与静置、三个物理频率、破碎碰撞移除、重置、墙壁各面材质及工坊菜单放置、旋转、删除、撤销和保存恢复。
- [三球回归](../artifacts/styled/ball_materials_report.json):115 项通过,保留滚动入洞、空气响应和定向加速行为。
- [源模型重开检查](../artifacts/styled/reopened_assets.json):18 项通过,含水、冰独立源文件。
- [当前泡沫动图](../artifacts/water_flow/preview.gif)、[早期水流画面](../artifacts/environment/water_running.png)、[冰块冲击](../artifacts/environment/ice_impact.png)、[静置承重](../artifacts/environment/ice_static_load.png)、[墙面制动](../artifacts/environment/wall_stop.png)。
物理报告来自真实 Godot 运行。编辑验证使用控件信号与物理射线路径;截图来自原生渲染,没有声称完成操作系统级鼠标自动化。
+112
View File
@@ -0,0 +1,112 @@
{
"schemaVersion": 2,
"assetFamily": "railbound_inspired",
"title": "冰块 · 同高冲击",
"pieces": [],
"entities": [
{
"id": "ice_0",
"kind": "ice",
"position": [
0,
0,
-3
],
"quarter": 0
},
{
"id": "wall_1",
"kind": "wall",
"position": [
0,
-1,
-3
],
"quarter": 0
},
{
"id": "ice_2",
"kind": "ice",
"position": [
0,
0,
0
],
"quarter": 0
},
{
"id": "wall_3",
"kind": "wall",
"position": [
0,
-1,
0
],
"quarter": 0
},
{
"id": "ice_4",
"kind": "ice",
"position": [
0,
0,
3
],
"quarter": 0
},
{
"id": "wall_5",
"kind": "wall",
"position": [
0,
-1,
3
],
"quarter": 0
}
],
"balls": [
{
"id": "wood_ball",
"ballTypeId": "wood_ball",
"position": [
0,
2.3,
-3
],
"launchDirection": [
1,
0,
0
]
},
{
"id": "ceramic_ball",
"ballTypeId": "ceramic_ball",
"position": [
0,
2.3,
0
],
"launchDirection": [
1,
0,
0
]
},
{
"id": "iron_ball",
"ballTypeId": "iron_ball",
"position": [
0,
2.3,
3
],
"launchDirection": [
1,
0,
0
]
}
]
}
+412
View File
@@ -0,0 +1,412 @@
{
"schemaVersion": 2,
"assetFamily": "railbound_inspired",
"title": "冰面 · 低阻力对照",
"pieces": [],
"entities": [
{
"id": "directional_boost_0",
"kind": "directional_boost",
"position": [
-2,
0,
-3
],
"quarter": 0
},
{
"id": "ice_1",
"kind": "ice",
"position": [
-1,
0,
-3
],
"quarter": 0
},
{
"id": "ice_2",
"kind": "ice",
"position": [
0,
0,
-3
],
"quarter": 0
},
{
"id": "ice_3",
"kind": "ice",
"position": [
1,
0,
-3
],
"quarter": 0
},
{
"id": "ice_4",
"kind": "ice",
"position": [
2,
0,
-3
],
"quarter": 0
},
{
"id": "ice_5",
"kind": "ice",
"position": [
3,
0,
-3
],
"quarter": 0
},
{
"id": "ice_6",
"kind": "ice",
"position": [
4,
0,
-3
],
"quarter": 0
},
{
"id": "ice_7",
"kind": "ice",
"position": [
5,
0,
-3
],
"quarter": 0
},
{
"id": "ice_8",
"kind": "ice",
"position": [
6,
0,
-3
],
"quarter": 0
},
{
"id": "ice_9",
"kind": "ice",
"position": [
7,
0,
-3
],
"quarter": 0
},
{
"id": "ice_10",
"kind": "ice",
"position": [
8,
0,
-3
],
"quarter": 0
},
{
"id": "ice_11",
"kind": "ice",
"position": [
9,
0,
-3
],
"quarter": 0
},
{
"id": "directional_boost_12",
"kind": "directional_boost",
"position": [
-2,
0,
0
],
"quarter": 0
},
{
"id": "ice_13",
"kind": "ice",
"position": [
-1,
0,
0
],
"quarter": 0
},
{
"id": "ice_14",
"kind": "ice",
"position": [
0,
0,
0
],
"quarter": 0
},
{
"id": "ice_15",
"kind": "ice",
"position": [
1,
0,
0
],
"quarter": 0
},
{
"id": "ice_16",
"kind": "ice",
"position": [
2,
0,
0
],
"quarter": 0
},
{
"id": "ice_17",
"kind": "ice",
"position": [
3,
0,
0
],
"quarter": 0
},
{
"id": "ice_18",
"kind": "ice",
"position": [
4,
0,
0
],
"quarter": 0
},
{
"id": "ice_19",
"kind": "ice",
"position": [
5,
0,
0
],
"quarter": 0
},
{
"id": "ice_20",
"kind": "ice",
"position": [
6,
0,
0
],
"quarter": 0
},
{
"id": "ice_21",
"kind": "ice",
"position": [
7,
0,
0
],
"quarter": 0
},
{
"id": "ice_22",
"kind": "ice",
"position": [
8,
0,
0
],
"quarter": 0
},
{
"id": "ice_23",
"kind": "ice",
"position": [
9,
0,
0
],
"quarter": 0
},
{
"id": "directional_boost_24",
"kind": "directional_boost",
"position": [
-2,
0,
3
],
"quarter": 0
},
{
"id": "ice_25",
"kind": "ice",
"position": [
-1,
0,
3
],
"quarter": 0
},
{
"id": "ice_26",
"kind": "ice",
"position": [
0,
0,
3
],
"quarter": 0
},
{
"id": "ice_27",
"kind": "ice",
"position": [
1,
0,
3
],
"quarter": 0
},
{
"id": "ice_28",
"kind": "ice",
"position": [
2,
0,
3
],
"quarter": 0
},
{
"id": "ice_29",
"kind": "ice",
"position": [
3,
0,
3
],
"quarter": 0
},
{
"id": "ice_30",
"kind": "ice",
"position": [
4,
0,
3
],
"quarter": 0
},
{
"id": "ice_31",
"kind": "ice",
"position": [
5,
0,
3
],
"quarter": 0
},
{
"id": "ice_32",
"kind": "ice",
"position": [
6,
0,
3
],
"quarter": 0
},
{
"id": "ice_33",
"kind": "ice",
"position": [
7,
0,
3
],
"quarter": 0
},
{
"id": "ice_34",
"kind": "ice",
"position": [
8,
0,
3
],
"quarter": 0
},
{
"id": "ice_35",
"kind": "ice",
"position": [
9,
0,
3
],
"quarter": 0
}
],
"balls": [
{
"id": "wood_ball",
"ballTypeId": "wood_ball",
"position": [
-2,
1.302,
-3
],
"launchDirection": [
1,
0,
0
]
},
{
"id": "ceramic_ball",
"ballTypeId": "ceramic_ball",
"position": [
-2,
1.302,
0
],
"launchDirection": [
1,
0,
0
]
},
{
"id": "iron_ball",
"ballTypeId": "iron_ball",
"position": [
-2,
1.302,
3
],
"launchDirection": [
1,
0,
0
]
}
]
}
+112
View File
@@ -0,0 +1,112 @@
{
"schemaVersion": 2,
"assetFamily": "railbound_inspired",
"title": "冰块 · 静置承重",
"pieces": [],
"entities": [
{
"id": "ice_0",
"kind": "ice",
"position": [
0,
0,
-3
],
"quarter": 0
},
{
"id": "wall_1",
"kind": "wall",
"position": [
0,
-1,
-3
],
"quarter": 0
},
{
"id": "ice_2",
"kind": "ice",
"position": [
0,
0,
0
],
"quarter": 0
},
{
"id": "wall_3",
"kind": "wall",
"position": [
0,
-1,
0
],
"quarter": 0
},
{
"id": "ice_4",
"kind": "ice",
"position": [
0,
0,
3
],
"quarter": 0
},
{
"id": "wall_5",
"kind": "wall",
"position": [
0,
-1,
3
],
"quarter": 0
}
],
"balls": [
{
"id": "wood_ball",
"ballTypeId": "wood_ball",
"position": [
0,
1.302,
-3
],
"launchDirection": [
1,
0,
0
]
},
{
"id": "ceramic_ball",
"ballTypeId": "ceramic_ball",
"position": [
0,
1.302,
0
],
"launchDirection": [
1,
0,
0
]
},
{
"id": "iron_ball",
"ballTypeId": "iron_ball",
"position": [
0,
1.302,
3
],
"launchDirection": [
1,
0,
0
]
}
]
}
+412
View File
@@ -0,0 +1,412 @@
{
"schemaVersion": 2,
"assetFamily": "railbound_inspired",
"title": "墙面 · 快速制动",
"pieces": [],
"entities": [
{
"id": "directional_boost_0",
"kind": "directional_boost",
"position": [
-2,
0,
-3
],
"quarter": 0
},
{
"id": "wall_1",
"kind": "wall",
"position": [
-1,
0,
-3
],
"quarter": 0
},
{
"id": "wall_2",
"kind": "wall",
"position": [
0,
0,
-3
],
"quarter": 0
},
{
"id": "wall_3",
"kind": "wall",
"position": [
1,
0,
-3
],
"quarter": 0
},
{
"id": "wall_4",
"kind": "wall",
"position": [
2,
0,
-3
],
"quarter": 0
},
{
"id": "wall_5",
"kind": "wall",
"position": [
3,
0,
-3
],
"quarter": 0
},
{
"id": "wall_6",
"kind": "wall",
"position": [
4,
0,
-3
],
"quarter": 0
},
{
"id": "wall_7",
"kind": "wall",
"position": [
5,
0,
-3
],
"quarter": 0
},
{
"id": "wall_8",
"kind": "wall",
"position": [
6,
0,
-3
],
"quarter": 0
},
{
"id": "wall_9",
"kind": "wall",
"position": [
7,
0,
-3
],
"quarter": 0
},
{
"id": "wall_10",
"kind": "wall",
"position": [
8,
0,
-3
],
"quarter": 0
},
{
"id": "wall_11",
"kind": "wall",
"position": [
9,
0,
-3
],
"quarter": 0
},
{
"id": "directional_boost_12",
"kind": "directional_boost",
"position": [
-2,
0,
0
],
"quarter": 0
},
{
"id": "wall_13",
"kind": "wall",
"position": [
-1,
0,
0
],
"quarter": 0
},
{
"id": "wall_14",
"kind": "wall",
"position": [
0,
0,
0
],
"quarter": 0
},
{
"id": "wall_15",
"kind": "wall",
"position": [
1,
0,
0
],
"quarter": 0
},
{
"id": "wall_16",
"kind": "wall",
"position": [
2,
0,
0
],
"quarter": 0
},
{
"id": "wall_17",
"kind": "wall",
"position": [
3,
0,
0
],
"quarter": 0
},
{
"id": "wall_18",
"kind": "wall",
"position": [
4,
0,
0
],
"quarter": 0
},
{
"id": "wall_19",
"kind": "wall",
"position": [
5,
0,
0
],
"quarter": 0
},
{
"id": "wall_20",
"kind": "wall",
"position": [
6,
0,
0
],
"quarter": 0
},
{
"id": "wall_21",
"kind": "wall",
"position": [
7,
0,
0
],
"quarter": 0
},
{
"id": "wall_22",
"kind": "wall",
"position": [
8,
0,
0
],
"quarter": 0
},
{
"id": "wall_23",
"kind": "wall",
"position": [
9,
0,
0
],
"quarter": 0
},
{
"id": "directional_boost_24",
"kind": "directional_boost",
"position": [
-2,
0,
3
],
"quarter": 0
},
{
"id": "wall_25",
"kind": "wall",
"position": [
-1,
0,
3
],
"quarter": 0
},
{
"id": "wall_26",
"kind": "wall",
"position": [
0,
0,
3
],
"quarter": 0
},
{
"id": "wall_27",
"kind": "wall",
"position": [
1,
0,
3
],
"quarter": 0
},
{
"id": "wall_28",
"kind": "wall",
"position": [
2,
0,
3
],
"quarter": 0
},
{
"id": "wall_29",
"kind": "wall",
"position": [
3,
0,
3
],
"quarter": 0
},
{
"id": "wall_30",
"kind": "wall",
"position": [
4,
0,
3
],
"quarter": 0
},
{
"id": "wall_31",
"kind": "wall",
"position": [
5,
0,
3
],
"quarter": 0
},
{
"id": "wall_32",
"kind": "wall",
"position": [
6,
0,
3
],
"quarter": 0
},
{
"id": "wall_33",
"kind": "wall",
"position": [
7,
0,
3
],
"quarter": 0
},
{
"id": "wall_34",
"kind": "wall",
"position": [
8,
0,
3
],
"quarter": 0
},
{
"id": "wall_35",
"kind": "wall",
"position": [
9,
0,
3
],
"quarter": 0
}
],
"balls": [
{
"id": "wood_ball",
"ballTypeId": "wood_ball",
"position": [
-2,
1.302,
-3
],
"launchDirection": [
1,
0,
0
]
},
{
"id": "ceramic_ball",
"ballTypeId": "ceramic_ball",
"position": [
-2,
1.302,
0
],
"launchDirection": [
1,
0,
0
]
},
{
"id": "iron_ball",
"ballTypeId": "iron_ball",
"position": [
-2,
1.302,
3
],
"launchDirection": [
1,
0,
0
]
}
]
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,6 @@
[gd_scene load_steps=2 format=3]
[ext_resource type="Script" path="res://playtest/environment/scripts/environment.gd" id="1"]
[node name="EnvironmentLab" type="Node3D"]
script = ExtResource("1")
+104
View File
@@ -0,0 +1,104 @@
extends "res://designer/scripts/studio.gd"
const MODES = ["water","ice","rest","wall","ice_slide"]
const NAMES = ["水流 · 固定 5 m/s","冰块 · 同高度撞击","冰块 · 静置承重","墙壁 · 快速减速","冰面 · 低阻力对照"]
var test_mode := "water"
var drop_height := 1.0
var mode_selector: OptionButton
var description: Label
var metrics: Label
var drop_control: SpinBox
var rotate_water: Button
func make_tree(_at: Vector3) -> void:pass
func setup_environment() -> void:
super.setup_environment()
for node in get_children():
if node is MeshInstance3D and node!=ground_view:
remove_child(node);node.queue_free()
camera.h_offset=-2.2
func setup_ui() -> void:
var layer:=CanvasLayer.new();add_child(layer)
var panel:=PanelContainer.new();layer.add_child(panel)
panel.position=Vector2(20,20);panel.custom_minimum_size=Vector2(340,0)
panel.add_theme_stylebox_override("panel",style(PAPER))
var col:=VBoxContainer.new();panel.add_child(col);col.add_theme_constant_override("separation",12)
col.add_child(label("水与冰 · 物理实验",25))
col.add_child(label("同尺寸三球 · 使用真实材质配置",14))
mode_selector=OptionButton.new()
for title in NAMES:mode_selector.add_item(title)
mode_selector.item_selected.connect(func(i):load_mode(MODES[i]))
col.add_child(mode_selector)
description=label("",14);description.custom_minimum_size.x=310;description.autowrap_mode=TextServer.AUTOWRAP_WORD_SMART;col.add_child(description)
var drop_row:=row(col);drop_row.add_child(label("球底释放高度(米)",14))
drop_control=SpinBox.new();drop_control.min_value=.01;drop_control.max_value=20;drop_control.step=.1;drop_control.value=1
drop_control.value_changed.connect(func(value):drop_height=value;load_mode("ice"))
drop_row.add_child(drop_control)
rotate_water=button("↻ 水流方向旋转 90°",rotate_flow);col.add_child(rotate_water)
var controls:=row(col)
run_button=button("同时释放",toggle_run,true);controls.add_child(run_button)
controls.add_child(button("重置",reset_simulation))
col.add_child(button("在工坊编辑当前布局",edit_layout))
metrics=label("",15);col.add_child(metrics)
col.add_child(label("空格 释放/暂停 · T 重置\n右键转视角 · 滚轮缩放",13))
func initialize_level() -> void:
get_window().title="IntoHole · 水流、冰块与墙面实验"
for arg in OS.get_cmdline_user_args():
if arg.begins_with("--case="):test_mode=arg.trim_prefix("--case=")
load_mode(test_mode)
func load_mode(mode: String) -> void:
test_mode=mode if mode in MODES else "water"
var data: Dictionary=JSON.parse_string(FileAccess.get_file_as_string("res://playtest/environment/data/"+test_mode+".json"))
if test_mode=="ice":
for ball in data.balls:ball.position[1]=1+lib.ball_radius(ball.ballTypeId)+drop_height
apply_data(data)
mode_selector.select(MODES.find(test_mode))
target=Vector3(3.5,1,0) if test_mode in ["water","wall","ice_slide"] else Vector3(0,1.2,0)
pitch=1.05 if test_mode=="water" else .78
camera_size=15 if test_mode in ["water","wall","ice_slide"] else 9.5
update_camera();refresh_ui()
func rotate_flow() -> void:
if started:return
for record in records:
if record.kind=="water":record.quarter=(record.quarter+1)%4
rebuild();reset_simulation()
func edit_layout() -> void:
var data:=encode()
var workshop=load("res://designer/scenes/workshop.tscn").instantiate()
get_tree().root.add_child(workshop)
workshop.apply_data(data)
queue_free()
func reset_simulation() -> void:
super.reset_simulation()
for i in range(tags.size()):tags[i].text=kind_name(spawn_specs[i].ballTypeId);tags[i].font_size=28;tags[i].no_depth_test=true
refresh_ui()
func refresh_ui() -> void:
if metrics==null or run_button==null:return
run_button.text="继续" if paused else "暂停" if started else "同时释放"
drop_control.editable=not started and test_mode=="ice"
rotate_water.visible=test_mode=="water";rotate_water.disabled=started
description.text={"water":"流速固定 5 m/s · 水面泡沫顺流漂动\n水体可穿入 · 河床/岸壁是独立墙块",
"ice":"同一高度从静止释放 · 冲量 ≥ 1000 N·s 破碎\n不累计静置承重 · 不是按球种类判定",
"rest":"三球直接放在冰面上 · 无释放落差\n检验重铁球持续承重也不会压碎冰块",
"wall":"固定加速块起步 +5 m/s · 粗糙墙面制动\n三种球使用相同的墙面接触规则",
"ice_slide":"相同加速起点 · 冰面低摩擦、低滚阻\n与墙面场景对比滑行距离"}[test_mode]
var lines: PackedStringArray=[]
for i in range(balls.size()):
var ball=balls[i]
var line: String="%s · %.0f kg\n速度 %.2f m/s · 球心高度 %.2f m"%[kind_name(spawn_specs[i].ballTypeId),ball.mass,ball.linear_velocity.length(),ball.position.y]
if test_mode=="water":line+="\n浸没 %.0f%% · 浮力 %.0f N"%[ball.submerged_fraction*100,ball.buoyancy_force.length()]
elif test_mode in ["ice","rest"]:
for piece in pieces:
if piece.has_method("receive_impact") and absf(piece.position.z-ball.position.z)<.5:
line+="\n%s · 峰值冲量 %.0f N·s"%["已破碎" if piece.broken else "完整",piece.peak_impulse]
else:line+="\n前进 %.2f m"%(ball.position.x-float(spawn_specs[i].position[0]))
lines.append(line)
metrics.text="时间 %.2f s\n\n"%elapsed+"\n\n".join(lines)
@@ -0,0 +1 @@
uid://dupp65jnyi18j