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
+19 -15
View File
@@ -1,6 +1,6 @@
# 首版 playtest 验证说明
更新日期:2026-11-15(Asia/Shanghai)。
更新日期:2026-11-16(Asia/Shanghai)。
这是资产、接触运动和搭建流程的可运行验证台。正式方块规则继续以 [blocks.md](../../references/design/blocks.md) 为准;试验中发现的尺寸冲突在此记录,不自动修改正式规则。
@@ -19,30 +19,30 @@
## 资产与几何结果
六种滑槽分别为直行、顺时针拐弯、逆时针拐弯、缓坡、陡坡和 Y 形汇流。球半径现为 0.3 m(直径 0.6 m);上槽半圆截面、底部圆孔和目标洞口均采用 0.32 m 净半径(直径 0.64 m),径向余量为 0.02 m。模型、导出目录与碰撞体使用同一几何来源。
现用五种滑槽分别为直行、90°弯槽、缓坡、陡坡和 Y 形汇流。球半径现为 0.3 m(直径 0.6 m);顶部半圆槽和目标洞口均采用 0.32 m 净半径(直径 0.64 m),径向余量为 0.02 m。模型、导出目录与碰撞体使用同一几何来源。
模型与碰撞体均保留实际槽面、底部开孔;碰撞采用最终布尔网格的三角面,不使用填满方块的盒形碰撞。所有生成滑槽的布尔网格通过闭合流形边检查,详细测量见 [geometry_report.json](../artifacts/baseline/geometry_report.json)。
模型与碰撞体均保留顶部槽面,底座、侧面和底面保持实心封闭;碰撞采用最终布尔网格的三角面,不使用填满方块的盒形碰撞。所有生成滑槽的布尔网格通过闭合流形边检查,详细测量见 [geometry_report.json](../artifacts/baseline/geometry_report.json)。
滑槽是独立的方块或楔形底座,通过布尔切削生成上方半圆槽和下方拱孔。默认连续路线由一个缓坡和三个直行滑槽拼接,并非一整条长轨模型。当前木材使用基础颜色与粗糙度表达油漆木表面,尚未制作精细木纹贴图。
滑槽是独立的方块或楔形底座,通过布尔切削生成上方半圆槽。默认连续路线由一个缓坡和三个直行滑槽拼接,并非一整条长轨模型。当前木材使用基础颜色与粗糙度表达油漆木表面,尚未制作精细木纹贴图。
滑槽作为固定碰撞对象保持位置,不需要立柱承托。试验场景不再添加装饰立柱;底部通孔试验保留入口、出口及开放底孔所需的承托台,小球由真实孔洞引导,不再生成独立下层导轨。
滑槽作为固定碰撞对象保持位置,不需要立柱承托。试验场景不添加装饰立柱;底孔实验及其承托台已删除。
- 直行、两种拐弯及缓坡的包围尺寸为 1 × 1 × 1 m。Y 形汇流的声明规格及实测尺寸均为 2 × 2 × 1 m。
- 陡坡的包围尺寸为 1 × 1 × 1.5 m。其两端高差保留为 1 m,沿用用户已确认保留的超界试验件外形;此次缩小槽径后仍维持该原型包围尺寸,正式单格规则以后再调整。该资产在目录和界面中均有标记。
- 水平直槽、拐弯和 Y 形的底孔为封闭圆形通孔,孔底与方块底面、孔顶与上槽槽底之间分别约有 0.02 m 实体厚度。缓坡、陡坡的底孔仍部分开放,试验平台提供孔底与进出口承托。
- 六种滑槽的槽面下方均为实体,不再存在下层孔道。
- Y 形在同一侧设置两个相邻、等高的入口,中心相距 1 m,各自连接一个单格直槽;公共出口与其中一路对齐,另一路以连续 S 形曲线并入,不要求对称。单件场景同时展示两个输入直槽和一个输出直槽,验证真实接缝。
- 编辑器按 Y 形四格占用进行选择、替换、旋转及重叠检查;数量配额计为一块。下方孔洞直接按上方路线的对角线镜像制作,通孔自身保留引导表面。
- 编辑器按 Y 形四格占用进行选择、替换、旋转及重叠检查;数量配额计为一块。只有上方槽面参与路线连接。
目标洞口现由 Blender 制作并导出为 `goal_hole.glb`:入口与喉部净半径均为 0.32 m,深度 0.55 m,壁厚 0.04 m。碰撞使用同一空心网格,避免只缩小视觉开口。入洞检测记录球心向下跨过洞底平面的交点,再按洞口净空校验水平位置。
独立半径对比实验已完成选择并清理:删除其 Blender 模型、GLB、Godot 场景、脚本和报告,以及旧镜像下层导轨夹具;当前主模型与五个主试玩场景继续保留。
独立半径对比实验已完成选择并清理:删除其 Blender 模型、GLB、Godot 场景、脚本和报告,以及旧镜像下层导轨夹具;当前保留连续轨道、单件试跑、自由搭建和双球汇流四个试玩预设。底孔测试预设及独立底孔场景均已删除。
## 物理实现与参数
铁球为 SphereShape3D 刚体,半径读取生成的资产目录;均匀实心球惯量按质量和半径生成。所有轨道为静态三角网格碰撞体,铁球与轨道、铁球与铁球碰撞均开启。固定物理频率为 120 Hz,启用连续碰撞检测。
当前 `physics.json` 中的名义铁密度假设为 7870 kg/m³,半径 0.3 m 对应约 890.08 kg;质量值保存在物理预设中。木材接触试验系数为:静摩擦 0.42、动摩擦 0.32、滚动阻力 0.025、回弹 0.08;空气密度 1.225 kg/m³,球阻力系数 0.47。这些是首轮验证参数,不是实验测得的材质常数。
当前 `physics.json` 中的名义铁密度假设为 7870 kg/m³,半径 0.3 m 对应约 890.08 kg;质量值保存在物理预设中。木材接触试验系数为:静摩擦 0.42、动摩擦 0.32、滚动阻力 0.025、回弹 0.08;空气密度 1.225 kg/m³,铁球阻力系数为 0.47,正常计算风力和静止空气阻力。质量与接触值沿用首轮验证参数,不是实验测得的材质常数。
Godot 原生 PhysicsMaterial 只暴露一个摩擦参数;本轮根据接触点滑速切换静/动摩擦系数,再由原生求解器计算接触冲量。这是用于本轮试验的近似,不等价于完整的逐接触双系数材质求解。滚动阻力另施加受限力矩,空气作用使用相对空气速度计算,不额外修改轨道速度。多材质同时接触和铁球之间的独立材质配对尚未完整标定;目前原生回弹合成会使两个铁球各 0.08 的回弹得到约 0.16 的相对恢复表现。[Godot PhysicsMaterial](https://docs.godotengine.org/en/4.7/classes/class_physicsmaterial.html)
@@ -50,17 +50,19 @@ Godot 原生 PhysicsMaterial 只暴露一个摩擦参数;本轮根据接触点
## 验证范围
本次实心底座修改已通过 42 项基础物理检查;另有两套模型的 151 项碰撞/场景检查和 16 项源文件检查,见 [本次验证索引](../README.md)。以下交互流程与双球汇流的完整历史结果未在本轮重复运行。
运行 `./scripts/run.zsh baseline-test` 会刷新 Godot 导入并运行物理、交互流程和双球汇流三组测试。报告记录实际参数、轨迹和结果;退出码非零表示测试失败。
物理测试共 70 项:
物理测试移除底孔通过用例后共 42 项:
- 真空自由落体与球在半圆槽中的静止接触。
- 30° 理想平面上实心球滚动,加速度与解析值比较。
- 水平滚动时关闭/开启滚动阻力的速度差异。
- 两个铁球副本迎面碰撞,检查速度方向与总动量。
- 六种滑槽、四个朝向的上方通过与下方通过;Y 形分别测试两个岔口,共 56 项路径测试。
- 六种滑槽、四个朝向的顶部槽面通行;Y 形分别测试两个岔口,共 28 项路径测试。
- Y 形连接两个相邻直槽及一个出口直槽后,分别测试两个入口和四个朝向,共 8 项完整连接测试。连接测试初速度为 1.6 m/s,其余既有路径测试继续使用原有的 1.2 m/s 或坡道静止释放条件。
- 无接触条件下,质量相差十倍时的风响应比较。
- 无接触条件下,质量相差十倍时的风响应比较;该解析基准直接读取当前铁球的非零阻力配置,仅改变质量,不再单独覆盖阻力系数。
交互流程测试共 30 项:默认重力路线穿过真实洞口、释放、暂停、重试、六种资产选择与四次旋转复位、相邻放置、运行后编辑锁定、删除、拒绝悬空放置、场景配额及鼠标射线选取可见方块;另覆盖 Y 形的合法四格尺寸、超界标记区分、重叠拒绝、四格选择、中心旋转和替换后释放多余格子。
@@ -68,11 +70,11 @@ Godot 原生 PhysicsMaterial 只暴露一个摩擦参数;本轮根据接触点
测试调用真实 Godot 场景和物理引擎。界面按钮通过信号触发、选格通过引擎输入事件路径验证;原生渲染已截图检查。没有声称通过操作系统鼠标自动化完成所有按钮测试。
最新结果见 [物理报告](../artifacts/baseline/physics_report.json) 与 [交互报告](../artifacts/baseline/playtest_report.json)。默认路线约 2.90 秒入洞;30° 平面加速度约 3.5033 m/s²,解析值约 3.5036 m/s²。窗口关闭或不同操作路径不会被这两个数值覆盖,需要按实际试玩继续验证。
当前基础物理结果见 [物理报告](../artifacts/baseline/physics_report.json),历史交互结果见 [交互报告](../artifacts/baseline/playtest_report.json)。历史默认路线约 2.90 秒入洞;当前 30° 平面验证仍与约 3.5036 m/s² 的解析值比较。窗口关闭或不同操作路径不会被这些数值覆盖,需要按实际试玩继续验证。
## 双铁球汇流场景
场景菜单第 5 项为“双铁球 · 汇流入洞”,也可使用 `./scripts/run.zsh merge` 直接打开。布局和出生位置保存在 [scenarios.json](data/scenarios.json) 的 `dual_merge` 项。
场景菜单第 4 项为“双铁球 · 汇流入洞”,也可使用 `./scripts/run.zsh merge` 直接打开。布局和出生位置保存在 [scenarios.json](data/scenarios.json) 的 `dual_merge` 项。
路线由一个 Y 形汇流、五个直槽和两个缓坡组成。A、B 两球使用同一个铁球资产与物理预设,从两条支路相同高度的位置同时静止释放。A 路比 B 路多一个直槽,通过真实行程错开汇入时间;两路在 Y 形的相邻同高入口汇合,经公共水平直槽进入同一个洞口。缩小洞口后,将最后一段下坡改为水平直槽,以减少出口加速造成的撞沿和卡边;未调整球材质,也没有额外推力、延迟释放或轨迹牵引。
@@ -84,4 +86,6 @@ Godot 原生 PhysicsMaterial 只暴露一个摩擦参数;本轮根据接触点
## 后续需验证
陡坡的单格几何仍需做设计取舍;下穿布局需要明确下层承托空间。自由搭建提供格子选择、0.5 m 高度调整、声明占用及包围盒重叠和相邻检查,尚不是完整的表面吸附、精确几何互锁与地图通关验收编辑器。物理系数、多材质同时接触及高速极端组合也需要继续验证。
陡坡的单格几何仍需做设计取舍。自由搭建提供格子选择、0.5 m 高度调整、声明占用及包围盒重叠和相邻检查,尚不是完整的表面吸附、精确几何互锁与地图通关验收编辑器。物理系数、多材质同时接触及高速极端组合也需要继续验证。
2026-11-16 弯槽合并:现用滑槽为直行、90°弯槽、缓坡、陡坡、Y 汇流共五种。早期场景菜单与配额已同步;上文涉及六种滑槽的报告与截图是合并前的历史证据。
+1 -1
View File
@@ -12,7 +12,7 @@ func check(name: String, ok: bool, detail: Dictionary={}) -> void:
func run() -> void:
var app=load("res://playtest/baseline/scenes/main.tscn").instantiate()
root.add_child(app)
app.build_preset(4)
app.build_preset(3)
await physics_frame
check("two_iron_balls_ready",app.merge_balls.size()==2 and app.merge_balls.all(func(b):return b.freeze and is_equal_approx(b.radius,.3) and b.linear_velocity.is_zero_approx()))
check("separate_equal_height_branches",is_equal_approx(app.merge_balls[0].position.y,app.merge_balls[1].position.y) and is_equal_approx(absf(app.merge_balls[0].position.z-app.merge_balls[1].position.z),1.0))
+15 -25
View File
@@ -26,35 +26,26 @@ func record(name: String, passed: bool, detail: Dictionary) -> void:
if not passed:failures+=1
print(("PASS " if passed else "FAIL ")+name+" "+JSON.stringify(detail))
func run_path(kind: String, rotation_step: int, branch: int, lower: bool, connected := false) -> void:
func run_path(kind: String, rotation_step: int, branch: int, connected := false) -> void:
await clear_arena()
var basis:=Basis(Vector3.UP,-rotation_step*PI/2)
arena.add_child(lib.create_piece(kind,Vector3.ZERO,rotation_step))
var sphere=lib.create_ball()
sphere.freeze=true
var descending: bool=not lower and kind in ["gentle","steep"]
var descending: bool=kind in ["gentle","steep"]
var t:=.80 if descending else .05
var direction: Vector3=lib.path_tangent(kind,0,branch,lower)
var direction: Vector3=lib.path_tangent(kind,0,branch)
var start: Vector3
var target: Vector3
var exit_direction: Vector3
if lower:
var guide: Dictionary=lib.lower_passage_spec(kind)
arena.add_child(lib.create_box(Vector3(4,.1,4),Vector3(0,float(guide.floor_y)-.05,0),Color.GRAY))
start=lib.path_point(kind,0,branch,true)-direction*.35+Vector3.UP*.015
start.y=float(guide.center_height)+.015
target=lib.path_point(kind,1,branch,true)
target.y=float(guide.center_height)
exit_direction=lib.path_tangent(kind,1,branch,true)
else:
start=lib.ball_on_surface(kind,t,branch)
target=lib.ball_on_surface(kind,0 if descending else 1,branch)
exit_direction=-lib.path_tangent(kind,0,branch) if descending else lib.path_tangent(kind,1,branch)
if connected:
for local_center in lib.y_connectors():arena.add_child(lib.create_piece("straight",basis*local_center,rotation_step))
start=lib.path_point(kind,0,branch)+Vector3(-.65,-float(lib.catalog[kind].grooveRadius)+sphere.radius+.018,0)
target=lib.path_point(kind,1,branch)+Vector3(.85,-float(lib.catalog[kind].grooveRadius)+sphere.radius,0)
direction=Vector3.RIGHT
start=lib.ball_on_surface(kind,t,branch)
target=lib.ball_on_surface(kind,0 if descending else 1,branch)
exit_direction=-lib.path_tangent(kind,0,branch) if descending else lib.path_tangent(kind,1,branch)
if connected:
for local_center in lib.y_connectors():arena.add_child(lib.create_piece("straight",basis*local_center,rotation_step))
start=lib.path_point(kind,0,branch)+Vector3(-.65,-float(lib.catalog[kind].grooveRadius)+sphere.radius+.018,0)
target=lib.path_point(kind,1,branch)+Vector3(.85,-float(lib.catalog[kind].grooveRadius)+sphere.radius,0)
direction=Vector3.RIGHT
arena.add_child(sphere)
sphere.position=basis*start
await physics_frame
@@ -83,7 +74,7 @@ func run_path(kind: String, rotation_step: int, branch: int, lower: bool, connec
time_at_exit=frame/120.0
break
if p.y < -2:break
var path_name:="connected" if connected else ("lower" if lower else "upper")
var path_name:="connected" if connected else "upper"
record("%s_%s_r%d_b%d" % [path_name,kind,rotation_step*90,branch],reached and contact_frames>0,
{"reached_exit":reached,"time":time_at_exit,"initial_speed":0.0 if descending else initial_speed,"closest_m":closest,"contact_frames":contact_frames,"max_speed":highest_speed,"final":vec(basis.inverse()*sphere.position),"trace":trace})
@@ -156,13 +147,12 @@ func run() -> void:
for i in range(150):await physics_frame
var momentum_error: float=(left.linear_velocity+right.linear_velocity).length()
record("ball_to_ball_collision_enabled",left.linear_velocity.x<-.02 and right.linear_velocity.x>.02 and momentum_error<.02,{"left_velocity":vec(left.linear_velocity),"right_velocity":vec(right.linear_velocity),"normalized_momentum_error":momentum_error})
for kind in ["straight","turn_cw","turn_ccw","gentle","steep","y_merge"]:
for kind in ["straight","turn_90","gentle","steep","y_merge"]:
for q in range(4):
for branch in range(2 if kind=="y_merge" else 1):
await run_path(kind,q,branch,false)
await run_path(kind,q,branch,true)
await run_path(kind,q,branch)
for q in range(4):
for branch in range(2):await run_path("y_merge",q,branch,false,true)
for branch in range(2):await run_path("y_merge",q,branch,true)
# Air response independently of contacts; compare actual simulated velocities.
var air_velocities: Array=[]
for mass_factor in [1.0,10.0]:
@@ -43,12 +43,12 @@ func run() -> void:
check("rotation_cycle_"+kind,app.preview_quarter==0 and app.records[0].quarter==0)
check("y_has_declared_four_cell_footprint",app.lib.footprint("y_merge")==Vector2i(2,2) and app.lib.catalog.y_merge.declaredBoundsFits and app.lib.catalog.y_merge.ports.size()==3)
check("y_not_mislabelled_as_steep_exception",not app.warning_label.text.contains("陡坡"))
app.build_preset(3)
app.build_preset(2)
await physics_frame
var previous: int=app.records.size()
app.selected_cell=Vector2i(2,0)
app.placement_height=.5
app.choose_kind("turn_cw")
app.choose_kind("turn_90")
app.place_selected()
check("place_adjacent_tile",app.records.size()==previous+1 and app.find_cell(Vector2i(2,0))>=0)
app.toggle_run()
+9 -25
View File
@@ -4,11 +4,10 @@
"name": "连续轨道",
"quotas": {
"straight": 6,
"turn_cw": 1,
"turn_ccw": 1,
"gentle": 2,
"steep": 0,
"y_merge": 0
"y_merge": 0,
"turn_90": 2
}
},
{
@@ -16,23 +15,10 @@
"name": "单件试跑",
"quotas": {
"straight": 1,
"turn_cw": 1,
"turn_ccw": 1,
"gentle": 1,
"steep": 1,
"y_merge": 1
}
},
{
"id": "underpass_test",
"name": "底部通孔",
"quotas": {
"straight": 1,
"turn_cw": 1,
"turn_ccw": 1,
"gentle": 1,
"steep": 1,
"y_merge": 1
"y_merge": 1,
"turn_90": 2
}
},
{
@@ -40,11 +26,10 @@
"name": "自由搭建",
"quotas": {
"straight": 12,
"turn_cw": 3,
"turn_ccw": 3,
"gentle": 3,
"steep": 2,
"y_merge": 2
"y_merge": 2,
"turn_90": 6
}
},
{
@@ -52,11 +37,10 @@
"name": "双铁球汇流",
"quotas": {
"straight": 5,
"turn_cw": 0,
"turn_ccw": 0,
"gentle": 2,
"steep": 0,
"y_merge": 1
"y_merge": 1,
"turn_90": 0
},
"layout": [
{
@@ -151,4 +135,4 @@
],
"notes": "Two equal-height iron balls release simultaneously from rest. Branch A has one extra straight tile. The merged outlet remains level to approach the close-fitting 0.32m-radius hole without the former final downhill acceleration."
}
]
]
+4 -9
View File
@@ -104,15 +104,14 @@ func create_box(size: Vector3, location: Vector3, color: Color, solid := true) -
root.physics_material_override = pm
return root
func path_point(kind: String, t: float, branch := 0, lower := false) -> Vector3:
var key := "lowerPaths" if lower else "upperPaths"
var path: Array = catalog[kind][key][branch]
func path_point(kind: String, t: float, branch := 0) -> Vector3:
var path: Array = catalog[kind]["upperPaths"][branch]
var f := clampf(t,0.0,1.0)*(path.size()-1)
var i := mini(int(f),path.size()-2)
return vector(path[i]).lerp(vector(path[i+1]),f-i)
func path_tangent(kind: String, t: float, branch := 0, lower := false) -> Vector3:
return (path_point(kind,minf(t+.02,1.0),branch,lower)-path_point(kind,maxf(t-.02,0.0),branch,lower)).normalized()
func path_tangent(kind: String, t: float, branch := 0) -> Vector3:
return (path_point(kind,minf(t+.02,1.0),branch)-path_point(kind,maxf(t-.02,0.0),branch)).normalized()
func ball_on_surface(kind: String, t: float, branch := 0) -> Vector3:
var p := path_point(kind,t,branch)
@@ -122,10 +121,6 @@ func ball_on_surface(kind: String, t: float, branch := 0) -> Vector3:
var normal := (Vector3.UP-horizontal*slope).normalized()
return p-Vector3.UP*float(catalog[kind]["grooveRadius"])+normal*float(catalog["iron_ball"]["radius"])+Vector3.UP*.018
func lower_passage_spec(kind: String) -> Dictionary:
var floor_y: float=catalog[kind].bottomRouteFloor
return {"floor_y":floor_y,"center_height":floor_y+float(catalog["iron_ball"].radius)}
func footprint(kind: String, quarter := 0) -> Vector2i:
var size: Array=catalog[kind].get("cellFootprint",[1,1])
return Vector2i(int(size[0]),int(size[1])) if quarter%2==0 else Vector2i(int(size[1]),int(size[0]))
+41 -69
View File
@@ -1,8 +1,8 @@
extends Node3D
const Library = preload("res://playtest/baseline/scripts/asset_library.gd")
const IDS = ["straight", "turn_cw", "turn_ccw", "gentle", "steep", "y_merge"]
const NAMES = ["直行", "顺时针拐弯", "逆时针拐弯", "缓坡 · 0.5 m", "陡坡 · 1 m", "Y 汇流 · 2×2"]
const IDS = preload("res://runtime/chute_types.gd").IDS
const NAMES = ["直行", "90°弯槽", "缓坡 · 0.5 m", "陡坡 · 1 m", "Y 汇流 · 2×2"]
const INK = Color("223c37")
const MUTED = Color("647a70")
const ACCENT = Color("347d68")
@@ -219,7 +219,7 @@ func setup_ui() -> void:
panel.add_child(column)
column.add_child(label_for("试验场景",14,MUTED))
mode_selector = OptionButton.new()
for title in ["01 连续轨道 · 重力起跑","02 单件试跑 · 轨道检验","03 底部通孔 · 交叉检验","04 自由搭建 · 修改布局","05 双铁球 · 汇流入洞"]:mode_selector.add_item(title)
for title in ["01 连续轨道 · 重力起跑","02 单件试跑 · 轨道检验","03 自由搭建 · 修改布局","04 双铁球 · 汇流入洞"]:mode_selector.add_item(title)
mode_selector.custom_minimum_size.y = 34
mode_selector.add_theme_stylebox_override("normal",panel_style(Color("e6eade")))
mode_selector.item_selected.connect(build_preset)
@@ -251,7 +251,7 @@ func setup_ui() -> void:
quota_label = label_for("",12,MUTED)
column.add_child(quota_label)
column.add_child(HSeparator.new())
column.add_child(label_for("单件 / 通孔试验初速度",13,MUTED))
column.add_child(label_for("单件试验初速度",13,MUTED))
speed_slider = HSlider.new()
speed_slider.min_value = 0
speed_slider.max_value = 4
@@ -275,7 +275,7 @@ func setup_ui() -> void:
trail_check.toggled.connect(func(on): trail_enabled=on; trail_view.visible=on; second_trail_view.visible=on)
checks.add_child(trail_check)
branch_button=button_for("切换岔口",func():
if started or mode==4:return
if started or mode==3:return
selected_branch=1-selected_branch
configure_spawn();reset_ball()
)
@@ -301,14 +301,14 @@ func setup_ui() -> void:
refresh_ui()
func choose_kind(kind: String) -> void:
if started or mode==4 or quota(kind)<=0:return
if started or mode==3 or quota(kind)<=0:return
selected_kind=kind
preview_quarter=0
selected_branch=0
if kind=="y_merge" and mode==1:
launch_speed=1.6
speed_slider.set_value_no_signal(launch_speed)
if mode==1 or mode==2: build_preset(mode)
if mode==1: build_preset(mode)
else:update_marker()
refresh_ui()
@@ -318,13 +318,13 @@ func add_record(kind: String, position: Vector3, quarter := 0) -> void:
func build_preset(new_mode: int) -> void:
var previous_mode:=mode
mode=new_mode
get_window().title="IntoHole · 双铁球汇流" if mode==4 else "IntoHole · Physics Playtest"
if mode==4:
get_window().title="IntoHole · 双铁球汇流" if mode==3 else "IntoHole · Physics Playtest"
if mode==3:
selected_kind="y_merge"
launch_speed=0
speed_slider.set_value_no_signal(0)
wind_slider.set_value_no_signal(0)
elif previous_mode==4:
elif previous_mode==3:
launch_speed=1.2
speed_slider.set_value_no_signal(launch_speed)
if quota(selected_kind)<=0:selected_kind="straight"
@@ -338,7 +338,7 @@ func build_preset(new_mode: int) -> void:
selected_index=-1
selected_cell=Vector2i.ZERO
records.clear()
if mode==0 or mode==3:
if mode==0 or mode==2:
add_record("gentle",Vector3(-2,1,0),2)
for x in [-1,0,1]:add_record("straight",Vector3(x,.5,0))
goal_position=Vector3(2.0,.5+float(lib.catalog["straight"].ports[0].surface[1]),0)
@@ -346,23 +346,20 @@ func build_preset(new_mode: int) -> void:
elif mode==1:
add_record(selected_kind,Vector3.ZERO)
goal_active=false
elif mode==2:
add_record(selected_kind,Vector3(0,.8,0))
goal_active=false
else:
for entry in scenarios[mode].layout:add_record(entry.kind,lib.vector(entry.position),int(entry.quarter))
goal_position=lib.vector(scenarios[mode].goal)
goal_active=true
selected_index=0 if mode==1 or mode==2 else find_cell(selected_cell)
selected_index=0 if mode==1 else find_cell(selected_cell)
if selected_index>=0:
placement_height=records[selected_index].position.y
preview_quarter=records[selected_index].quarter
rebuild_world()
configure_spawn()
reset_ball()
camera_target=Vector3(-.1,.8,0) if mode==0 or mode==3 else lib.record_center(records[0])+Vector3(0,.55,0)
camera.size=8.0 if mode==0 or mode==3 else (6.2 if selected_kind=="y_merge" else 4.2)
if mode==4:
camera_target=Vector3(-.1,.8,0) if mode==0 or mode==2 else lib.record_center(records[0])+Vector3(0,.55,0)
camera.size=8.0 if mode==0 or mode==2 else (6.2 if selected_kind=="y_merge" else 4.2)
if mode==3:
camera_target=Vector3(.5,1.1,.5)
camera.size=9.5
update_camera()
@@ -388,23 +385,6 @@ func rebuild_world() -> void:
caption.rotation_degrees.x=-45
caption.modulate=Color("385449")
world.add_child(caption)
if mode==2 and not records.is_empty():
var record: Dictionary = records[0]
var center: Vector3=lib.record_center(record)
var footprint: Vector2i=lib.footprint(record.kind,record.quarter)
var guide: Dictionary=lib.lower_passage_spec(record.kind)
var floor_y: float = float(guide.floor_y)+record.position.y
var floor_node=lib.create_box(Vector3(footprint.x+2.4,.12,footprint.y+2.4),Vector3(center.x,floor_y-.06,center.z),Color("6f9e88"))
world.add_child(floor_node)
var caption := Label3D.new()
caption.text="通过真实孔洞 · 净半径 0.32 m"
caption.font=ui_font
caption.outline_size=0
caption.font_size=28
caption.pixel_size=.005
caption.position=Vector3(center.x,floor_y+.01,center.z+footprint.y*.5+.8)
caption.rotation_degrees.x=-90
world.add_child(caption)
if mode==1 and not records.is_empty() and records[0].kind=="y_merge":
var record: Dictionary=records[0]
var transform:=Transform3D(Basis(Vector3.UP,-int(record.quarter)*PI/2),lib.record_center(record))
@@ -425,22 +405,14 @@ func rebuild_world() -> void:
update_marker()
func configure_spawn() -> void:
if mode==4:return
if mode==3:return
if records.is_empty():return
var record: Dictionary=records[0]
if mode==3 and selected_index>=0 and selected_index<records.size():record=records[selected_index]
if mode==2 and selected_index>=0 and selected_index<records.size():record=records[selected_index]
var kind: String=record.kind
var basis := Basis(Vector3.UP,-int(record.quarter)*PI/2)
var transform := Transform3D(basis,lib.record_center(record))
if mode==2:
var branch := mini(selected_branch,lib.catalog[kind].lowerPaths.size()-1)
var start: Vector3=lib.path_point(kind,0,branch,true)
start.y=float(lib.lower_passage_spec(kind).center_height)
var direction: Vector3=lib.path_tangent(kind,0,branch,true)
spawn_transform=Transform3D.IDENTITY
spawn_transform.origin=transform*(start-direction*.55+Vector3.UP*.025)
launch_velocity=basis*direction*launch_speed
elif kind=="gentle" or kind=="steep":
if kind=="gentle" or kind=="steep":
spawn_transform=Transform3D.IDENTITY
spawn_transform.origin=transform*lib.ball_on_surface(kind,.82)
launch_velocity=Vector3.ZERO
@@ -483,7 +455,7 @@ func reset_ball() -> void:
trail_points.clear()
trail_mesh.clear_surfaces()
trail_timer=0
if mode==4:
if mode==3:
create_merge_balls()
status="准备释放 · 两球同时从静止出发"
refresh_ui()
@@ -498,7 +470,7 @@ func reset_ball() -> void:
refresh_ui()
func toggle_run() -> void:
if mode==4:
if mode==3:
toggle_merge_run()
return
if not is_instance_valid(ball):return
@@ -534,13 +506,13 @@ func refresh_ui() -> void:
detail_label.text="%s · %d° · 占用 %d×%d\n底座高度 %.1f m" % [NAMES[IDS.find(selected_kind)],preview_quarter*90,footprint.x,footprint.y,placement_height]
quota_label.text="当前类型 %d / %d 件 · 选格 (%d, %d)" % [count,quota(selected_kind),selected_cell.x,selected_cell.y]
for i in range(type_buttons.size()):
type_buttons[i].disabled=quota(IDS[i])<=0 or started or mode==4
type_buttons[i].disabled=quota(IDS[i])<=0 or started or mode==3
type_buttons[i].add_theme_stylebox_override("normal",panel_style(Color("c5dbc8") if IDS[i]==selected_kind else Color("e6eade")))
start_button.text="▶ 释放铁球" if not started else ("▶ 继续" if paused else "Ⅱ 暂停")
for control in editing_controls:control.disabled=mode==4 or started
branch_button.disabled=mode==4 or started
speed_slider.editable=mode!=4 and not started
if mode==4:
for control in editing_controls:control.disabled=mode==3 or started
branch_button.disabled=mode==3 or started
speed_slider.editable=mode!=3 and not started
if mode==3:
start_button.text="▶ 同时释放两球" if not started else ("▶ 继续" if paused else "Ⅱ 暂停")
if merge_entered.size()+merge_lost.size()==2:start_button.text="↻ 再试一次"
quota_label.text="预设路线 · 两条支路汇入同一洞口"
@@ -548,8 +520,8 @@ func refresh_ui() -> void:
var conflict:=false
for record in records:
if not bool(lib.catalog[record.kind].declaredBoundsFits):conflict=true
warning_label.text="陡坡试验件高 1.5 m,超出单格;保留原高差与球尺寸供验证。" if conflict else ("通孔净半径 0.32 m;平台仅提供进出口承托。" if mode==2 else "当前铁球半径 0.3 m · 开口净半径 0.32 m")
if mode==4:warning_label.text="两球同时释放 · 初速度为零 · 球间碰撞开启"
warning_label.text="陡坡试验件高 1.5 m,超出单格;保留原高差与球尺寸供验证。" if conflict else "实心底座 · 球半径 0.3 m · 槽半径 0.32 m"
if mode==3:warning_label.text="两球同时释放 · 初速度为零 · 球间碰撞开启"
func quota(kind: String) -> int:
return int(scenarios[mode].quotas.get(kind,0))
@@ -574,9 +546,9 @@ func placement_error(candidate: Dictionary, ignore_index := -1) -> String:
return "" if attached else "新滑槽至少一侧需依附已有方块"
func place_selected() -> void:
if started or mode==4:return
if mode==1 or mode==2:
records[0]={"kind":selected_kind,"position":Vector3(0,.8 if mode==2 else 0,0),"quarter":preview_quarter}
if started or mode==3:return
if mode==1:
records[0]={"kind":selected_kind,"position":Vector3.ZERO,"quarter":preview_quarter}
else:
var count:=0
for record in records:
@@ -593,13 +565,13 @@ func place_selected() -> void:
rebuild_world();reset_ball()
func rotate_selected() -> void:
if started or mode==4:return
if started or mode==3:return
var next_quarter: int=(preview_quarter+1)%4
var idx:=0 if mode==1 or mode==2 else find_cell(selected_cell)
var idx:=0 if mode==1 else find_cell(selected_cell)
if idx>=0:
var candidate: Dictionary=records[idx].duplicate()
candidate.quarter=next_quarter
var issue: String=placement_error(candidate,idx) if mode in [0,3] else ""
var issue: String=placement_error(candidate,idx) if mode in [0,2] else ""
if not issue.is_empty():status=issue;refresh_ui();return
records[idx]=candidate
preview_quarter=next_quarter
@@ -610,15 +582,15 @@ func rotate_selected() -> void:
refresh_ui()
func change_height(amount: float) -> void:
if started or mode==4:return
if started or mode==3:return
var new_height: float=clampf(placement_height+amount,-.5,3.0)
var idx:=0 if mode==1 or mode==2 else find_cell(selected_cell)
var idx:=0 if mode==1 else find_cell(selected_cell)
if idx>=0:
var pos: Vector3=records[idx].position
pos.y=new_height
var candidate: Dictionary=records[idx].duplicate()
candidate.position=pos
var issue: String=placement_error(candidate,idx) if mode in [0,3] else ""
var issue: String=placement_error(candidate,idx) if mode in [0,2] else ""
if not issue.is_empty():status=issue;refresh_ui();return
records[idx]=candidate
placement_height=new_height
@@ -629,7 +601,7 @@ func change_height(amount: float) -> void:
refresh_ui()
func remove_selected() -> void:
if started or mode in [1,2,4]:return
if started or mode in [1,3]:return
var idx:=find_cell(selected_cell)
if idx>=0:
records.remove_at(idx)
@@ -640,7 +612,7 @@ func update_marker() -> void:
if is_instance_valid(cell_marker):cell_marker.queue_free()
cell_marker=Node3D.new()
add_child(cell_marker)
if mode in [1,2,4]:return
if mode in [1,3]:return
var footprint: Vector2i=lib.footprint(selected_kind,preview_quarter)
var center:=Vector3(selected_cell.x+(footprint.x-1)*.5,placement_height+.01,selected_cell.y+(footprint.y-1)*.5)
for axis in range(2):
@@ -664,7 +636,7 @@ func _unhandled_input(event: InputEvent) -> void:
if event.button_index==MOUSE_BUTTON_RIGHT:orbiting=event.pressed
if event.pressed and event.button_index==MOUSE_BUTTON_WHEEL_UP:camera.size=maxf(2.5,camera.size-.5)
if event.pressed and event.button_index==MOUSE_BUTTON_WHEEL_DOWN:camera.size=minf(16,camera.size+.5)
if event.pressed and event.button_index==MOUSE_BUTTON_LEFT and not started and mode in [0,3]:
if event.pressed and event.button_index==MOUSE_BUTTON_LEFT and not started and mode in [0,2]:
var origin:=camera.project_ray_origin(event.position)
var direction:=camera.project_ray_normal(event.position)
var query:=PhysicsRayQueryParameters3D.create(origin,origin+direction*100,1)
@@ -698,7 +670,7 @@ func _unhandled_input(event: InputEvent) -> void:
update_camera()
func _physics_process(delta: float) -> void:
if mode==4:
if mode==3:
process_merge(delta)
return
if not is_instance_valid(ball):return
@@ -713,7 +685,7 @@ func _physics_process(delta: float) -> void:
ball.collision_layer=0
ball.collision_mask=0
refresh_ui()
elif ball.position.y<-.65 and mode!=2 or ball.position.y<-2.0 or ball.position.length()>30:
elif ball.position.y<-.65 or ball.position.length()>30:
status="已离开轨道 · 调整布局后重试"
ball.freeze=true
refresh_ui()