feat: 更新 IntoHole 的球体、滑槽和环境资产
- 为铁球、陶瓷球和木球制作风格化材质,归档 CC0 原始参考 - 更新方形球洞和实心滑槽,统一 90° 弯槽并兼容旧存档 - 用顺流泡沫表示水流方向,为冰块制作三种交错的裂纹 - 同步 Blender 源资产、Godot 加载、工坊和试玩预览
This commit is contained in:
@@ -0,0 +1,149 @@
|
||||
extends SceneTree
|
||||
|
||||
const Library=preload("res://runtime/asset_library.gd")
|
||||
const Placement=preload("res://designer/scripts/placement.gd")
|
||||
const Types=preload("res://runtime/chute_types.gd")
|
||||
const Output="res://playtest/artifacts/styled/surface_alignment_report.json"
|
||||
var lib=Library.new()
|
||||
var placement=Placement.new(lib)
|
||||
var results:Array=[]
|
||||
var failures:=0
|
||||
var pointer_inside:=false
|
||||
|
||||
func _initialize() -> void:
|
||||
root.mouse_entered.connect(func():pointer_inside=true)
|
||||
root.mouse_exited.connect(func():pointer_inside=false)
|
||||
call_deferred("run")
|
||||
func check(name:String,ok:bool,detail:Dictionary={}) -> void:
|
||||
results.append({"name":name,"passed":ok,"detail":detail})
|
||||
if not ok:failures+=1
|
||||
print(("PASS " if ok else "FAIL ")+name+" "+JSON.stringify(detail))
|
||||
func frames(count:int) -> void:
|
||||
for i in range(count):await physics_frame
|
||||
func click(point:Vector2) -> void:
|
||||
if not pointer_inside:root.notify_mouse_entered();pointer_inside=true
|
||||
for pressed in [true,false]:
|
||||
var event:=InputEventMouseButton.new();event.position=point
|
||||
event.button_index=MOUSE_BUTTON_LEFT;event.pressed=pressed
|
||||
event.button_mask=MOUSE_BUTTON_MASK_LEFT if pressed else 0
|
||||
root.push_input(event,true)
|
||||
await frames(2)
|
||||
func record(kind:String,position:Vector3,quarter:=0,id:="piece") -> Dictionary:
|
||||
return placement.record_at(kind,position,quarter,id)
|
||||
func seam(candidate:Dictionary,support:Dictionary) -> float:
|
||||
var matches:=placement.connections(candidate,[support])
|
||||
var error:=INF
|
||||
for match in matches:error=minf(error,absf(match.offset))
|
||||
return error
|
||||
|
||||
func run() -> void:
|
||||
# Both ends of both slopes, rotated in every direction, touching a flat top.
|
||||
for kind in ["gentle","steep"]:
|
||||
for quarter in range(4):
|
||||
var base:=record(kind,Vector3(0,2,0),quarter)
|
||||
for port in placement.ports(base):
|
||||
var at:Vector3=port.surface+port.normal*.5;at.y=2
|
||||
var support:=record("directional_boost",at,0,"launch")
|
||||
var hit:Vector3=port.surface;hit.y=2.7
|
||||
var bottom:=placement.on_face(support,hit,-port.normal,kind,quarter)
|
||||
var candidate:=record(kind,bottom,quarter)
|
||||
check("%s_q%d_end_%s_flat_join"%[kind,quarter,str(port.normal)],seam(candidate,support)<.00001 and candidate.position.x==0 and candidate.position.z==0,{"bottom_y":bottom.y,"seam_error":seam(candidate,support)})
|
||||
# Catalog-driven seams include straight, bends, slopes and all three Y ports.
|
||||
var pairs:=0;var pair_failures:Array=[]
|
||||
for kind in Types.IDS:
|
||||
for quarter in range(4):
|
||||
var candidate:=record(kind,Vector3(0,3,0),quarter)
|
||||
for own in placement.ports(candidate):
|
||||
for other_kind in Types.IDS:
|
||||
for other_quarter in range(4):
|
||||
var other:=record(other_kind,Vector3.ZERO,other_quarter,"neighbor")
|
||||
for target in placement.ports(other):
|
||||
if own.normal.dot(target.normal)>-.999:continue
|
||||
var support:Dictionary=other.duplicate(true)
|
||||
support.position=own.surface-target.surface+Vector3.UP*.5
|
||||
var solved:Dictionary=placement.align_surfaces(candidate,[support])
|
||||
pairs+=1
|
||||
if seam(solved,support)>.00001 or solved.quarter!=quarter or solved.kind!=kind:
|
||||
pair_failures.append([kind,quarter,other_kind,other_quarter])
|
||||
check("all_chute_ports_and_quarters",pair_failures.is_empty(),{"pairs":pairs,"failures":pair_failures})
|
||||
var launcher:=record("directional_boost",Vector3(-1,2,0),0,"launcher")
|
||||
var slope:=placement.align_surfaces(record("steep",Vector3(0,2,0),2),[launcher])
|
||||
check("screenshot_reproduces_old_018_lip",absf(seam(record("steep",Vector3(0,2,0),2),launcher)-.18)<.00001)
|
||||
check("screenshot_exact_y_182",absf(slope.position.y-1.82)<.00001 and seam(slope,launcher)<.00001)
|
||||
var wall:=record("wall",Vector3(-1,2,0),0,"wall")
|
||||
check("top_click_still_stacks",placement.on_face(wall,Vector3(-1,3,0),Vector3.UP,"steep",2)==Vector3(-1,3,0))
|
||||
check("wall_side_still_bottom_aligned",placement.on_face(wall,Vector3(-.5,2.5,0),Vector3.RIGHT,"wall",0)==Vector3(0,2,0))
|
||||
check("unconnected_orientation_not_auto_rotated",placement.align_surfaces(record("steep",Vector3(0,2,0),1),[launcher]).position==Vector3(0,2,0))
|
||||
var tail:=placement.align_surfaces(record("straight",Vector3(1,2,0),0,"tail"),[slope])
|
||||
check("following_flat_joins_slope_low_end",absf(tail.position.y-1.32)<.00001 and seam(tail,slope)<.00001)
|
||||
check("neighbor_order_does_not_change_height",placement.align_surfaces(slope,[launcher,tail])==placement.align_surfaces(slope,[tail,launcher]))
|
||||
await check_interfaces(launcher)
|
||||
# No direct initial velocity or test-only material overrides: normal iron,
|
||||
# real launcher top contact, real imported solid meshes, all four rotations.
|
||||
for kind in ["gentle","steep"]:
|
||||
for quarter in range(4):await roll_across(kind,quarter)
|
||||
var file:=FileAccess.open(Output,FileAccess.WRITE)
|
||||
file.store_string(JSON.stringify({"engine":Engine.get_version_info().string,"passed":results.size()-failures,"failed":failures,"results":results}," "));file.close()
|
||||
quit(1 if failures else 0)
|
||||
|
||||
func check_interfaces(launcher:Dictionary) -> void:
|
||||
var app=load("res://designer/scenes/workshop.tscn").instantiate();root.add_child(app);await frames(3)
|
||||
app.records=[launcher];app.rebuild();app.select_category("chutes");app.kind="steep";app.quarter=2
|
||||
app.target=Vector3(0,2,0);app.camera_size=8;app.update_camera();await frames(3)
|
||||
await click(app.camera.unproject_position(Vector3(-.499,2.7,0)))
|
||||
check("workshop_mouse_side_pick_aligns",not app.face_pick.is_empty() and absf(app.cursor.y-1.82)<.00001,{"cursor":str(app.cursor)})
|
||||
app.rotate_current();app.rotate_current()
|
||||
check("rotation_recomputes_same_join",app.quarter==0 and absf(app.cursor.y-2.82)<.00001)
|
||||
app.rotate_current();app.rotate_current()
|
||||
await click(app.place_button.get_global_rect().get_center())
|
||||
check("workshop_preview_matches_committed_height",app.records.size()==2 and absf(app.records[-1].position.y-1.82)<.00001)
|
||||
var expected:Dictionary=app.records[-1].duplicate(true)
|
||||
var data:Dictionary=app.encode()
|
||||
check("fractional_height_save_load_valid",app.validate_level(data).is_empty(),{"error":app.validate_level(data)})
|
||||
var path:="res://playtest/artifacts/styled/surface_alignment_saved.json"
|
||||
app.save_level(path);app.load_level(path)
|
||||
check("fractional_height_roundtrip_exact",app.records[app.index_for(expected.id)]==expected)
|
||||
app.select_record(expected.id)
|
||||
check("coordinate_field_keeps_exact_height",absf(app.position_fields[1].value-1.82)<.00001)
|
||||
app.position_fields[1].value=2.17;app.apply_selected()
|
||||
check("manual_coordinates_remain_explicit",absf(app.records[app.index_for(expected.id)].position.y-2.17)<.00001)
|
||||
app.undo();check("undo_preserves_surface_join",absf(app.records[app.index_for(expected.id)].position.y-1.82)<.00001)
|
||||
root.remove_child(app);app.queue_free();await frames(3)
|
||||
app=load("res://playtest/tutorial/scenes/tutorial.tscn").instantiate();root.add_child(app);await frames(3)
|
||||
app.unlocked=4;app.open_lesson(3)
|
||||
app.records=[launcher];app.spawn_specs=[];app.rebuild();app.reset_simulation()
|
||||
app.kind="steep";app.quarter=2;app.refresh_slots()
|
||||
app.target=Vector3(0,2,0);app.camera_size=8;app.update_camera();await frames(3)
|
||||
var screen:Vector2=app.camera.unproject_position(Vector3(0,1.834,0))
|
||||
app.hover_at(screen)
|
||||
var preview:Vector3=app.preview_view.get_child(0).position
|
||||
await click(screen)
|
||||
var index:int=app.records.size()-1 if app.records.size()>1 else -1
|
||||
check("player_grid_click_uses_same_algorithm",index>=0 and app.records[index].position.is_equal_approx(expected.position),{"records":app.records.size(),"status":app.status})
|
||||
check("player_preview_matches_commit",index>=0 and app.records[index].position.is_equal_approx(preview))
|
||||
root.remove_child(app);app.queue_free();await frames(3)
|
||||
|
||||
func roll_across(kind:String,quarter:int) -> void:
|
||||
var basis:=Basis(Vector3.UP,-quarter*PI/2)
|
||||
var direction:Vector3=basis*Vector3.LEFT # local high end to low end
|
||||
var launch:=record("directional_boost",-direction+Vector3.UP*2,(quarter+2)%4,"launch")
|
||||
var slope:=placement.align_surfaces(record(kind,Vector3.UP*2,quarter,"slope"),[launch])
|
||||
var tail:=placement.align_surfaces(record("straight",direction+Vector3.UP*2,quarter,"tail"),[slope])
|
||||
var arena:=Node3D.new();root.add_child(arena)
|
||||
for item in [launch,slope,tail]:
|
||||
var piece:Node3D=lib.create_piece(item.kind,lib.record_center(item),item.quarter)
|
||||
piece.set_meta("record_id",item.id);arena.add_child(piece)
|
||||
var ball=lib.create_ball();ball.freeze=true;arena.add_child(ball)
|
||||
ball.position=launch.position+Vector3.UP*(1+lib.ball_radius()+.02)
|
||||
await frames(3);ball.freeze=false
|
||||
var contacts:Array=[];var crossed:=false;var time:=0.0
|
||||
for tick in range(480):
|
||||
await physics_frame;time=(tick+1)/120.0
|
||||
for collider in ball.get_colliding_bodies():
|
||||
var node:Node=collider
|
||||
while node!=null and not node.has_meta("record_id"):node=node.get_parent()
|
||||
if node!=null and node.get_meta("record_id") not in contacts:contacts.append(node.get_meta("record_id"))
|
||||
if ball.position.dot(direction)>1.3 and "tail" in contacts:crossed=true;break
|
||||
if ball.position.y<0:break
|
||||
check("%s_q%d_real_ball_crosses_both_seams"%[kind,quarter],crossed and "slope" in contacts and ball.boost_controller.events.size()==1,{"contacts":contacts,"time":time,"final":str(ball.position),"slope_y":slope.position.y,"tail_y":tail.position.y,"boosts":ball.boost_controller.events.size()})
|
||||
root.remove_child(arena);arena.queue_free();await frames(3)
|
||||
Reference in New Issue
Block a user