Skip to content

armgit / raea

Public Imported from GitHub
0

Render Anything Engine: tell your AI what to make. Videos, motion graphics, 3D and games as React and TypeScript, rendered on your own GPU. Rust + Bevy, macOS, Linux and Windows.

HG14: the bar, and the audit that measures against it. tools/hands-audit runs six takes on a clean body's own skin (skeleton.json's surface samples, now read and posed by raea-sys-body) at 60 frames a second and prints the worst of each measure: skin in the thing, the scene and the body, finger pads on, joint speeds and their jumps, limits, bend. The first run showed the takes were not seamless or clip-free (docs/hands.feature HG14 has the numbers). The elbow's swing, the hand's lie on its hold, the squat's give and the knees' set-back are now continuous instead of chosen from steps: body-joint jumps down from about 3,500 to 400-750 degrees a second in five of six takes. Open: a wrist flip, finger jumps, and all the clipping

shinyobjectz03de032a28bf
diff --git a/Cargo.lock b/Cargo.lock
index dc14e5ec..1f31ced0 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -14349,6 +14349,15 @@ dependencies = [
"wgpu",
]
+[[package]]
+name = "raea-hands-audit"
+version = "0.1.0"
+dependencies = [
+ "glam 0.33.12",
+ "raea-sys-body",
+ "raea-sys-grab",
+]
+
[[package]]
name = "raea-io-alpha"
version = "0.1.0"
diff --git a/Cargo.toml b/Cargo.toml
index c3403496..12e54b17 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -189,6 +189,7 @@ members = [
"apps/capcut",
"apps/play",
"tools/sdk-props",
+ "tools/hands-audit",
]
exclude = [
"engine/sandbox/rtools",
diff --git a/docs/hands.feature b/docs/hands.feature
index 66f678c7..307f643a 100644
--- a/docs/hands.feature
+++ b/docs/hands.feature
@@ -308,6 +308,31 @@ Feature: Procedural arms and hands: a character reaches for, takes, holds, carri
# a squat, and the fingers against the body.
Then a thing is carried against the body, never in it
+ Rule: The bar, set by the user 11-14: a complete tool, not scenarios
+
+ Scenario: HG14. Measured on the body's own skin, the takes are seamless and clip nothing
+ # 11-14, after the third pass was posted: "I doubt you solved it it should be a complete tool with fingers,
+ # grips, holds no clipping into somehting. hwo far away do you need to move to get something how smooth is
+ # the rig is we want perfect seemless motion, npc behaivior, not colliding with things not bending down
+ # weirdly we want something that is complete. as well i notice you use teal which loosk broken stubbed
+ # fingers, broken face, weird body type and skelton." He was right. The scenarios above were judged on
+ # wrists and palm centres, on stills, on a drawn character. tools/hands-audit runs six takes on a clean
+ # body (turbo, 1,588 skin samples, every finger segment) at 60 frames a second and prints the worst of
+ # each measure. First run: body joints jumping up to 6,000 degrees a second in one frame; finger skin 14
+ # to 22 mm inside what it holds; the waist 99 mm inside a box drawn back for a throw; fingers 10 to 30 mm
+ # inside the table; a mug held with no finger pad on it; a floor squat with the hips at a fifth of
+ # standing height. Since: the elbow's swing, the hand's lie on its hold, the squat's give and the knees'
+ # set-back are continuous instead of chosen from steps, and body-joint jumps are down to 400 to 750 in
+ # five of six takes. Not fixed: a wrist flip in the mug take (6,100), finger jumps of 1,500 to 4,000 where
+ # a curl flips between touching and not, and every clipping number above.
+ Given the six takes of tools/hands-audit on a clean body with real fingers
+ Then no skin is in the thing beyond a pad's give (2 mm), none in the scene or the body
+ And every finger meant to hold has its pad on the thing, by a grip chosen for the thing's size and shape
+ And no joint's speed changes by more than 300 degrees a second in a frame, fingers included
+ And a low thing is taken with the hips no lower than a real squat and the back as a person holds it
+ And a body that can't reach walks until it can, on any body, and the walk stops without sliding
+ And it is shown on that clean body, in motion, and Shane has watched it
+
Rule: Next, in order
@needs:HG5
diff --git a/systems/body/src/lib.rs b/systems/body/src/lib.rs
index 59e1cb17..7a5f3c7d 100644
--- a/systems/body/src/lib.rs
+++ b/systems/body/src/lib.rs
@@ -17,4 +17,4 @@ pub mod rig;
pub use arm::{ArmOptions, IkReport, forearm_twist, reach, twist_joints, two_bone};
pub use fit::{Mark, fit, marks_of};
pub use limits::{Angles, angles_of, clamp_turn, violations};
-pub use rig::{HandRest, Pose, Posed, Side, Skeleton, hand_rest, mannequin};
+pub use rig::{HandRest, Pose, Posed, Sample, Side, Skeleton, hand_rest, mannequin};
diff --git a/systems/body/src/rig.rs b/systems/body/src/rig.rs
index c6010698..6de853f9 100644
--- a/systems/body/src/rig.rs
+++ b/systems/body/src/rig.rs
@@ -35,9 +35,21 @@ pub struct Joint {
pub tail: Vec3,
}
+/// A point of the skin: the part of the body it is on ("palm", "index3", "thigh"...), the joints that carry it with
+/// their weights, where it is at rest, and the way the skin faces there.
+#[derive(Clone, Debug)]
+pub struct Sample {
+ pub part: String,
+ pub joints: Vec<(usize, f32)>,
+ pub at: Vec3,
+ pub normal: Vec3,
+}
+
#[derive(Clone, Debug)]
pub struct Skeleton {
pub joints: Vec<Joint>,
+ /// samples of the body's skin at rest (skeleton.json's `surface`; none on the stand-in body)
+ pub surface: Vec<Sample>,
index: HashMap<String, usize>,
}
@@ -58,7 +70,7 @@ pub struct Posed {
impl Skeleton {
pub fn new(joints: Vec<Joint>) -> Self {
let index = joints.iter().enumerate().map(|(i, j)| (j.name.clone(), i)).collect();
- Skeleton { joints, index }
+ Skeleton { joints, surface: Vec::new(), index }
}
/// A character's skeleton.json (projects/psx/export.py): `joints` of name, parent (-1 for the root), head, tail.
@@ -83,7 +95,18 @@ impl Skeleton {
let tail = vec3(&j["tail"]).unwrap_or(head);
joints.push(Joint { name: name.to_string(), parent: usize::try_from(parent).ok(), head, tail });
}
- Ok(Skeleton::new(joints))
+ let mut skel = Skeleton::new(joints);
+ // the skin's samples: each an offset from its first joint's head, carried by up to four joints
+ for x in v["surface"].as_array().into_iter().flatten() {
+ let js: Vec<usize> = x["j"].as_array().into_iter().flatten().filter_map(|j| j.as_u64().map(|j| j as usize)).collect();
+ let ws = x["w"].as_array().into_iter().flatten().filter_map(|w| w.as_f64().map(|w| w as f32));
+ let (Some(&first), Some(o)) = (js.first(), vec3(&x["o"])) else { continue };
+ if js.iter().any(|&j| j >= skel.joints.len()) {
+ continue;
+ }
+ skel.surface.push(Sample { part: x["part"].as_str().unwrap_or("").to_string(), joints: js.iter().copied().zip(ws).collect(), at: skel.joints[first].head + o, normal: vec3(&x["n"]).unwrap_or(Vec3::Y) });
+ }
+ Ok(skel)
}
pub fn joint(&self, name: &str) -> Option<usize> {
@@ -137,6 +160,11 @@ impl Skeleton {
Posed { pos, rot }
}
+ /// Where every sample of the skin is in a pose drawn: each carried by its joints, by their weights.
+ pub fn skin(&self, at: &Posed) -> Vec<Vec3> {
+ self.surface.iter().map(|s| s.joints.iter().map(|&(j, w)| (at.pos[j] + at.rot[j] * (s.at - self.joints[j].head)) * w).sum::<Vec3>() / s.joints.iter().map(|j| j.1).sum::<f32>().max(1e-6)).collect()
+ }
+
/// the local turn that gives joint `i` the world turn `world`, against its drawn parent
pub fn local_for(&self, w: &Posed, i: usize, world: Quat) -> Quat {
let pr = self.joints[i].parent.map_or(Quat::IDENTITY, |p| w.rot[p]);
diff --git a/systems/grab/src/take.rs b/systems/grab/src/take.rs
index 1f6bf233..223227db 100644
--- a/systems/grab/src/take.rs
+++ b/systems/grab/src/take.rs
@@ -338,19 +338,15 @@ pub fn perform(skel: &Skeleton, base: &dyn Fn(f32) -> Pose, take: &Take, t: f32)
let w = skel.fk(&r.pose);
(w.pos[arm[2]] - w.pos[arm[1]]).normalize_or(face)
});
- let mut best = (f32::MAX, level);
- for keep in [1.0, 0.5, 0.0] {
- let along = Vec3::new(forearm.x, forearm.y * keep, forearm.z).normalize_or(face);
- let Some(lie) = wrist_for(skel, &held, &hold, along) else { continue };
- let pushed = (clear(lie.0, lie.1, &rest, &take.avoid) - lie.0).length();
- if pushed < best.0 - 1e-4 {
- best = (pushed, lie);
- }
- if pushed < 0.004 {
- break;
+ // by how far the forearm's lie would have to be pushed off a solid (nothing at none, all of it at 3 cm)
+ let lie = |keep: f32| wrist_for(skel, &held, &hold, Vec3::new(forearm.x, forearm.y * keep, forearm.z).normalize_or(face));
+ match lie(1.0) {
+ Some(along) => {
+ let pushed = (clear(along.0, along.1, &rest, &take.avoid) - along.0).length();
+ lie(1.0 - smooth(pushed / 0.03)).unwrap_or(level)
}
+ None => level,
}
- best.1
};
// the wrist's path: from where the body has it, in onto the hold from off the surface and over what is in the
// way; and when letting go, back off the surface and out to where the body has it
@@ -363,30 +359,36 @@ pub fn perform(skel: &Skeleton, base: &dyn Fn(f32) -> Pose, take: &Take, t: f32)
// doesn't (the wrist is then held to its own range, and a frame that had to says so)
let pole = yaw(&w0) * Vec3::new(0.7 * hold.side.sign(), -1.0, -0.4);
let line = (target - skel.fk(&pose).pos[arm[0]]).normalize_or(face);
- let mut best: Option<(f32, Pose)> = None;
- for step in [0.0f32, 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0, 5.0, -5.0, 6.0, -6.0] {
- let swung = Quat::from_axis_angle(line, (step * 10.0).to_radians()) * pole;
- let Some(solved) = reach(skel, &pose, hold.side, target, ArmOptions { pole: Some(swung), end: Some(end), soft: 0.02, stiff: give }) else { break };
- let tried = forearm_twist(skel, &solved.pose, hold.side, 1.0);
- let mut past: f32 = arm[..2].iter().map(|&joint| clamp_turn(skel, joint, tried.turns[joint]).1).sum();
- // a swing that puts the elbow or the forearm into a solid counts as far past
+ // each swing's cost: how far past their ranges the shoulder and elbow are (degrees), and how deep the elbow
+ // and forearm are in the scene's solids and the body's own trunk (a degree a millimetre); the swing taken is
+ // the mean of them all, weighted steeply toward the cheapest and gently toward none, so it moves smoothly
+ // from frame to frame where a first-that-passes choice jumped
+ let solve_at = |swing: f32| {
+ let swung = Quat::from_axis_angle(line, swing.to_radians()) * pole;
+ let solved = reach(skel, &pose, hold.side, target, ArmOptions { pole: Some(swung), end: Some(end), soft: 0.02, stiff: give })?;
+ Some(forearm_twist(skel, &solved.pose, hold.side, 1.0))
+ };
+ let (mut sum, mut weights, mut least) = (0.0f32, 0.0f32, f32::MAX);
+ let mut costs = Vec::with_capacity(13);
+ for step in -6..=6 {
+ let swing = step as f32 * 10.0;
+ let Some(tried) = solve_at(swing) else { continue };
+ let mut cost = past_range(skel, arm, &tried);
let drawn = skel.fk(&tried);
let (elbow, wrist) = (drawn.pos[arm[1]], drawn.pos[arm[2]]);
- if take.avoid.iter().any(|s| s.distance(elbow) < 0.04 || s.distance(elbow.lerp(wrist, 0.5)) < 0.03) {
- past += 30.0;
- }
- // and so does one that puts the elbow into the body's own trunk
- if torso(skel, &drawn).is_some_and(|body| body.distance(elbow) < 0.03) {
- past += 30.0;
- }
- if best.as_ref().is_none_or(|b| past < b.0 - 0.01) {
- best = Some((past, tried));
- }
- if past < 0.5 {
- break;
- }
+ let depth = |solid: &Thing, margin: f32| (margin - solid.distance(elbow)).max(margin - 0.01 - solid.distance(elbow.lerp(wrist, 0.5))).max(0.0);
+ cost += take.avoid.iter().map(|s| depth(s, 0.04)).sum::<f32>() * 1000.0;
+ cost += torso(skel, &drawn).map_or(0.0, |body| depth(&body, 0.03)) * 1000.0;
+ least = least.min(cost);
+ costs.push((swing, cost));
+ }
+ for (swing, cost) in costs {
+ let w = (-(cost - least) / 4.0).exp() * (-(swing / 45.0).powi(2)).exp();
+ sum += swing * w;
+ weights += w;
}
- let Some((past, solved)) = best else { continue };
+ let Some(solved) = solve_at(if weights > 0.0 { sum / weights } else { 0.0 }) else { continue };
+ let past = past_range(skel, arm, &solved);
pose = solved;
let (wrist, by) = clamp_turn(skel, arm[2], pose.turns[arm[2]]);
pose.turns[arm[2]] = wrist;
@@ -423,11 +425,14 @@ pub fn perform(skel: &Skeleton, base: &dyn Fn(f32) -> Pose, take: &Take, t: f32)
look(skel, &pose, thing.at, watching * (1.0 - 0.5 * give))
};
let mut pose = solve(0.0, &mut frame);
- for step in 1..=6 {
- if roomy(skel, &pose, &take.avoid) {
- break;
+ if !roomy(skel, &pose, &take.avoid) {
+ // the least give that keeps the head and chest clear, found by halving, so it changes smoothly
+ let (mut lo, mut hi) = (0.0f32, 1.0f32);
+ for _ in 0..7 {
+ let mid = (lo + hi) / 2.0;
+ if roomy(skel, &solve(mid, &mut frame), &take.avoid) { hi = mid } else { lo = mid }
}
- pose = solve(step as f32 / 6.0, &mut frame);
+ pose = solve(hi, &mut frame);
}
// the first and the last of a hand's part are a blend of the joints, so its arm leaves and ends exactly as the
// body has it: each hand's own arm by its own part, the rest of the body by the hand most on
@@ -454,3 +459,8 @@ pub fn perform(skel: &Skeleton, base: &dyn Fn(f32) -> Pose, take: &Take, t: f32)
frame.pose = pose;
frame
}
+
+/// how far past their ranges an arm's shoulder and elbow are in a pose, degrees
+fn past_range(skel: &Skeleton, arm: [usize; 3], pose: &Pose) -> f32 {
+ arm[..2].iter().map(|&joint| clamp_turn(skel, joint, pose.turns[joint]).1).sum()
+}
diff --git a/systems/grab/src/trunk.rs b/systems/grab/src/trunk.rs
index 9eb969f2..5bacdfec 100644
--- a/systems/grab/src/trunk.rs
+++ b/systems/grab/src/trunk.rs
@@ -34,12 +34,11 @@ pub fn stoop(skel: &Skeleton, own: &Pose, w: &Posed, face: Vec3, low: f32, amoun
let (drop, pitch) = ((drop + 0.45 * pitch * give).min(0.82) * amount, pitch * (1.0 - give) * amount);
let left = Vec3::Y.cross(face);
let knees: Vec<usize> = ["calf_l", "calf_r"].iter().filter_map(|n| skel.joint(n)).collect();
- let mut pose = own.clone();
- // the hips go back a little as the trunk goes forward, as a body keeps its balance; and further back, 4 cm at a
- // time, while a knee would be in a solid (a squat in front of a table sits back from it)
- for back in 0..6 {
- pose = own.clone();
- pose.root = own.root - Vec3::Y * drop - face * (0.12 * pitch + 0.04 * back as f32);
+ // the hips go back a little as the trunk goes forward, as a body keeps its balance; and further back by how near
+ // a knee would be to a solid (a squat in front of a table sits back from it): found once, then by as much
+ let bent = |back: f32| {
+ let mut pose = own.clone();
+ pose.root = own.root - Vec3::Y * drop - face * (0.12 * pitch + back);
pose.turns[0] = (Quat::from_axis_angle(left, pitch * 0.4) * own.turns[0]).normalize();
for name in ["spine_01", "spine_02", "spine_03"] {
if let Some(i) = skel.joint(name) {
@@ -54,12 +53,17 @@ pub fn stoop(skel: &Skeleton, own: &Pose, w: &Posed, face: Vec3, low: f32, amoun
let pole = face + left * (0.25 * s.sign());
pose = two_bone(skel, &pose, [a, b, c], w.pos[c], ArmOptions { pole: Some(pole), end: Some(w.rot[c]), ..Default::default() }).pose;
}
- let at = skel.fk(&pose);
- if knees.iter().all(|&k| solids.iter().all(|s| s.distance(at.pos[k]) > 0.07)) {
- break;
+ pose
+ };
+ let pose = bent(0.0);
+ let at = skel.fk(&pose);
+ let mut near = f32::MAX;
+ for &k in &knees {
+ for solid in solids {
+ near = near.min(solid.distance(at.pos[k]));
}
}
- pose
+ if near < 0.09 { bent(((0.09 - near) * 1.3).min(0.26)) } else { pose }
}
/// Whether the head's top, the neck and the chest are a hand's breadth off every solid.
diff --git a/tools/hands-audit/Cargo.toml b/tools/hands-audit/Cargo.toml
new file mode 100644
index 00000000..9c92103b
--- /dev/null
+++ b/tools/hands-audit/Cargo.toml
@@ -0,0 +1,12 @@
+[package]
+name = "raea-hands-audit"
+version = "0.1.0"
+edition = "2024"
+license = "FSL-1.1-ALv2"
+publish = false
+description = "What a character's hands and body really do in a take (docs/hands.feature), measured on the body's own skin: how deep skin goes into the thing, the scene and the body, how many fingers touch, how fast and how unevenly joints turn"
+
+[dependencies]
+raea-sys-body = { path = "../../systems/body" }
+raea-sys-grab = { path = "../../systems/grab" }
+glam = "0.33"
diff --git a/tools/hands-audit/src/main.rs b/tools/hands-audit/src/main.rs
new file mode 100644
index 00000000..8fcb1675
--- /dev/null
+++ b/tools/hands-audit/src/main.rs
@@ -0,0 +1,168 @@
+//! The hands' audit: a set of takes run on a real body (a character's skeleton.json, with its skin samples) and
+//! measured on that skin, 60 frames a second. Nothing here judges; it prints what happened, worst first within a
+//! take, so a claim that a take is right can be checked against numbers taken from the body itself.
+//! cargo run -p raea-hands-audit -- CHARACTER/skeleton.json
+
+use glam::{Quat, Vec3};
+use raea_sys_body::*;
+use raea_sys_grab::*;
+
+/// one take's worst numbers
+#[derive(Default)]
+struct Worst {
+ /// skin of the hands, and of the rest of the body, inside the thing, metres
+ hand_in_thing: f32,
+ body_in_thing: f32,
+ /// any skin inside the scene's solids; hands and forearms inside the body's own trunk and thighs
+ in_scene: f32,
+ in_self: f32,
+ /// while held: the fewest finger pads on the thing (of the hands holding), and the widest palm gap
+ fewest_pads: usize,
+ palm_gap: f32,
+ miss: f32,
+ /// degrees a second, and the biggest change of that in one frame (a pop), body joints then finger joints
+ speed: [f32; 2],
+ jump: [f32; 2],
+ limited: usize,
+ /// the most the trunk pitched forward, degrees, and the lowest the hips went, as a share of standing
+ pitch: f32,
+ hips: f32,
+ where_worst: String,
+}
+
+fn audit(skel: &Skeleton, name: &str, base: &dyn Fn(f32) -> Pose, take: &Take, until: f32) {
+ let hands_part = |part: &str| part == "palm" || ["thumb", "index", "middle", "ring", "pinky"].iter().any(|f| part.starts_with(f));
+ let arm_part = |part: &str| hands_part(part) || part == "foreArm";
+ let fingers_from = skel.joint("thumb_01_l").unwrap_or(usize::MAX);
+ let chest = skel.joint("spine_03").unwrap_or(0);
+ let stand = skel.fk(&base(0.0)).pos[0].y;
+ let mut w = Worst { fewest_pads: usize::MAX, hips: 1.0, ..Default::default() };
+ let (mut last, mut rate): (Option<Pose>, Vec<f32>) = (None, vec![0.0; skel.joints.len()]);
+ let frames = (until * 60.0) as usize;
+ for i in 0..=frames {
+ let t = i as f32 / 60.0;
+ let f = perform(skel, base, take, t);
+ let at = skel.fk(&f.pose);
+ let skin = skel.skin(&at);
+ let own = own_solids(skel, &at);
+ let held = matches!(f.phase, Phase::Lift | Phase::Carry | Phase::Release);
+ let (mut pads, mut gap) = (0usize, f32::MAX);
+ let note = |value: f32, slot: &mut f32, what: &str, w_where: &mut String| {
+ if value > *slot {
+ *slot = value;
+ if value > 0.005 {
+ *w_where = format!("{what} at {t:.2} s");
+ }
+ }
+ };
+ let mut touching = std::collections::HashSet::new();
+ for (sample, p) in skel.surface.iter().zip(&skin) {
+ let d = f.thing.distance(*p);
+ if f.phase != Phase::After {
+ if hands_part(&sample.part) {
+ note(-d, &mut w.hand_in_thing, &format!("{} in the thing", sample.part), &mut w.where_worst);
+ } else {
+ note(-d, &mut w.body_in_thing, &format!("{} in the thing", sample.part), &mut w.where_worst);
+ }
+ }
+ for solid in &take.avoid {
+ note(-solid.distance(*p), &mut w.in_scene, &format!("{} in the scene", sample.part), &mut w.where_worst);
+ }
+ if arm_part(&sample.part) {
+ for solid in &own {
+ note(-solid.distance(*p), &mut w.in_self, &format!("{} in the body", sample.part), &mut w.where_worst);
+ }
+ }
+ if held && d < 0.006 && sample.part.ends_with('3') {
+ touching.insert((sample.part.clone(), sample.joints[0].0));
+ }
+ if held && sample.part == "palm" {
+ gap = gap.min(d);
+ }
+ }
+ pads += touching.len();
+ if held && t >= take.grab + 0.05 {
+ w.fewest_pads = w.fewest_pads.min(pads);
+ w.palm_gap = w.palm_gap.max(gap);
+ w.miss = w.miss.max(f.miss);
+ }
+ w.limited += f.limited as usize;
+ let up = (at.pos[chest] - at.pos[0]).normalize();
+ w.pitch = w.pitch.max(up.angle_between(Vec3::Y).to_degrees());
+ w.hips = w.hips.min(at.pos[0].y / stand);
+ if let Some(before) = &last {
+ for (j, (a, b)) in f.pose.turns.iter().zip(&before.turns).enumerate() {
+ let speed = a.angle_between(*b).to_degrees() * 60.0;
+ let k = (j >= fingers_from) as usize;
+ w.speed[k] = w.speed[k].max(speed);
+ if i > 1 {
+ if (speed - rate[j]).abs() > 600.0 && std::env::var("POPS").is_ok() {
+ eprintln!(" pop {name}: {} at {t:.3} s: {:.0} to {speed:.0} deg/s ({:?})", skel.joints[j].name, rate[j], f.phase);
+ }
+ w.jump[k] = w.jump[k].max((speed - rate[j]).abs());
+ }
+ rate[j] = speed;
+ }
+ }
+ last = Some(f.pose);
+ }
+ println!(
+ "{name:<22} skin in thing: hand {:>4.0} mm, body {:>4.0} mm | in scene {:>4.0} mm | in self {:>4.0} mm | pads on {:>2}, palm gap {:>3.0} mm, hold off {:>3.0} mm | body {:>4.0} deg/s (jump {:>4.0}), fingers {:>4.0} (jump {:>4.0}) | limited {:>3} frames | pitch {:>2.0} deg, hips {:>3.0}% | {}",
+ w.hand_in_thing * 1000.0, w.body_in_thing * 1000.0, w.in_scene * 1000.0, w.in_self * 1000.0,
+ if w.fewest_pads == usize::MAX { 0 } else { w.fewest_pads }, w.palm_gap.min(9.99) * 1000.0, w.miss * 1000.0,
+ w.speed[0], w.jump[0], w.speed[1], w.jump[1], w.limited, w.pitch, w.hips * 100.0, w.where_worst
+ );
+}
+
+fn main() {
+ let path = std::env::args().nth(1).expect("a character's skeleton.json");
+ let skel = Skeleton::from_json(&std::fs::read_to_string(&path).expect("the skeleton read")).expect("a skeleton");
+ println!("{} joints, {} skin samples; every number is the worst over the take, 60 frames a second", skel.joints.len(), skel.surface.len());
+ // the body's own motion: standing, arms hanging (the rest pose holds them out)
+ let mut stand = skel.rest();
+ for side in Side::BOTH {
+ if let Some([upper, fore, _]) = skel.arm(side) {
+ let down = |i: usize, to: Vec3| Quat::from_rotation_arc((skel.joints[i].tail - skel.joints[i].head).normalize(), to.normalize());
+ stand.turns[upper] = down(upper, Vec3::new(0.12 * side.sign(), -1.0, 0.0));
+ stand.turns[fore] = (stand.turns[upper].inverse() * down(fore, Vec3::new(0.05 * side.sign(), -1.0, 0.12))).normalize();
+ }
+ }
+ let base = move |_: f32| stand.clone();
+ let root = base(0.0).root;
+ let top = 0.95;
+ let table = Thing::new(Solid::Box { half: Vec3::new(0.6, top / 2.0, 0.34) }, Vec3::new(0.0, top / 2.0, 0.72));
+ let found = |thing: &Thing| find_holds(thing, root, HoldOptions::default());
+
+ let crate_ = Thing::new(Solid::Box { half: Vec3::new(0.16, 0.1, 0.12) }, Vec3::new(0.0, top + 0.1, 0.5));
+ let mut t = Take::new(crate_, found(&crate_), 0.4);
+ t.avoid = vec![table];
+ t.release = Some(Release::Throw { at: 2.3, velocity: Vec3::new(0.0, 1.6, 2.6), floor: 0.0 });
+ audit(&skel, "box, taken and thrown", &base, &t, 3.2);
+
+ let cup = Thing::new(Solid::Cylinder { half: 0.05, r: 0.035 }, Vec3::new(-0.2, top + 0.05, 0.46));
+ let mut t = Take::new(cup, found(&cup), 0.4);
+ t.avoid = vec![table];
+ t.release = Some(Release::Put { at: 1.9, down: 2.5, place: Vec3::new(0.02, top + 0.05, 0.48) });
+ audit(&skel, "cup, moved", &base, &t, 3.3);
+
+ let low = Thing::new(Solid::Box { half: Vec3::new(0.16, 0.1, 0.12) }, Vec3::new(0.0, 0.1, 0.2));
+ let mut t = Take::new(low, found(&low), 0.4);
+ (t.grab, t.carried, t.avoid) = (1.2, 2.0, vec![table]);
+ t.release = Some(Release::Put { at: 2.2, down: 2.9, place: Vec3::new(0.0, top + 0.1, 0.52) });
+ audit(&skel, "box, floor to table", &base, &t, 3.6);
+
+ let hold = Hold { side: Side::R, at: Vec3::new(-0.035, 0.0, 0.0), normal: Vec3::NEG_X, along: None, shape: Some([-1.2, 0.0, 0.0]) };
+ let mut t = Take::new(cup, Grip::One(hold), 0.3);
+ (t.grab, t.carried, t.avoid) = (0.9, 1.4, vec![table]);
+ t.path = vec![Key { t: 2.0, carry: Vec3::new(-0.02, 0.36, 0.24), tilt: Quat::from_rotation_x(-0.5) }];
+ t.release = Some(Release::Put { at: 2.4, down: 3.1, place: cup.at });
+ audit(&skel, "mug, drunk from", &base, &t, 3.8);
+
+ let mut t = Take::new(cup, found(&cup), 0.3).passing(2.0);
+ t.avoid = vec![table];
+ audit(&skel, "cup, hand to hand", &base, &t, 3.5);
+
+ let mut t = Take::new(crate_, found(&crate_), 0.4).weighing(14.0);
+ t.avoid = vec![table];
+ audit(&skel, "box, 14 kg", &base, &t, 3.5);
+}
diff --git a/tools/layers.toml b/tools/layers.toml
index 615b60f5..d5bf6042 100644
--- a/tools/layers.toml
+++ b/tools/layers.toml
@@ -203,6 +203,7 @@ conformance-fake = "tools"
rtools = "tools"
skillcheck = "tools"
seetool = "tools"
+raea-hands-audit = "tools"
# systems that hold only a facility another system may build on (docs/overhaul.md: the mixer graph, ONNX sessions,
# Vision requests, K kernels on the GPU)