Files
Diabolo/Demon_v0.19/reviews/infernal_v01/review_tests.gd
T

38 lines
2.9 KiB
GDScript

extends SceneTree
var failures=[]
func _initialize():call_deferred("run")
func check(ok,label):
if not ok and not label in failures:failures.append(label);push_error("INFERNAL REVIEW QA: "+label)
func run():
var max_error=0.0;var max_twist=0.0;var max_wing=0.0;var max_tail=0.0
for scale_y in [1.0,.82]:
var carrier=Node3D.new();root.add_child(carrier)
var actor=preload("res://succubus_actor.gd").new(preload("res://reviews/infernal_v01/infernal_game.glb"));carrier.add_child(actor);actor.scale=Vector3.ONE*scale_y;actor.rotation=Vector3.ZERO
check(actor.clips.has("Idle") and actor.clips.has("Walk") and actor.clips.has("Whip"),"all three transferred animations imported")
actor.gait=preload("res://reviews/infernal_v01/infernal_gait.gd").new();actor.configure(self);actor.set_process(false)
for speed in [1.0,2.5,3.3,5.775]:
for fps in [30,60]:
actor.restore_animation_pose();carrier.position=Vector3.ZERO;actor.rotation=Vector3.ZERO;actor.reset_gait()
for frame in range(fps*3):
var direction=Vector3.BACK if frame<fps else Vector3.RIGHT
carrier.position+=direction*speed/fps;actor.rotation.y=lerp_angle(actor.rotation.y,atan2(direction.x,direction.z),minf(1,10.0/fps));actor._process(1.0/fps)
for f in actor.gait.feet:
max_error=maxf(max_error,actor.gait.point("foot."+f.side).distance_to(f.target))
max_twist=maxf(max_twist,absf(wrapf(f.yaw-actor.global_rotation.y,-PI,PI)))
check(actor.gait.point("foot."+f.side).y>=actor.gait.ground_height(f)-.003,"ankles above floor")
var wi=actor.skeleton.find_bone("Wing.L");var wing=actor.skeleton.get_bone_pose_rotation(wi)
max_wing=maxf(max_wing,wing.angle_to(actor.animation_pose[wi].basis.get_rotation_quaternion()))
for frame in range(fps):actor._process(1.0/fps)
var tail_id=actor.skeleton.find_bone("Tail")
max_tail=maxf(max_tail,actor.skeleton.get_bone_pose_rotation(tail_id).angle_to(actor.animation_pose[tail_id].basis.get_rotation_quaternion()))
for f in actor.gait.feet:check(f.grounded,"stopping settles both shoes")
check(actor.gait.track_width>.065,"separate paths keep wide heels apart")
carrier.queue_free();await process_frame
check(max_tail>.001 and max_tail<.06,"tail moves gently with a fixed root")
check(max_error<.005,"IK reaches both shoes at both scales and four speeds")
check(max_twist<=deg_to_rad(22.01),"ankle heading never twists more than 22 degrees")
check(max_wing>.01 and max_wing<.10,"wings sway gently instead of active flapping")
print("INFERNAL REVIEW METRICS ",JSON.stringify({"max_ik_error":max_error,"max_heading_twist_degrees":rad_to_deg(max_twist),"max_wing_pose_angle":max_wing,"max_tail_pose_angle":max_tail,"failures":failures}))
if failures.is_empty():print("ALL INFERNAL REVIEW TESTS PASSED: heroine/helper scales, four speeds, two frame rates, right-angle turns, stop, reach and ankle heading")
quit(0 if failures.is_empty() else 1)