feat: 切换至滚动阻力运行模型并更新资产、编辑器与验证
- 物理规则:现行模型仅保留滚动阻力耗能与恢复系数碰撞,风力、空气阻力、静摩擦、动摩擦不再参与运行;确认三球质量 60/330/约890 kg 及水密度、流阻参数 - 定向加速改为真实顶面接触触发的一次性 +5 m/s 速度事件,模型新增渐进式 U 形导槽出口 - 更新球体、滑槽、水/冰/墙、球洞模型与 storybook 目录、物理、实体配置 - 工坊摆放、编辑器、运行适配与检查脚本同步;删除过时的 baseline 三组检查 - 新增谜题设计参考文档、关卡草稿与本轮实验产物
This commit is contained in:
+5
-5
@@ -46,7 +46,7 @@
|
||||
|
||||
标准墙壁是实心 **1×1×1 m** 立方体,碰撞采用从模型包围尺寸生成的实心盒体。球洞重新建模为 **1×1×1 m** 的漏斗外形:上口半径 0.46 m,锥面下降 0.35 m 后收窄至 0.32 m 的喉口,通道总深度 1 m。锥面和喉口均有真实三角面碰撞,靠重力与接触引导球进入,没有吸附或轨迹牵引。球洞的模型原点仍在上沿,墙壁的模型原点在底部;工坊坐标栏统一显示方块底面,内部自动换算模型原点,既有存档坐标不整体平移。
|
||||
|
||||
原木球、陶瓷球、铁球均为独立资产,球面几何与半径完全相同。原木使用木纹,陶瓷使用浅色釉面与蓝色纹饰;各自具有源文件、制作代码、GLB 和资源索引。质量依次为 60 / 330 / 约 890.08 kg,陶瓷为原木质量的 5.5 倍;空气阻力系数依次为 0.47 / 0.04 / 0.47。铁球也受到风力;同样空气力下其加速度更小,且当前滑槽上的滚动阻力更大,因此普通测试风场难以推动它。这些是当前玩法验证参数,保存在 [physics.json](../assets/collections/storybook/physics.json),不作为真实材料测量值。共享运动逻辑见 [physics.gd](../assets/balls/shared/physics.gd)。[同场对照与结果](../playtest/materials/README.md)。
|
||||
原木球、陶瓷球、铁球均为独立资产,球面几何与半径完全相同。原木使用木纹,陶瓷使用浅色釉面与蓝色纹饰;各自具有源文件、制作代码、GLB 和资源索引。质量依次为 60 / 330 / 约 890.08 kg,陶瓷为原木质量的 5.5 倍。三种球共用固体滚动阻力和水体浮沉模型。这些是当前玩法验证参数,保存在 [physics.json](../assets/collections/storybook/physics.json),不作为真实材料测量值。共享运动逻辑见 [physics.gd](../assets/balls/shared/physics.gd)。[同场对照与结果](../playtest/materials/README.md)。
|
||||
|
||||
[source_manifest.json](../assets/collections/storybook/source/snapshot/source_manifest.json) 记录基线来源哈希。首次复制前后均检查源文件稳定性,随后重建只读取副本快照。后续如要接入新的模型优化,应显式刷新这套快照并重新验证,避免在其他 Agent 建模时混入半成品。正式设计文档中的数值同步由原模型优化任务处理,本文件说明的是当前副本的实际资产。
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
|
||||
末端另有一块旋转 90° 的直槽,以其可见实体侧面作为洞后止挡,承接剩余水平速度。早期没有止挡时,重复试跑曾出现越过窄洞口的情况;加入这块现有滑槽后,通过 30 次连续完整双球试跑。它也是可选中、移动和删除的普通直槽,不是隐藏墙体或新实体类型。
|
||||
|
||||
两球间碰撞保持开启,沿用既有摩擦、回弹与滚动阻力;铁球空气阻力系数恢复为 0.47,风力与静止空气阻力均正常计算。入洞按穿过洞口底部截面和真实孔径净空检测,每球只计一次;入洞后移除其碰撞并隐藏,全部入洞才成功,丢球不减少目标数量。
|
||||
两球间碰撞保持开启,采用法向回弹及固体表面滚动阻力。球心向下进入漏斗的喉口并满足孔径净空时,立即计数一次、关闭该球碰撞并隐藏小球。洞底可以直接放在墙壁上。全部小球入洞才成功,丢球不减少目标数量。
|
||||
|
||||
测试场景界面只保留“启动”“重置”和初速度滑块。初速度范围为 0–5 m/s,步长 0.1 m/s,同时作用于两颗铁球,方向沿各自出生槽的下坡切线。启动后锁定滑块,再次实验先点击重置;重置恢复两颗球并保留当前滑块值。`空格` 启动,`T` 重置;右键拖动旋转观察,中键拖动平移,滚轮缩放,`F` 回到全景。
|
||||
|
||||
@@ -71,19 +71,19 @@
|
||||
1. 在素材栏选择 **滑槽 / 小球 / 交互方块 / 非交互方块**。小球是与滑槽并列的独立菜单项,位于菜单第一行右侧;滑槽显示五种积木,选择小球后显示原木球、陶瓷球、铁球三个选项及坐标/放置控件;非交互方块显示“标准墙壁”“锥口球洞”和“水方块”;交互方块显示“定向加速”和“易碎冰块”。
|
||||
2. 默认使用 **放置模式**。点击地面选择 Y=0 的位置;点击已有墙块的顶面会把待放方块底面对齐到墙顶。点击侧面拼接滑槽时,按槽口的实际滚动面自动调整高度:接滑槽对齐两端槽底,接墙壁、冰块或加速块对齐顶面。选好后点击 **放置新方块**。这个按钮始终新增,绝不会移动或替换原方块;旋转预览时重新计算与所点表面的连接高度。
|
||||
3. 方块坐标统一为 **X / 底面 Y / Z**,可见地面与固定网格都是 **Y=0**。例如标准墙第一层底面为 0,第二层为 1,第三层为 2;可以直接输入坐标后连续新增,无需先取消选中。修改已有方块时切换到 **选择 / 移动**,点击目标方块,修改坐标或类型,再点 **应用修改到选中方块**。`R` 在放置模式旋转预览,在选择模式旋转选中方块;删除只作用于明确选中的方块或球。支持撤销和多层占用检查,所有十种现用方块均可放在墙顶。
|
||||
4. 点击菜单中的 **小球** 并选定球种,默认使用 **贴表面点选**:点击地面或墙面会按球的实际半径计算球心,点击滑槽会对准最近的上方槽线。槽口紧邻墙体时会寻找同一槽内最近的无重叠位置,容不下球时会提示重新选点。半透明球预览落点,点击 **+ 放置原木球 / 陶瓷球 / 铁球** 才实际新增。也可以切换 **按 Y 高度点选(悬空)**,先设置球心 Y,再点击场景选择该水平面上的 X/Z;无须先放滑槽。坐标仍可按 0.01 m 精度输入或微调,Y 始终表示球心高度。切回方块菜单只隐藏小球编辑控件和预览,已放置的小球保留。
|
||||
4. 点击菜单中的 **小球** 并选定球种,默认使用 **贴表面点选**:点击方块的任意可见面,球会对准顶面中央。加速块取箭头所在的槽底高度。点击滑槽会选中轨道中点,Y 汇流按点中的分支取中点。中央空间不足时会提示重新选点。点击空地仍按所点位置预览。半透明球预览落点,点击 **+ 放置原木球 / 陶瓷球 / 铁球** 才实际新增。也可以切换 **按 Y 高度点选(悬空)**,先设置球心 Y,再点击场景选择该水平面上的 X/Z;无须先放滑槽。坐标仍可按 0.01 m 精度输入或微调,Y 始终表示球心高度。切回方块菜单只隐藏小球编辑控件和预览,已放置的小球保留。
|
||||
5. 移动已有球时,先从小球列表或场景中点击选球,再点击目标墙面、滑槽或指定高度平面,最后点击 **移动选中小球**。点选新位置只更新预览,不会擅自移动旧球;放置按钮始终新增选定种类的小球。也可直接改坐标后移动,支持撤销、重试和存档。移动或删除方块不会牵动已放置的小球。
|
||||
6. 球洞作为非交互方块,使用与墙块相同的放置、选择、移动、删除、撤销及存档流程。可放置多个球洞,任意球进入任意球洞都只记一次;所有预设球入洞后才算成功。
|
||||
7. 按空格试跑,悬空球会自由下落并与墙体、滑槽或锥面发生真实碰撞;运行和暂停期间锁定编辑。按 `T` 恢复原布局与所有球的球心坐标。
|
||||
8. 在侧栏下部输入名称并保存。文件写入 `designer/drafts/<名称>.json`,覆盖时保留 `.json.bak`。从列表选择名称后点击“载入”;非法对象、非数值坐标或方块重叠会被拒绝,失败不会清空当前关卡。
|
||||
|
||||
自动拼接与玩家教学关共用 [placement.gd](scripts/placement.gd) 的 `align_surfaces()`。高度不再强制取整到 0.5 m,Y 坐标栏按 0.01 m 调整,存档保留实际高度;X/Z 仍对齐网格。例如加速块底面 Y=2、顶面 Y=3,陡坡高端槽底相对底面为 1.18 m,所以接入该端时陡坡底面应为 **Y=1.82**,不能同底放在 Y=2。
|
||||
自动拼接与玩家教学关共用 [placement.gd](scripts/placement.gd) 的 `align_surfaces()`。高度不再强制取整到 0.5 m,Y 坐标栏按 0.01 m 调整,存档保留实际高度;X/Z 仍对齐网格。例如加速块底面 Y=2、出口槽底 Y=3,陡坡高端槽底相对底面为 1.18 m,所以接入该端时陡坡底面应为 **Y=1.82**,不能同底放在 Y=2。加速块在放置预览和单独摆放时就带有 U 形槽与方向箭头。沿箭头接坡时,出口中央和两侧槽沿同时接齐。已保存的布局重新载入即可生效。
|
||||
|
||||
连接只调整待放件的高度,不自动改变坡型、朝向或已有方块。两端无法同时满足时,工坊优先连接所点方块,玩家格位优先匹配更多邻接槽口、再选最接近格位高度的解;仍需选对坡型与朝向。手动输入坐标会退出此次自动面吸附,便于精确编辑。旧草稿保持原坐标,已有错误接缝需要重新点选放置或手动修正。
|
||||
|
||||
选择 **交互方块 → 定向加速**,选位置并点击“放置新方块”;按 `R` 旋转箭头方向。所有方块每次触发均固定增加 **5 m/s**,工坊只显示“固定增速:+5 m/s”,不提供调节入口,运行中也不可更改。
|
||||
|
||||
把任一种小球放在方块顶面并启动,即可在首次真实顶面接触时沿箭头起步。运动中的球先改为箭头方向,再在原水平速率上加上增量:原水平速率 2 m/s 时,触发结果为沿箭头的 7 m/s。保留当时的竖直速度和角速度;之后继续正常物理运动。侧面、底面及悬空经过不触发;每颗球每次接触只触发一次,充分离开再接触可重新触发,暂停/继续不重复增速,重置会清空触发记录。顶面被其他实体覆盖时,不会隔着覆盖物加速。方块仍提供完整实心碰撞,箭头为不参与碰撞的平面标识。
|
||||
把任一种小球放在方块顶面并启动,即可在首次真实顶面接触时沿箭头起步。运动中的球先改为箭头方向,再在原水平速率上加上增量:原水平速率 2 m/s 时,触发结果为沿箭头的 7 m/s。保留当时的竖直速度和角速度;之后继续正常物理运动。侧面、底面及悬空经过不触发;每颗球每次接触只触发一次,充分离开再接触可重新触发,暂停/继续不重复增速,重置会清空触发记录。顶面被其他实体覆盖时,不会隔着覆盖物加速。方块仍提供完整实心碰撞,箭头贴合槽面,仅作方向标识。
|
||||
|
||||
加速方块以 `kind: "directional_boost"`、位置与 `quarter` 保存到实体记录中,支持保存/载入、移动、删除和撤销。速度增量属于固定玩法规则,不写入关卡数据。旧存档中的 `speedGain` 会在载入时忽略,再次保存时移除;任何旧数值均不能覆盖固定的 +5 m/s。不含加速方块的旧关卡不会新增加速效果。
|
||||
|
||||
|
||||
@@ -0,0 +1,215 @@
|
||||
{
|
||||
"assetFamily": "railbound_inspired",
|
||||
"balls": [
|
||||
{
|
||||
"ballTypeId": "iron_ball",
|
||||
"id": "iron_ball_54733144_11",
|
||||
"launchDirection": [
|
||||
1.0,
|
||||
0.0,
|
||||
0.0
|
||||
],
|
||||
"position": [
|
||||
-4.02999973297119,
|
||||
3.3199999332428,
|
||||
-0.0799999982118607
|
||||
]
|
||||
}
|
||||
],
|
||||
"entities": [
|
||||
{
|
||||
"id": "piece_15858038_1",
|
||||
"kind": "wall",
|
||||
"position": [
|
||||
-4.0,
|
||||
0.0,
|
||||
1.0
|
||||
],
|
||||
"quarter": 0
|
||||
},
|
||||
{
|
||||
"id": "piece_18049673_2",
|
||||
"kind": "wall",
|
||||
"position": [
|
||||
-4.0,
|
||||
1.0,
|
||||
1.0
|
||||
],
|
||||
"quarter": 0
|
||||
},
|
||||
{
|
||||
"id": "piece_19796675_3",
|
||||
"kind": "wall",
|
||||
"position": [
|
||||
-4.0,
|
||||
0.0,
|
||||
0.0
|
||||
],
|
||||
"quarter": 0
|
||||
},
|
||||
{
|
||||
"id": "piece_21292261_4",
|
||||
"kind": "wall",
|
||||
"position": [
|
||||
-4.0,
|
||||
1.0,
|
||||
0.0
|
||||
],
|
||||
"quarter": 0
|
||||
},
|
||||
{
|
||||
"id": "piece_23084086_5",
|
||||
"kind": "wall",
|
||||
"position": [
|
||||
-4.0,
|
||||
0.0,
|
||||
-1.0
|
||||
],
|
||||
"quarter": 0
|
||||
},
|
||||
{
|
||||
"id": "piece_24705746_6",
|
||||
"kind": "wall",
|
||||
"position": [
|
||||
-4.0,
|
||||
1.0,
|
||||
-1.0
|
||||
],
|
||||
"quarter": 0
|
||||
},
|
||||
{
|
||||
"id": "piece_26513152_7",
|
||||
"kind": "wall",
|
||||
"position": [
|
||||
-4.0,
|
||||
2.0,
|
||||
-1.0
|
||||
],
|
||||
"quarter": 0
|
||||
},
|
||||
{
|
||||
"id": "piece_28199731_8",
|
||||
"kind": "wall",
|
||||
"position": [
|
||||
-4.0,
|
||||
2.0,
|
||||
1.0
|
||||
],
|
||||
"quarter": 0
|
||||
},
|
||||
{
|
||||
"id": "piece_32033087_9",
|
||||
"kind": "directional_boost",
|
||||
"position": [
|
||||
-4.0,
|
||||
2.0,
|
||||
0.0
|
||||
],
|
||||
"quarter": 0
|
||||
},
|
||||
{
|
||||
"id": "piece_45816500_10",
|
||||
"kind": "goal_hole",
|
||||
"position": [
|
||||
-2.0,
|
||||
1.0,
|
||||
0.0
|
||||
],
|
||||
"quarter": 0
|
||||
}
|
||||
],
|
||||
"pieces": [
|
||||
{
|
||||
"id": "piece_70046522_12",
|
||||
"kind": "straight",
|
||||
"position": [
|
||||
-3.0,
|
||||
2.0,
|
||||
0.0
|
||||
],
|
||||
"quarter": 0
|
||||
},
|
||||
{
|
||||
"id": "piece_77038214_13",
|
||||
"kind": "turn_90",
|
||||
"position": [
|
||||
-2.0,
|
||||
2.0,
|
||||
0.0
|
||||
],
|
||||
"quarter": 0
|
||||
},
|
||||
{
|
||||
"id": "piece_89895659_14",
|
||||
"kind": "gentle",
|
||||
"position": [
|
||||
-2.0,
|
||||
2.0,
|
||||
1.0
|
||||
],
|
||||
"quarter": 3
|
||||
},
|
||||
{
|
||||
"id": "piece_103149940_15",
|
||||
"kind": "turn_90",
|
||||
"position": [
|
||||
-2.0,
|
||||
1.5,
|
||||
2.0
|
||||
],
|
||||
"quarter": 2
|
||||
},
|
||||
{
|
||||
"id": "piece_160941968_17",
|
||||
"kind": "gentle",
|
||||
"position": [
|
||||
-1.0,
|
||||
1.5,
|
||||
2.0
|
||||
],
|
||||
"quarter": 2
|
||||
},
|
||||
{
|
||||
"id": "piece_173516839_18",
|
||||
"kind": "turn_90",
|
||||
"position": [
|
||||
0.0,
|
||||
1.0,
|
||||
2.0
|
||||
],
|
||||
"quarter": 1
|
||||
},
|
||||
{
|
||||
"id": "piece_195109380_19",
|
||||
"kind": "straight",
|
||||
"position": [
|
||||
0.0,
|
||||
1.0,
|
||||
1.0
|
||||
],
|
||||
"quarter": 1
|
||||
},
|
||||
{
|
||||
"id": "piece_215538886_20",
|
||||
"kind": "turn_90",
|
||||
"position": [
|
||||
0.0,
|
||||
1.0,
|
||||
0.0
|
||||
],
|
||||
"quarter": 0
|
||||
},
|
||||
{
|
||||
"id": "piece_242631404_21",
|
||||
"kind": "steep",
|
||||
"position": [
|
||||
-1.0,
|
||||
0.5,
|
||||
0.0
|
||||
],
|
||||
"quarter": 0
|
||||
}
|
||||
],
|
||||
"schemaVersion": 2,
|
||||
"title": "TestLevel1"
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
{
|
||||
"assetFamily": "railbound_inspired",
|
||||
"balls": [
|
||||
{
|
||||
"ballTypeId": "iron_ball",
|
||||
"id": "iron_ball_164994389_10",
|
||||
"launchDirection": [
|
||||
1.0,
|
||||
0.0,
|
||||
0.0
|
||||
],
|
||||
"position": [
|
||||
-4.01999998092651,
|
||||
4.31999969482422,
|
||||
2.95000004768372
|
||||
]
|
||||
}
|
||||
],
|
||||
"entities": [
|
||||
{
|
||||
"id": "piece_99132318_5",
|
||||
"kind": "wall",
|
||||
"position": [
|
||||
-4.0,
|
||||
0.0,
|
||||
3.0
|
||||
],
|
||||
"quarter": 0
|
||||
},
|
||||
{
|
||||
"id": "piece_100675506_6",
|
||||
"kind": "wall",
|
||||
"position": [
|
||||
-4.0,
|
||||
1.0,
|
||||
3.0
|
||||
],
|
||||
"quarter": 0
|
||||
},
|
||||
{
|
||||
"id": "piece_102310872_7",
|
||||
"kind": "wall",
|
||||
"position": [
|
||||
-4.0,
|
||||
2.0,
|
||||
3.0
|
||||
],
|
||||
"quarter": 0
|
||||
},
|
||||
{
|
||||
"id": "piece_108466479_8",
|
||||
"kind": "directional_boost",
|
||||
"position": [
|
||||
-4.0,
|
||||
3.0,
|
||||
3.0
|
||||
],
|
||||
"quarter": 0
|
||||
},
|
||||
{
|
||||
"id": "piece_193286052_13",
|
||||
"kind": "goal_hole",
|
||||
"position": [
|
||||
1.0,
|
||||
1.0,
|
||||
3.0
|
||||
],
|
||||
"quarter": 2
|
||||
}
|
||||
],
|
||||
"pieces": [
|
||||
{
|
||||
"id": "piece_157935970_9",
|
||||
"kind": "gentle",
|
||||
"position": [
|
||||
-3.0,
|
||||
3.3199999332428,
|
||||
3.0
|
||||
],
|
||||
"quarter": 2
|
||||
},
|
||||
{
|
||||
"id": "piece_172677659_11",
|
||||
"kind": "straight",
|
||||
"position": [
|
||||
-2.0,
|
||||
2.8199999332428,
|
||||
3.0
|
||||
],
|
||||
"quarter": 2
|
||||
},
|
||||
{
|
||||
"id": "piece_177149779_12",
|
||||
"kind": "steep",
|
||||
"position": [
|
||||
-1.0,
|
||||
2.3199999332428,
|
||||
3.0
|
||||
],
|
||||
"quarter": 2
|
||||
},
|
||||
{
|
||||
"id": "piece_214624797_14",
|
||||
"kind": "steep",
|
||||
"position": [
|
||||
0.0,
|
||||
1.3199999332428,
|
||||
3.0
|
||||
],
|
||||
"quarter": 2
|
||||
}
|
||||
],
|
||||
"schemaVersion": 2,
|
||||
"title": "my_level"
|
||||
}
|
||||
@@ -17,8 +17,13 @@ func valid_vector(value: Variant) -> bool:
|
||||
if not (n is float or n is int) or not is_finite(float(n)):return false
|
||||
return true
|
||||
|
||||
func overlaps(a: Dictionary,b: Dictionary) -> bool:
|
||||
func overlaps(a: Dictionary,b: Dictionary, saved_layout := false) -> bool:
|
||||
var ab: AABB=lib.record_bounds(a);var bb: AABB=lib.record_bounds(b)
|
||||
# Earlier saves allow another block directly above the 1 m base.
|
||||
# Accept those coordinates on load. New placements reserve the full rim.
|
||||
if saved_layout:
|
||||
if a.kind=="directional_boost":ab.size.y=lib.catalog[a.kind].baseHeight
|
||||
if b.kind=="directional_boost":bb.size.y=lib.catalog[b.kind].baseHeight
|
||||
var extent: Vector3=ab.end.min(bb.end)-ab.position.max(bb.position)
|
||||
return extent.x>.001 and extent.y>.001 and extent.z>.001
|
||||
|
||||
@@ -42,7 +47,7 @@ func validate(data: Variant) -> String:
|
||||
if r.kind!="goal_hole" and (r.position[0]!=round(r.position[0]) or r.position[2]!=round(r.position[2])):return "积木 X / Z 坐标必须对齐网格"
|
||||
var d={"id":r.id,"kind":Chutes.canonical_kind(r.kind),"position":lib.vector(r.position),"quarter":Chutes.canonical_quarter(r.kind,int(r.quarter))}
|
||||
for other in decoded:
|
||||
if overlaps(d,other):return "关卡中有重叠方块"
|
||||
if overlaps(d,other,true):return "关卡中有重叠方块"
|
||||
decoded.append(d);ids.append(r.id)
|
||||
var ball_ids: Array=[]
|
||||
for b in data.balls:
|
||||
|
||||
@@ -51,13 +51,23 @@ func ports(record: Dictionary) -> Array:
|
||||
result.append({"surface":center+basis*local,"normal":basis*outward})
|
||||
return result
|
||||
|
||||
func boost_mouth(record: Dictionary) -> Dictionary:
|
||||
var bounds: AABB = lib.record_bounds(record)
|
||||
var basis := Basis(Vector3.UP, -int(record.quarter)*PI/2)
|
||||
var normal: Vector3 = basis * lib.vector(lib.catalog[record.kind].arrowDirectionGodot)
|
||||
var surface := bounds.get_center() + normal*.5
|
||||
surface.y = record.position.y + lib.catalog[record.kind].baseHeight
|
||||
return {"surface":surface, "normal":normal}
|
||||
|
||||
func connections(candidate: Dictionary,neighbors: Array) -> Array:
|
||||
var matches: Array=[]
|
||||
for own in ports(candidate):
|
||||
var is_boost: bool = candidate.kind == "directional_boost"
|
||||
var own_ports: Array = [boost_mouth(candidate)] if is_boost else ports(candidate)
|
||||
for own in own_ports:
|
||||
for other in neighbors:
|
||||
if other.id==candidate.id:continue
|
||||
var targets: Array=ports(other)
|
||||
if other.kind in ["wall","directional_boost","ice","goal_hole"]:
|
||||
if not is_boost and other.kind in ["wall","directional_boost","ice","goal_hole"]:
|
||||
# Flat solid tops and the goal rim have no groove. Use the edge at
|
||||
# this lane, not the block bottom or the decorative arrow mesh.
|
||||
var bounds: AABB=lib.record_bounds(other)
|
||||
@@ -67,7 +77,8 @@ func connections(candidate: Dictionary,neighbors: Array) -> Array:
|
||||
var lateral:=2 if axis==0 else 0
|
||||
var edge: float=bounds.position[axis] if n[axis]>0 else bounds.end[axis]
|
||||
if absf(p[axis]-edge)<.001 and p[lateral]>bounds.position[lateral]+.001 and p[lateral]<bounds.end[lateral]-.001:
|
||||
targets.append({"surface":Vector3(p.x,bounds.end.y,p.z),"normal":-n})
|
||||
var rolling_y: float = boost_mouth(other).surface.y if other.kind=="directional_boost" else bounds.end.y
|
||||
targets.append({"surface":Vector3(p.x,rolling_y,p.z),"normal":-n})
|
||||
for target in targets:
|
||||
var delta: Vector3=target.surface-own.surface
|
||||
if Vector2(delta.x,delta.z).length()>.001 or own.normal.dot(target.normal)>-.999:continue
|
||||
|
||||
+38
-40
@@ -351,10 +351,10 @@ func refresh_palette() -> void:
|
||||
option.toggle_mode=true
|
||||
option.button_pressed=block_mode!="erase" and (id==ball_kind if category=="balls" else id==kind)
|
||||
if category=="balls":
|
||||
option.tooltip_text={"wood_ball":"原木球:容易被风吹动","ceramic_ball":"陶瓷球:330 kg,在当前水域中下沉","iron_ball":"铁球:最重,普通风下难以推动"}[id]
|
||||
option.tooltip_text={"wood_ball":"原木球:60 kg,在当前水域中浮起","ceramic_ball":"陶瓷球:330 kg,在当前水域中下沉","iron_ball":"铁球:约 890 kg,在当前水域中下沉"}[id]
|
||||
elif id=="water":option.tooltip_text="水体可穿入;泡沫顺流漂动,水速固定 5 m/s。R 顺时针旋转 90°。"
|
||||
elif id=="ice":option.tooltip_text="低摩擦冰面;强撞击会破碎,静置承重不触发。"
|
||||
elif id=="wall":option.tooltip_text="实心墙壁;高摩擦、高滚动阻力,也可搭建河床和河岸。"
|
||||
elif id=="ice":option.tooltip_text="低滚动阻力冰面;强撞击会破碎,静置承重不触发。"
|
||||
elif id=="wall":option.tooltip_text="实心墙壁;高滚动阻力,也可搭建河床和河岸。"
|
||||
palette_box.add_child(option)
|
||||
for id in category_buttons:category_buttons[id].button_pressed=id==category
|
||||
if block_controls!=null:block_controls.visible=category!="balls" and block_mode!="erase"
|
||||
@@ -508,7 +508,7 @@ func add_spawn() -> void:
|
||||
|
||||
func refresh_ball_pick_hint() -> void:
|
||||
if ball_pick_hint==null:return
|
||||
ball_pick_hint.text="点击场景选位置,再点“放置小球”。\n滑槽会自动对准槽内。" if ball_pick_mode.selected==0 else "先设置球心 Y,再点击场景选 X/Z,\n最后点“放置小球”。"
|
||||
ball_pick_hint.text="点方块选中顶面中央,点滑槽选中槽段中点。\n确认预览后点“放置小球”。" if ball_pick_mode.selected==0 else "先设置球心 Y,再点击场景选 X/Z,\n最后点“放置小球”。"
|
||||
|
||||
func ball_position_is_clear(at: Vector3) -> bool:
|
||||
var shape:=SphereShape3D.new();shape.radius=lib.ball_radius(ball_kind)
|
||||
@@ -516,37 +516,39 @@ func ball_position_is_clear(at: Vector3) -> bool:
|
||||
query.transform=Transform3D(Basis.IDENTITY,at);query.collision_mask=1;query.margin=0
|
||||
return get_world_3d().direct_space_state.intersect_shape(query).is_empty()
|
||||
|
||||
func ball_position_on_chute(hit: Dictionary) -> Variant:
|
||||
var node: Node=hit.collider
|
||||
while node!=null and not node.has_meta("record_id"):node=node.get_parent()
|
||||
if node==null:return null
|
||||
var record: Dictionary=records[index_for(node.get_meta("record_id"))]
|
||||
if record.kind not in IDS:return null
|
||||
var transform:=Transform3D(Basis(Vector3.UP,-int(record.quarter)*PI/2),lib.record_center(record))
|
||||
var local: Vector3=transform.affine_inverse()*Vector3(hit.position)
|
||||
var point:=Vector2(local.x,local.z)
|
||||
var paths: Array=lib.catalog[record.kind].upperPaths
|
||||
var distance:=INF;var best_t:=0.0;var best_branch:=0
|
||||
for branch in range(paths.size()):
|
||||
var path: Array=paths[branch]
|
||||
for i in range(path.size()-1):
|
||||
var a:=Vector2(path[i][0],path[i][2]);var b:=Vector2(path[i+1][0],path[i+1][2])
|
||||
var segment:=b-a
|
||||
var ratio:=clampf((point-a).dot(segment)/maxf(segment.length_squared(),.000001),0,1)
|
||||
var d:=point.distance_squared_to(a+segment*ratio)
|
||||
if d<distance:distance=d;best_t=(i+ratio)/(path.size()-1);best_branch=branch
|
||||
var candidate: Vector3=(transform*lib.ball_on_surface(record.kind,best_t,best_branch)).snapped(Vector3.ONE*.01)
|
||||
if ball_position_is_clear(candidate):return candidate
|
||||
# At a seam a nearby wall can obstruct the ideal groove point. Find the
|
||||
# closest clear point on this same asset without moving or altering any block.
|
||||
var best_distance:=INF
|
||||
for branch in range(paths.size()):
|
||||
for i in range(paths[branch].size()):
|
||||
var t: float=float(i)/(paths[branch].size()-1)
|
||||
var alternative: Vector3=(transform*lib.ball_on_surface(record.kind,t,branch)).snapped(Vector3.ONE*.01)
|
||||
var d: float=alternative.distance_squared_to(Vector3(hit.position))
|
||||
if d<best_distance and ball_position_is_clear(alternative):candidate=alternative;best_distance=d
|
||||
return candidate
|
||||
func ball_position_on_block(hit: Dictionary) -> Variant:
|
||||
var node: Node = hit.collider
|
||||
while node != null and not node.has_meta("record_id"):
|
||||
node = node.get_parent()
|
||||
if node == null:
|
||||
return null
|
||||
var record: Dictionary = records[index_for(node.get_meta("record_id"))]
|
||||
var center: Vector3 = lib.record_center(record)
|
||||
if record.kind not in IDS:
|
||||
var bounds: AABB = lib.record_bounds(record)
|
||||
center.y = bounds.end.y
|
||||
if record.kind == "directional_boost":
|
||||
center.y = record.position.y + lib.catalog[record.kind].baseHeight
|
||||
return center + Vector3.UP * (lib.ball_radius(ball_kind) + .018)
|
||||
|
||||
var transform := Transform3D(Basis(Vector3.UP, -int(record.quarter) * PI/2), center)
|
||||
var paths: Array = lib.catalog[record.kind].upperPaths
|
||||
var branch := 0
|
||||
if paths.size() > 1:
|
||||
# The click chooses a Y-merge branch. Its spawn point stays fixed.
|
||||
var local_hit: Vector3 = transform.affine_inverse() * Vector3(hit.position)
|
||||
var point := Vector2(local_hit.x, local_hit.z)
|
||||
var best_distance := INF
|
||||
for path_index in range(paths.size()):
|
||||
var path: Array = paths[path_index]
|
||||
for i in range(path.size() - 1):
|
||||
var a := Vector2(path[i][0], path[i][2])
|
||||
var b := Vector2(path[i+1][0], path[i+1][2])
|
||||
var distance := point.distance_squared_to(Geometry2D.get_closest_point_to_segment(point, a, b))
|
||||
if distance < best_distance:
|
||||
best_distance = distance
|
||||
branch = path_index
|
||||
return transform * lib.ball_on_surface(record.kind, .5, branch)
|
||||
|
||||
func pick_ball_position(origin: Vector3,direction: Vector3,hit: Dictionary) -> void:
|
||||
var candidate: Variant=null
|
||||
@@ -554,11 +556,7 @@ func pick_ball_position(origin: Vector3,direction: Vector3,hit: Dictionary) -> v
|
||||
if ball_pick_mode.selected==1:
|
||||
candidate=Plane(Vector3.UP,ball_cursor.y).intersects_ray(origin,direction)
|
||||
elif not hit.is_empty():
|
||||
candidate=ball_position_on_chute(hit)
|
||||
if candidate==null:
|
||||
var normal: Vector3=hit.normal
|
||||
if normal.length_squared()<.001:return
|
||||
candidate=hit.position+normal.normalized()*(radius+.018)
|
||||
candidate=ball_position_on_block(hit)
|
||||
else:
|
||||
var ground=Plane(Vector3.UP,0).intersects_ray(origin,direction)
|
||||
if ground!=null:candidate=ground+Vector3.UP*(radius+.018)
|
||||
|
||||
Reference in New Issue
Block a user