extends RefCounted var failures=[] func check(ok,label): if not ok and not label in failures:failures.append(label);push_error("GAIT QA: "+label) func run(g): await g.get_tree().create_timer(.3).timeout g.start_game();g.set_process(false);g.avatar.set_process(false) g.workshop.add_helper();g.workshop.add_helper();g.workshop.add_helper() for h in g.workshop.helpers:h.model.set_process(false) var actors=[g.avatar] for h in g.workshop.helpers:actors.append(h.model) for actor in actors: for speed in [1.0,2.5,3.3,4.375,5.775]: actor.get_parent().position=Vector3.ZERO;actor.rotation=Vector3.ZERO;actor.striking=false;actor.refresh();actor.animator.advance(0);actor.reset_gait() var max_slide=0.0;var max_error=0.0;var max_lift=0.0;var min_contact=10.0;var planted_frames=0 for frame in range(240): var before=[] for f in actor.gait.feet:before.append({"grounded":f.grounded,"anchor":f.anchor,"position":actor.gait.point("foot."+f.side)}) var direction=Vector3.BACK if frame<120 else Vector3.RIGHT actor.get_parent().position+=direction*speed/60 actor.rotation.y=lerp_angle(actor.rotation.y,atan2(direction.x,direction.z),.16) actor._process(1.0/60) for i in range(2): var f=actor.gait.feet[i];var actual=actor.gait.point("foot."+f.side) max_error=maxf(max_error,actual.distance_to(f.target)) max_lift=maxf(max_lift,actual.y-actor.gait.ground_height(f)) min_contact=minf(min_contact,actual.y-actor.gait.ground_height(f)) if f.grounded and before[i].grounded and f.anchor.is_equal_approx(before[i].anchor) and frame>1: max_slide=maxf(max_slide,actual.distance_to(before[i].position));planted_frames+=1 check(max_error<.003,"IK reach "+str(actor.scale.x)+" "+str(speed)) check(max_slide<.003,"stance slip "+str(actor.scale.x)+" "+str(speed)) check(min_contact>-.002,"ground clearance") check(max_lift>.08 and planted_frames>150,"alternating lift/support") print("GAIT_METRICS ",JSON.stringify({"scale":actor.scale.x,"speed":speed,"max_slide":max_slide,"max_target_error":max_error,"max_lift":max_lift,"min_contact":min_contact})) var phase=actor.gait.phase for frame in range(30):actor._process(1.0/60) check(is_equal_approx(actor.gait.phase,phase),"no steps when blocked/stopped") for f in actor.gait.feet:check(f.grounded and absf(actor.gait.point("foot."+f.side).y-actor.gait.ground_height(f))<.04,"stop settles to floor") actor.strike(.45) for frame in range(40):actor._process(1.0/60) check(not actor.striking,"whip returns to idle") g.paused=true;var root=actor.gait.point("root");actor._process(.05);check(actor.gait.point("root").is_equal_approx(root),"pause freezes pose");g.paused=false actor.get_parent().position+=Vector3(10,0,0);actor._process(.016) check(actor.gait.last_speed==0,"teleport resets anchors") print("GAIT_FAILURES: ",failures) if failures.is_empty():print("ALL GAIT TESTS PASSED: heroine and three helpers, five speeds, turns, ground contact, stopping, whip, pause, teleport") g.get_tree().quit(0 if failures.is_empty() else 1)