feat: 切换至滚动阻力运行模型并更新资产、编辑器与验证
- 物理规则:现行模型仅保留滚动阻力耗能与恢复系数碰撞,风力、空气阻力、静摩擦、动摩擦不再参与运行;确认三球质量 60/330/约890 kg 及水密度、流阻参数 - 定向加速改为真实顶面接触触发的一次性 +5 m/s 速度事件,模型新增渐进式 U 形导槽出口 - 更新球体、滑槽、水/冰/墙、球洞模型与 storybook 目录、物理、实体配置 - 工坊摆放、编辑器、运行适配与检查脚本同步;删除过时的 baseline 三组检查 - 新增谜题设计参考文档、关卡草稿与本轮实验产物
This commit is contained in:
@@ -5,7 +5,6 @@ var results: Array=[]
|
||||
var failures:=0
|
||||
var app
|
||||
var demo
|
||||
var wind_measurements: Dictionary={}
|
||||
|
||||
func _initialize() -> void: call_deferred("run")
|
||||
func check(name: String, ok: bool, detail: Dictionary={}) -> void:
|
||||
@@ -84,7 +83,7 @@ func run() -> void:
|
||||
var correct:=false
|
||||
if not event.is_empty():
|
||||
var before: Vector3=event.before;var after: Vector3=event.after
|
||||
var expected:=direction*(Vector2(before.x,before.z).length()+5)
|
||||
var expected: Vector3=direction*(Vector2(before.x,before.z).length()+app.Booster.SPEED_GAIN)
|
||||
correct=Vector3(after.x,0,after.z).distance_to(expected)<.0001 and is_equal_approx(before.y,after.y)
|
||||
var pos: Vector3=body.position
|
||||
await frames(8)
|
||||
@@ -114,75 +113,20 @@ func run() -> void:
|
||||
for kind in TYPES:
|
||||
check("roll_into_hole_%s_run%d"%[kind,attempt+1],demo.events.any(func(event):return event.ballId==kind),{"events":demo.events})
|
||||
check("roll_three_unique_goal_events_run%d"%(attempt+1),demo.entered.size()==3 and demo.events.size()==3 and demo.lost.is_empty())
|
||||
for with_wind in [false,true]:
|
||||
demo.load_mode("wind");await frames(3)
|
||||
for body in demo.balls:body.wind_velocity=Vector3(20,0,0) if with_wind else Vector3.ZERO
|
||||
var peaks: Array=[0.0,0.0,0.0]
|
||||
demo.toggle_run()
|
||||
for frame in range(600):
|
||||
await physics_frame
|
||||
for i in range(3):peaks[i]=maxf(peaks[i],demo.balls[i].air_force.length())
|
||||
var measurements: Dictionary={}
|
||||
for i in range(3):
|
||||
var body=demo.balls[i]
|
||||
measurements[TYPES[i]]={"dx":body.position.x-demo.spawn_specs[i].position[0],"speed":body.linear_velocity.length(),"peakAirForceN":peaks[i]}
|
||||
wind_measurements["wind" if with_wind else "calm"]=measurements
|
||||
var wood_delta: float=wind_measurements.wind.wood_ball.dx-wind_measurements.calm.wood_ball.dx
|
||||
var ceramic_delta: float=wind_measurements.wind.ceramic_ball.dx-wind_measurements.calm.ceramic_ball.dx
|
||||
var iron_delta: float=wind_measurements.wind.iron_ball.dx-wind_measurements.calm.iron_ball.dx
|
||||
check("wind_clearly_moves_wood",wood_delta>1.0,{"windMinusCalmMeters":wood_delta})
|
||||
check("ceramic_weak_wind_response",ceramic_delta>=-.001 and ceramic_delta<.2 and ceramic_delta<wood_delta*.15,{"windMinusCalmMeters":ceramic_delta})
|
||||
check("iron_receives_nonzero_wind_force",wind_measurements.wind.iron_ball.peakAirForceN>30 and wind_measurements.wind.iron_ball.peakAirForceN<35,
|
||||
{"peakAirForceN":wind_measurements.wind.iron_ball.peakAirForceN})
|
||||
check("heavy_iron_barely_moves_in_reference_wind",absf(iron_delta)<.1 and absf(iron_delta)<wood_delta*.1,
|
||||
{"windMinusCalmMeters":iron_delta,"maxDisplacementMeters":.1})
|
||||
# The same physical iron must move when a sufficiently stronger wind acts.
|
||||
demo.load_mode("wind");await frames(3)
|
||||
for body in demo.balls:body.wind_velocity=Vector3.ZERO
|
||||
var iron=demo.balls[2];iron.wind_velocity=Vector3(100,0,0)
|
||||
var start_x: float=iron.position.x
|
||||
demo.toggle_run();await frames(360)
|
||||
check("strong_wind_can_move_iron",iron.position.x-start_x>.5 and iron.air_force.x>0,
|
||||
{"windSpeedMps":100,"durationSeconds":3,"displacementMeters":iron.position.x-start_x,"airForceN":iron.air_force.x})
|
||||
root.remove_child(demo);demo.queue_free();await process_frame
|
||||
# Isolate mass with two otherwise identical iron bodies in free space.
|
||||
# No drag override: this tests the actual configured iron profile.
|
||||
var heavy=lib.create_ball("iron_ball")
|
||||
var light=lib.create_ball("iron_ball")
|
||||
var calm=lib.create_ball("iron_ball")
|
||||
light.mass=heavy.mass/10
|
||||
light.inertia=Vector3.ONE*(.4*light.mass*light.radius*light.radius)
|
||||
var bodies=[heavy,light,calm]
|
||||
for i in range(3):
|
||||
var body=bodies[i]
|
||||
body.freeze=true;body.gravity_scale=0;root.add_child(body);body.position=Vector3(0,10,i*3)
|
||||
body.wind_velocity=Vector3(20,0,0) if i<2 else Vector3.ZERO
|
||||
await frames(3)
|
||||
check("iron_profile_has_normal_air_drag",heavy.drag_enabled and is_equal_approx(heavy.drag_coefficient,.47) and
|
||||
is_equal_approx(heavy.drag_coefficient,lib.physics.physicsProfiles.wood_game.dragCoefficient))
|
||||
for body in bodies:body.freeze=false
|
||||
calm.linear_velocity=Vector3(2,0,0)
|
||||
await frames(2)
|
||||
var forces: Array=[heavy.air_force.x,light.air_force.x]
|
||||
await frames(118)
|
||||
var k: float=.5*heavy.air_density*heavy.drag_coefficient*PI*heavy.radius*heavy.radius
|
||||
var expected_force: float=k*20*20
|
||||
check("mass_does_not_change_initial_wind_force",forces[0]>0 and absf(forces[0]-expected_force)<.1 and absf(forces[1]-expected_force)<.1,
|
||||
{"heavyLightForceN":forces,"analyticForceN":expected_force})
|
||||
# dv/dt = k/m * (u-v)^2, v(0)=0, integrated for one second.
|
||||
for body in [heavy,light]:
|
||||
var expected_speed: float=20.0-20.0/(1.0+k/body.mass*20.0)
|
||||
check("wind_motion_matches_equation_mass_"+str(body.mass),absf(body.linear_velocity.x-expected_speed)<maxf(.0005,expected_speed*.02),
|
||||
{"massKg":body.mass,"speedMps":body.linear_velocity.x,"analyticSpeedMps":expected_speed})
|
||||
check("lower_mass_increases_wind_acceleration",heavy.linear_velocity.x>.02 and light.linear_velocity.x>heavy.linear_velocity.x*9,
|
||||
{"heavyLightSpeedsMps":[heavy.linear_velocity.x,light.linear_velocity.x]})
|
||||
check("iron_still_air_drag_is_active",calm.air_force.dot(calm.linear_velocity)<0 and calm.linear_velocity.x<1.9999,
|
||||
{"speedMps":calm.linear_velocity.x,"airForceX":calm.air_force.x})
|
||||
for body in bodies:root.remove_child(body);body.queue_free()
|
||||
await process_frame
|
||||
# All production profiles keep their horizontal speed during free flight.
|
||||
for kind in TYPES:
|
||||
var body=lib.create_ball(kind)
|
||||
root.add_child(body);body.position=Vector3(0,40,0)
|
||||
body.linear_velocity=Vector3(4,0,0)
|
||||
await physics_frame
|
||||
var initial:Vector3=body.linear_velocity
|
||||
await frames(120)
|
||||
var delta:Vector3=body.linear_velocity-initial
|
||||
check("gravity_only_in_air_"+kind,absf(delta.x)<.001 and absf(delta.y+9.81)<.02 and body.rolling_force.is_zero_approx() and body.physics_material_override.friction==0.0,{"velocity_change_1s":delta})
|
||||
root.remove_child(body);body.queue_free()
|
||||
var file:=FileAccess.open("res://playtest/artifacts/styled/ball_materials_report.json",FileAccess.WRITE)
|
||||
file.store_string(JSON.stringify({"engine":Engine.get_version_info().string,"physicsHz":120,
|
||||
"windSpeedMps":20,"windDurationSeconds":5,"windComparisons":wind_measurements,
|
||||
"passed":results.size()-failures,"failed":failures,"results":results}," "));file.close()
|
||||
print("BALL_MATERIALS_REPORT ",results.size()-failures," passed, ",failures," failed")
|
||||
quit(1 if failures else 0)
|
||||
|
||||
@@ -41,7 +41,7 @@ func run() -> void:
|
||||
{"id":"wall2","kind":"wall","position":[0,2,0],"quarter":0}],"balls":[]})
|
||||
app.select_category("balls");app.target=Vector3(0,1,0);app.camera_size=9;app.update_camera();await settle()
|
||||
await click_world(app,Vector3(.1,3.001,.1))
|
||||
check("mouse_picks_wall_top",app.ball_cursor.distance_to(Vector3(.1,3.32,.1))<.02 and no_overlap(app,app.ball_cursor),{"position":app.codec.array_from(app.ball_cursor)})
|
||||
check("mouse_picks_wall_top",app.ball_cursor.is_equal_approx(Vector3(0,3.32,0)) and no_overlap(app,app.ball_cursor),{"position":app.codec.array_from(app.ball_cursor)})
|
||||
await click_button(app.add_ball_button);await settle()
|
||||
var original: Vector3=app.balls[0].position
|
||||
await click_world(app,Vector3(2,0,1))
|
||||
@@ -71,11 +71,15 @@ func run() -> void:
|
||||
app.yaw=.72+quarter*PI/2;app.pitch=.95;app.camera_size=7;app.update_camera();await settle()
|
||||
var record: Dictionary=app.records[0]
|
||||
var transform:=Transform3D(Basis(Vector3.UP,-quarter*PI/2),app.lib.record_center(record))
|
||||
var target: Vector3=transform*(app.lib.path_point(kind,.45)-Vector3.UP*float(app.lib.catalog[kind].grooveRadius))
|
||||
await click_world(app,target)
|
||||
var local: Vector3=transform.affine_inverse()*app.ball_cursor
|
||||
var bounds: AABB=app.lib.record_bounds(record).grow(.35)
|
||||
check("chute_pick_"+kind+"_"+str(quarter),bounds.has_point(app.ball_cursor) and no_overlap(app,app.ball_cursor) and local.y>.4,{"position":app.codec.array_from(app.ball_cursor)})
|
||||
var paths: Array = app.lib.catalog[kind].upperPaths
|
||||
for branch in range(paths.size()):
|
||||
var expected: Vector3 = (transform * app.lib.ball_on_surface(kind,.5,branch)).snapped(Vector3.ONE*.01)
|
||||
# Both Y branches have distinct inlets; the outlet is shared.
|
||||
for t in [.12, .35]:
|
||||
var target: Vector3 = transform * (app.lib.path_point(kind,t,branch) - Vector3.UP * float(app.lib.catalog[kind].grooveRadius))
|
||||
app.ball_cursor = Vector3(10,10,10)
|
||||
await click_world(app,target)
|
||||
check("chute_midpoint_%s_%d_%d_%.2f" % [kind,quarter,branch,t],app.ball_cursor.is_equal_approx(expected) and no_overlap(app,app.ball_cursor),{"actual":app.ball_cursor,"expected":expected})
|
||||
# The picked location must remain a normal rigid-body spawn, not attached to the track.
|
||||
if kind=="gentle" and quarter==2:
|
||||
await click_button(app.add_ball_button);await settle()
|
||||
@@ -87,6 +91,16 @@ func run() -> void:
|
||||
await click_world(app,Vector3(3,0,3))
|
||||
check("simulation_blocks_ball_picking",app.ball_cursor.is_equal_approx(pending))
|
||||
app.reset_simulation()
|
||||
for kind in ["directional_boost","water","ice","goal_hole"]:
|
||||
var level := empty_level()
|
||||
level.entities = [{"id":"top","kind":kind,"position":[0,1,0],"quarter":1}]
|
||||
app.apply_data(level)
|
||||
app.select_category("balls")
|
||||
app.pitch=1.1;app.camera_size=7;app.update_camera();await settle()
|
||||
var top_y := 1.0 if kind=="goal_hole" else 2.0
|
||||
app.ball_cursor = Vector3(10,10,10)
|
||||
await click_world(app,Vector3(.42,top_y,.35))
|
||||
check("entity_top_center_"+kind,app.ball_cursor.is_equal_approx(Vector3(0,top_y+.32,0)) and no_overlap(app,app.ball_cursor),{"actual":app.ball_cursor})
|
||||
var seam:=empty_level()
|
||||
seam.pieces=[{"id":"ramp","kind":"steep","position":[0,1,0],"quarter":0}]
|
||||
seam.entities=[{"id":"back_wall","kind":"wall","position":[1,1.5,0],"quarter":0}]
|
||||
|
||||
@@ -44,10 +44,12 @@ func run() -> void:
|
||||
check("interactive_palette_exposes_boost",app.kind=="directional_boost" and app.boost_controls.is_visible_in_tree())
|
||||
check("editor_has_fixed_gain_label_and_no_speed_input",app.boost_controls.find_children("*","SpinBox",true,false).is_empty() and app.boost_controls.find_children("*","Label",true,false).any(func(l):return l.text=="固定增速:+5 m/s"))
|
||||
app.quarter=3;app.cursor=Vector3(2,0,-1);app.refresh_selection()
|
||||
var preview=app.selection
|
||||
check("standalone_preview_has_guide_and_arrow",preview.find_children("ink_boost_arrow_fill*","MeshInstance3D",true,false).size()==1 and preview.find_children("directional_boost*","MeshInstance3D",true,false).any(func(m):return is_equal_approx(m.mesh.get_aabb().size.y,1.32)))
|
||||
await click(app.place_button);await frames(3)
|
||||
var id: String=app.last_placed_id
|
||||
check("gui_places_boost_without_gain_override",app.records.size()==1 and not app.records[0].has("speedGain") and app.records[0].quarter==3)
|
||||
check("boost_retains_solid_wall_bounds",app.lib.record_bounds(app.records[0]).size==Vector3.ONE and app.pieces[0].find_children("*","StaticBody3D",true,false).size()==1)
|
||||
check("boost_includes_permanent_guide_bounds",app.lib.record_bounds(app.records[0]).size.is_equal_approx(Vector3(1,1.32,1)) and app.pieces[0].find_children("*","StaticBody3D",true,false).size()==1)
|
||||
app.select_record(id);app.cursor.y=1;await click(app.apply_button)
|
||||
check("gui_moves_selected_boost",app.records[0].position.y==1)
|
||||
app.undo();check("undo_restores_boost_position",app.records[0].position.y==0)
|
||||
@@ -76,7 +78,7 @@ func run() -> void:
|
||||
await load_case([{"id":"base","kind":"wall","position":[0,0,0],"quarter":0}],[])
|
||||
app.select_category("interactive");app.cursor=Vector3(0,1,0);app.quarter=1;app.refresh_selection()
|
||||
await click(app.place_button);await frames(3)
|
||||
check("boost_stacks_on_wall",app.records.size()==2 and app.lib.record_bounds(app.records[1]).end.y==2)
|
||||
check("boost_stacks_on_wall",app.records.size()==2 and is_equal_approx(app.lib.record_bounds(app.records[1]).end.y,2.32))
|
||||
app.select_category("balls");await frames(3)
|
||||
await click_point(app.camera.unproject_position(Vector3(0,2.001,0)))
|
||||
check("mouse_places_ball_on_boost_top",app.ball_cursor.distance_to(Vector3(0,2.32,0))<.02)
|
||||
|
||||
@@ -145,14 +145,15 @@ func run() -> void:
|
||||
var name: String=kind+("_rolling" if rolling else "_sliding")
|
||||
measurements.braking[name]={"wall":wall,"ice":ice}
|
||||
check("wall_quick_stop_"+name,wall.speedMps<.1 and wall.stopSeconds>0 and wall.stopSeconds<1.2 and wall.distanceM<1.8,wall)
|
||||
check("zero_native_friction_"+name,is_zero_approx(wall.nativeFriction) and is_zero_approx(ice.nativeFriction))
|
||||
check("ice_remains_slippery_"+name,ice.distanceM>wall.distanceM+2 and ice.speedMps>1.5,ice)
|
||||
# Wall side faces also select the same rough contact material.
|
||||
# A loaded wall face brakes tangential travel with zero native friction.
|
||||
for kind in TYPES:
|
||||
await clear();piece("wall",Vector3.ZERO)
|
||||
var body=ball(kind,Vector3(.802,.5,0));body.gravity_scale=0
|
||||
await frames(3);body.freeze=false;body.constant_force=Vector3(-body.mass*9.81,0,0);body.linear_velocity=Vector3(0,0,1)
|
||||
await frames(30)
|
||||
check("wall_side_uses_high_friction_"+kind,body.active_surface=="wall" and body.physics_material_override.friction>=.9 and absf(body.linear_velocity.z)<.6,{"speedZ":body.linear_velocity.z,"surface":body.active_surface})
|
||||
check("loaded_wall_side_uses_only_rolling_resistance_"+kind,body.active_surface=="wall" and is_zero_approx(body.physics_material_override.friction) and absf(body.linear_velocity.z)<.6,{"speedZ":body.linear_velocity.z,"surface":body.active_surface})
|
||||
await clear()
|
||||
# Real editor registry, flow rendering, ray selection, serialization, reset.
|
||||
var app=load("res://designer/scenes/workshop.tscn").instantiate();root.add_child(app);await frames(3)
|
||||
|
||||
@@ -50,7 +50,7 @@ func run() -> void:
|
||||
var launcher:Dictionary=app.records[app.index_for("launcher")]
|
||||
var bounds:AABB=lib.record_bounds(launcher)
|
||||
var start_ball:Vector3=app.balls[0].position
|
||||
check("L%d_ball_on_boost"%(index+1),launcher.kind=="directional_boost" and absf(start_ball.y-bounds.end.y-.32)<.0001 and absf(start_ball.x-bounds.get_center().x)<.5)
|
||||
check("L%d_ball_on_boost"%(index+1),launcher.kind=="directional_boost" and absf(start_ball.y-launcher.position.y-lib.catalog.directional_boost.baseHeight-.32)<.0001 and absf(start_ball.x-bounds.get_center().x)<.5)
|
||||
check("L%d_has_no_support_walls_or_grid_colliders"%(index+1),app.records.filter(func(r):return r.kind=="wall").all(func(r):return r.id=="stop") and app.slots_view.find_children("*","CollisionObject3D",true,false).is_empty() and app.ground_view.find_children("*","CollisionObject3D",true,false).is_empty())
|
||||
# Empty virtual grids cannot catch a sphere or satisfy physics support.
|
||||
var query:=PhysicsShapeQueryParameters3D.new();var shape:=SphereShape3D.new();shape.radius=.12
|
||||
@@ -74,7 +74,7 @@ func run() -> void:
|
||||
var boosts:Array=app.balls[0].boost_controller.events
|
||||
var gain:=0.0
|
||||
if boosts.size()==1:gain=Vector2(boosts[0].after.x,boosts[0].after.z).length()-Vector2(boosts[0].before.x,boosts[0].before.z).length()
|
||||
check("L%d_boosted_floating_run_%d"%[index+1,repeat+1],app.solved and boosts.size()==1 and boosts[0].blockId=="launcher" and absf(gain-5)<.00001 and app.pieces.map(func(p):return p.global_transform)==originals,{"time":app.elapsed,"boosts":boosts.size(),"speed_gain":gain})
|
||||
check("L%d_boosted_floating_run_%d"%[index+1,repeat+1],app.solved and boosts.size()==1 and boosts[0].blockId=="launcher" and absf(gain-app.Booster.SPEED_GAIN)<.00001 and app.pieces.map(func(p):return p.global_transform)==originals,{"time":app.elapsed,"boosts":boosts.size(),"speed_gain":gain})
|
||||
var file:=FileAccess.open("res://playtest/artifacts/tutorial/floating_report.json",FileAccess.WRITE)
|
||||
file.store_string(JSON.stringify({"passed":results.size()-failures,"failed":failures,"engine":Engine.get_version_info().string,"results":results}," "));file.close()
|
||||
quit(1 if failures else 0)
|
||||
|
||||
@@ -12,8 +12,31 @@ func check(name: String, passed: bool, detail: Dictionary = {}) -> void:
|
||||
if not passed:failures += 1
|
||||
print(("PASS " if passed else "FAIL ") + name)
|
||||
|
||||
func check_supported_workshop_goal() -> void:
|
||||
var workshop = load("res://designer/scenes/workshop.tscn").instantiate()
|
||||
root.add_child(workshop)
|
||||
workshop.apply_data({"schemaVersion":2, "pieces":[], "entities":[
|
||||
{"id":"support", "kind":"wall", "position":[2,0,-1], "quarter":0},
|
||||
{"id":"hole", "kind":"goal_hole", "position":[2,2,-1], "quarter":0}
|
||||
], "balls":[{"id":"iron", "ballTypeId":"iron_ball", "position":[2.24,3.2,-1]}]})
|
||||
await physics_frame
|
||||
workshop.toggle_run()
|
||||
for frame in range(360):
|
||||
await physics_frame
|
||||
var ball = workshop.balls[0]
|
||||
check("workshop_scores_inside_supported_goal", workshop.events.size()==1
|
||||
and workshop.events[0].goalId=="hole" and workshop.entered.size()==1
|
||||
and workshop.status.begins_with("全部入洞") and not ball.visible and ball.position.y>1.3,
|
||||
{"events":workshop.events.duplicate(true), "centerY":ball.position.y, "status":workshop.status})
|
||||
root.remove_child(workshop)
|
||||
workshop.queue_free()
|
||||
|
||||
func run() -> void:
|
||||
await check_supported_workshop_goal()
|
||||
var lib = Library.new()
|
||||
check("skimming_above_mouth_does_not_score", not lib.crossed_goal(Vector3(-.3,.4,0),Vector3(.3,.3,0),Vector3.ZERO,.3))
|
||||
check("grazing_throat_edge_does_not_score", not lib.crossed_goal(Vector3(.08,.4,0),Vector3(.08,-1.2,0),Vector3.ZERO,.3))
|
||||
check("rising_from_below_does_not_score", not lib.crossed_goal(Vector3.DOWN*1.2,Vector3.UP,Vector3.ZERO,.3))
|
||||
var arena := Node3D.new();root.add_child(arena)
|
||||
var trials: Array = []
|
||||
var offsets := [Vector2.ZERO,Vector2(.12,0),Vector2(.26,0),Vector2(.36,0),
|
||||
@@ -60,6 +83,10 @@ func run() -> void:
|
||||
app.started=false;app.unlocked=4;app.open_lesson(index)
|
||||
for r in Maps.solution(app.lesson):
|
||||
app.records.append({"id":r.id,"kind":r.kind,"position":app.lib.vector(r.position),"quarter":int(r.quarter)})
|
||||
if index==0:
|
||||
# Exercise a rolling approach with the exit sealed, as in the workshop.
|
||||
var bottom: Vector3 = app.placement.bottom_of(app.goals[0])
|
||||
app.records.append({"id":"support","kind":"wall","position":bottom-Vector3.UP,"quarter":0})
|
||||
app.rebuild();app.reset_simulation()
|
||||
for i in range(3):await physics_frame
|
||||
app.toggle_run()
|
||||
|
||||
@@ -70,6 +70,8 @@ func run() -> void:
|
||||
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 reverse_join := placement.align_surfaces(record("directional_boost",launcher.position+Vector3.UP*.5,0,"launcher"),[slope])
|
||||
check("placing_launcher_second_joins_same_surface",reverse_join.position.is_equal_approx(launcher.position))
|
||||
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))
|
||||
@@ -81,14 +83,18 @@ func run() -> void:
|
||||
# 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)
|
||||
for quarter in range(4):
|
||||
for offset in [0.0,-.05,.05]:await roll_across(kind,quarter,offset)
|
||||
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.records=[launcher];app.rebuild()
|
||||
var meshes:Array=app.pieces[0].find_children("*","MeshInstance3D",true,false)
|
||||
check("standalone_launcher_has_rims_and_arrow",meshes.any(func(m):return not str(m.name).begins_with("ink_") and absf(m.mesh.get_aabb().size.y-1.32)<.001) and meshes.any(func(m):return str(m.name).begins_with("ink_boost_arrow_fill")))
|
||||
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)})
|
||||
@@ -123,27 +129,46 @@ func check_interfaces(launcher:Dictionary) -> void:
|
||||
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:
|
||||
func roll_across(kind:String,quarter:int,offset:float) -> 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 pieces := [launch,slope,tail]
|
||||
var across := direction.cross(Vector3.UP)
|
||||
for item in pieces:
|
||||
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
|
||||
ball.position=launch.position+Vector3.UP*(1+lib.ball_radius()+.02)+across*offset
|
||||
await frames(3)
|
||||
var mouth:Vector3 = launch.position + Vector3.UP + direction*.5
|
||||
if offset==0:
|
||||
# Compare both sides 1 mm from the joint, across floor, curved sides and rims.
|
||||
var max_step := 0.0
|
||||
for z in [-.45,-.32,-.25,-.15,0,.15,.25,.32,.45]:
|
||||
var heights:Array[float]=[]
|
||||
for side in [-1,1]:
|
||||
var sample:Vector3=mouth+across*z+direction*.001*side
|
||||
var ray:=PhysicsRayQueryParameters3D.create(sample+Vector3.UP,sample-Vector3.UP,1)
|
||||
var hit:=arena.get_world_3d().direct_space_state.intersect_ray(ray)
|
||||
heights.append(hit.position.y if not hit.is_empty() else INF)
|
||||
max_step=maxf(max_step,absf(heights[0]-heights[1]))
|
||||
check("%s_q%d_full_mouth" % [kind,quarter],max_step<.003,{"max_step_m":max_step})
|
||||
ball.freeze=false
|
||||
var entry_speed := -1.0
|
||||
var contacts:Array=[];var crossed:=false;var time:=0.0
|
||||
for tick in range(480):
|
||||
await physics_frame;time=(tick+1)/120.0
|
||||
if entry_speed<0 and (ball.position-mouth).dot(direction)>.06:
|
||||
entry_speed=ball.linear_velocity.dot(direction)
|
||||
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()})
|
||||
check("%s_q%d_offset_%.2f_real_ball"%[kind,quarter,offset],entry_speed>lib.Booster.SPEED_GAIN*.5 and crossed and "slope" in contacts and ball.boost_controller.events.size()==1,{"entry_speed_mps":entry_speed,"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)
|
||||
|
||||
@@ -115,7 +115,7 @@ func run() -> void:
|
||||
check("L%d_gui_solution_enters_goal"%(index+1),app.solved and app.entered.size()==1 and app.lost.is_empty() and app.events.size()==1 and app.events[0].goalId=="goal" and required.all(func(id):return app.contact_ids.has(id)),{"time":app.elapsed,"contacts":app.contact_ids.keys(),"events":app.events})
|
||||
if not app.solved:write_report();quit(1);return
|
||||
var boosts:Array=app.balls[0].boost_controller.events
|
||||
check("L%d_real_launch_block_fires_once"%(index+1),boosts.size()==1 and boosts[0].blockId=="launcher" and is_equal_approx(Vector2(boosts[0].after.x,boosts[0].after.z).length()-Vector2(boosts[0].before.x,boosts[0].before.z).length(),5.0))
|
||||
check("L%d_real_launch_block_fires_once"%(index+1),boosts.size()==1 and boosts[0].blockId=="launcher" and is_equal_approx(Vector2(boosts[0].after.x,boosts[0].after.z).length()-Vector2(boosts[0].before.x,boosts[0].before.z).length(),app.Booster.SPEED_GAIN))
|
||||
var accepted:Dictionary={"lesson":index+1,"time":app.elapsed,"layout":layout,"input_events":app.interface_events.duplicate(true),"contacts":app.contact_ids.keys(),"goal_events":app.events.duplicate(true),"trace":app.samples.duplicate(true),"launch_boosts":boosts.map(func(e):return {"blockId":e.blockId,"before":app.codec.array_from(e.before),"after":app.codec.array_from(e.after),"tick":e.tick})}
|
||||
runs.append(accepted);save_json("%02d_accepted.json"%(index+1),accepted)
|
||||
await snapshot("%02d_completed"%(index+1))
|
||||
|
||||
Reference in New Issue
Block a user