nx_rigbench.nx source
↩ module page · 84 lines · 4222 B
1// nx_rigbench.nx -- CLI for THE REAL-CHARACTER REFEREE of the sovereign auto-rig (dcc DC16, rung M2): scores the
2// auto-rig against an ARTIST rig on the same mesh -- skeleton coverage in the artist's own bone units, weight L1 on
3// the artist skeleton, and the artist's own POSE played through the served nx_nxa_play with both weightings judged
4// by md_measure. ALL arithmetic lives in nx_rigbench_lib.nx so nx_rigbench_gate composes it in-process; this file
5// is argv and exit only. Usage: nx_rigbench <rigged.nxa> <workdir> [pose_id] [cells]
6// Exits: 0 ok | 2 usage | 3 abstain (no POSE library) | 4 refuse
7// license_tier: ORIGINAL expect_exit: 0
8import "nx_rigbench_lib.nx"
9import "nx_readcap_lib.nx"
10
11func main(argc: i64, argv: *i64) -> i64 {
12 if argc > 1 { if rb_motion_command(argv[1] as *u8)==1 { return rb_motion_cli(argc,argv) } }
13 if argc < 3 { rbw("usage: nx_rigbench <rigged.nxa> <workdir> [pose_id] [cells]\n" as *u8); return RB_EXIT_USAGE }
14 var pose_id: i64 = RB_POSE_DEFAULT
15 if argc >= 4 { pose_id = rb_atoi(argv[3] as *u8) }
16 var cells: i64 = RB_CELLS_DEFAULT
17 if argc >= 5 { cells = rb_atoi(argv[4] as *u8) }
18 if cells < 1 { cells = RB_CELLS_DEFAULT }
19 let rep: *i64 = sys_mmap(RB_R_WORDS * 8) as *i64
20 let rc: i64 = rb_run(argv[1] as *u8, argv[2] as *u8, pose_id, cells, rep)
21 rb_report(rep)
22 rb_kv("RIGBENCH rc=" as *u8, rc)
23 return rc
24}
25
26func rb_motion_command(s: *u8) -> i64 {
27 let name: *u8="motion" as *u8
28 var i: i64=0
29 while name[i] != (0 as u8) { if s[i] != name[i] { return 0 };i=i+1 }
30 return (s[i] == (0 as u8)) as i64
31}
32func rb_motion_arg(s: *u8) -> i64 {
33 var i: i64=0
34 var n: i64=0
35 if s[0] == (0 as u8) { return 0-1 }
36 let limit: i64=(1 << 62)-1
37 while s[i] != (0 as u8) {
38 let c: i64=s[i] as i64
39 if c < 48 { return 0-1 }
40 if c > 57 { return 0-1 }
41 if n > (limit-(c-48))/10 { return 0-1 }
42 n=n*10+(c-48);i=i+1
43 }
44 return n
45}
46func rb_motion_cli(argc: i64,argv: *i64) -> i64 {
47 if argc != 7 { rbw("usage: nx_rigbench motion <asset.nxa> <time_a_ms> <time_b_ms> <max_joints> <asset_byte_budget>\n" as *u8);return RB_EXIT_USAGE }
48 let ta: i64=rb_motion_arg(argv[3] as *u8)
49 let tb: i64=rb_motion_arg(argv[4] as *u8)
50 let cap: i64=rb_motion_arg(argv[5] as *u8)
51 if ta < 0 { return RB_EXIT_USAGE }
52 if tb <= ta { return RB_EXIT_USAGE }
53 if cap < 1 { return RB_EXIT_USAGE }
54 let byte_budget: i64=rb_motion_arg(argv[6] as *u8)
55 if byte_budget < 1 { return RB_EXIT_USAGE }
56 let readstate: *i64=sys_mmap(3*RBM_BYTES) as *i64
57 let b: *u8=sys_mmap(byte_budget)
58 let flen: i64=rc_read_file_into(argv[2] as *u8,b,byte_budget,readstate)
59 if rc_complete(readstate)==0 {
60 rbw("RIGBENCH-MOTION REFUSED reason=asset-read-envelope state=" as *u8);rbw(rc_state_name(readstate[0]));rbw("\n" as *u8)
61 rb_kv(" asset_byte_budget=" as *u8,byte_budget);rb_kv(" bytes_read=" as *u8,flen);rb_kv(" read_rc=" as *u8,readstate[1])
62 sys_munmap(b,byte_budget);return RB_EXIT_REFUSE
63 }
64 let rep: *i64=sys_mmap(RBM_R_WORDS*RBM_BYTES) as *i64
65 let rc: i64=rb_motion_asset(b,flen,ta,tb,cap,rep)
66 rbw("RIGBENCH-MOTION contract=1 scope=two-authored-palette-samples evaluator=nx_nxa_anim_lib.na_rows root_drift=0 pose_hold=0 scene_visibility=unqualified\n" as *u8)
67 rb_kv(" asset_bytes=" as *u8,flen)
68 rb_kv(" asset_byte_budget=" as *u8,byte_budget)
69 rb_kv(" time_a_ms=" as *u8,ta)
70 rb_kv(" time_b_ms=" as *u8,tb)
71 rb_kv(" max_joints=" as *u8,cap)
72 rb_kv(" joints=" as *u8,rep[RBM_R_JOINTS])
73 rb_kv(" duration_ms=" as *u8,rep[RBM_R_DURATION])
74 rb_kv(" tracked_joints=" as *u8,rep[RBM_R_TRACKED])
75 rb_kv(" changed_joints=" as *u8,rep[RBM_R_CHANGED])
76 rb_kv(" nonidentity_a=" as *u8,rep[RBM_R_NONIDENTITY_A])
77 rb_kv(" nonidentity_b=" as *u8,rep[RBM_R_NONIDENTITY_B])
78 rb_kv(" reason=" as *u8,rep[RBM_R_REASON])
79 rb_kv(" asset_rc=" as *u8,rep[RBM_R_ASSET_RC])
80 rb_kv(" consumer_rc=" as *u8,rep[RBM_R_CONSUMER_RC])
81 rb_kv("RIGBENCH-MOTION rc=" as *u8,rc)
82 sys_munmap(b,byte_budget);sys_munmap(rep as *u8,RBM_R_WORDS*RBM_BYTES);sys_munmap(readstate as *u8,3*RBM_BYTES)
83 return rc
84}