feat: 切换至滚动阻力运行模型并更新资产、编辑器与验证
- 物理规则:现行模型仅保留滚动阻力耗能与恢复系数碰撞,风力、空气阻力、静摩擦、动摩擦不再参与运行;确认三球质量 60/330/约890 kg 及水密度、流阻参数 - 定向加速改为真实顶面接触触发的一次性 +5 m/s 速度事件,模型新增渐进式 U 形导槽出口 - 更新球体、滑槽、水/冰/墙、球洞模型与 storybook 目录、物理、实体配置 - 工坊摆放、编辑器、运行适配与检查脚本同步;删除过时的 baseline 三组检查 - 新增谜题设计参考文档、关卡草稿与本轮实验产物
This commit is contained in:
@@ -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