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.
TypeScript 3dagent-skillsai-agentsai-videobevyclaude-codegame-enginegpulinuxmacosmotion-designmotion-graphicsreactrusttypescriptvideo-editingvideo-renderingwgpuwindows
HG19: a take's hands stay out of the table and the body on SOMA. A reach leans the chest, and the second hand's lean carried the first hand 6 cm off its hold with its fingers still shaped for it: every hand but the last is solved again with the trunk left where it is. A travelling hand keeps off solids by its skin as its fingers are that frame. The audit's standing pose hangs the arms clear of the thighs (SOMA's fingers hung 31 mm inside them before any take). Five of six takes: 0 to 2 mm of hand in the thing, none in the scene, 0 to 6 mm in the body's own solids, all five pads of each holding hand on. The scenario filed as HG17 is HG19 (HG17 was taken).
shinyobjectz9586aa968925
diff --git a/docs/hands.feature b/docs/hands.featureindex 597546e3..4d96c256 100644--- a/docs/hands.feature+++ b/docs/hands.feature@@ -452,7 +452,7 @@ Feature: Procedural arms and hands: a character reaches for, takes, holds, carriAnd a throw's wind-up and follow-through scale with it@done- Scenario: HG17. On SOMA's own skin a held thing has no skin of the hand in it+ Scenario: HG19. On SOMA's own skin a held thing has no skin of the hand in it# 11-15, the audit (tools/hands-audit) on SOMA's body: fingers stood 17 to 36 mm inside a held box and cup.# Three causes, each in the system. A joint bent until its own bone met the surface, and carried the bones# past it in (a knuckle 60 degrees onto a box's face, the next two bones 24 and 35 mm inside): it now stops@@ -460,11 +460,19 @@ Feature: Procedural arms and hands: a character reaches for, takes, holds, carri# carried by several joints' weights (the ball of the thumb is half the hand's): it reads it as drawn. And# the ball of the thumb is the palm's: the hand's frame sets the palm's height on it too, and only on skin# the hand mostly carries itself (the web to the thumb stood 13 mm proud). Now, worst over each take: 0 to- # 1 mm in the thing (3 mm passing a cup hand to hand), 4 to 5 pads on, the palm 1 to 6 mm off. Not this:- # fingers 20 to 37 mm into the table on the way to a box, and into the body's own thigh.+ # 1 mm in the thing (3 mm passing a cup hand to hand), 4 to 5 pads on, the palm 1 to 6 mm off.+ # Then the table (fingers 20 to 37 mm into it at a box's grab) and the body's own thighs. A reach leans the+ # chest, and the second hand's lean carried the first hand 6 cm off its hold with its fingers still shaped+ # for the hold: every hand but the last is solved again with the trunk left where it is. A travelling hand is+ # kept off solids by its skin as its fingers are that frame (opened, they go further than at rest). The+ # audit's own standing pose hung SOMA's fingers 31 mm inside the thighs before any take began: it now hangs+ # the arms as near the sides as keeps them out. Five of the six takes now: 0 to 2 mm of hand in the thing,+ # none in the scene, 0 to 6 mm in the body's own solids, every holding hand's five pads on. The sixth (a+ # box from the floor to a table, squatting) still has 8 mm in the box, 20 in the table and 50 in the thighs.Given SOMA's body, its skin samples on the joints that carry themThen through each of the audit's six takes no skin of a hand is more than 3 mm inside the thing it holdsAnd every hand that holds has four pads or more on it, its palm within 6 mm+ And no skin of a hand or forearm is in the scene's solids, nor more than 6 mm in the body's ownRule: Wider, for the character SDKdiff --git a/systems/grab/src/grip.rs b/systems/grab/src/grip.rsindex 5408fecc..137244dc 100644--- a/systems/grab/src/grip.rs+++ b/systems/grab/src/grip.rs@@ -57,7 +57,7 @@ pub(crate) fn lie_at_grab(skel: &Skeleton, base: &dyn Fn(f32) -> Pose, take: &Ta}let lie = |keep: f32| wrist_for(skel, &thing, &hold, Vec3::new(forearm.x, forearm.y * keep, forearm.z).normalize_or(face));match lie(1.0) {- Some(along) => lie(1.0 - smooth((clear(along.0, along.1, &hand_points(skel, hold.side, &rest), &take.avoid) - along.0).length() / 0.03)).unwrap_or(level),+ Some(along) => lie(1.0 - smooth((clear(along.0, along.1, &hand_points(skel, hold.side, &rest, None), &take.avoid) - along.0).length() / 0.03)).unwrap_or(level),None => level,}};diff --git a/systems/grab/src/take.rs b/systems/grab/src/take.rsindex e4361f67..e4e74eb0 100644--- a/systems/grab/src/take.rs+++ b/systems/grab/src/take.rs@@ -348,8 +348,10 @@ pub fn perform(skel: &Skeleton, base: &dyn Fn(f32) -> Pose, take: &Take, t: f32)let back = (0.012 * take.weight).min(0.2) * smooth(span(t, take.grab, take.carried)) * on;pose.turns[waist] = (pose.turns[waist] * Quat::from_rotation_x(-back)).normalize();}- for &(part, into, away, held, level) in &holds {- let hold = part.hold;+ // (each hand, then every hand but the last again with the trunk left where it is: a reach leans the chest, and+ // the second hand's lean carried the first 6 cm off its hold, its fingers still shaped for the hold)+ for (n, &(part, into, away, held, level)) in holds.iter().chain(&holds[..holds.len().saturating_sub(1)]).enumerate() {+ let (hold, again) = (part.hold, n >= holds.len());let (Some(arm), Some(rest)) = (skel.arm(hold.side), hand_rest(skel, hold.side)) else { continue };let normal = held.turn * hold.normal;let (at, turn) = level;@@ -358,8 +360,41 @@ pub fn perform(skel: &Skeleton, base: &dyn Fn(f32) -> Pose, take: &Take, t: f32)let (u, off) = if away > 0.0 { (1.0 - away, (normal * 0.08 + follow) * smooth(away * 4.0)) } else { (into, normal * 0.1 * (1.0 - into)) };let arc = Vec3::Y * 0.06 * (std::f32::consts::PI * u).sin();let end = w0.rot[arm[2]].slerp(turn, smooth(span(u, 0.0, 0.8)));- // (the hand's skin keeps 2 cm off solids while it travels, its fingers opening; on its hold, 4 mm)- let mut skin = hand_points(skel, hold.side, &rest);+ // the hand opens as it comes in, as a hand does before it takes something (the prior's open hand), then+ // the fingers shut over the last moments of the reach, and open again as the hand leaves+ let mut open = pose.turns.clone();+ if !again && shape(skel, &mut open, hold.side, &[OPEN]).is_some() {+ let wide = smooth(span(t, part.start, part.grab - SHUT));+ for (mine, open) in pose.turns.iter_mut().zip(&open) {+ *mine = mine.slerp(*open, wide);+ }+ }+ let close = if again { 0.0 } else { smooth(span(t, part.grab - SHUT, part.grab)) * (1.0 - smooth(span(away, 0.0, 0.5))) };+ match hold.shape {+ // a way of holding brings its hand's shape+ // for the fingers that don't meet the thing; the ones that do are curled onto it as on any hold, so none+ // sinks in+ Some(z) => {+ let (mut fitted, mut shaped) = (pose.turns.clone(), pose.turns.clone());+ let touch = curl(skel, &mut fitted, (at, turn), hold.side, &held, 1.0);+ if let (Some(touch), Some(())) = (touch, shape(skel, &mut shaped, hold.side, &z)) {+ for (n, name) in raea_sys_body::rig::FINGERS.iter().enumerate() {+ for j in skel.finger(name, hold.side).into_iter().flatten().filter(|_| !touch.on[n]) {+ fitted[j] = shaped[j];+ }+ }+ }+ frame.touch[hold.side as usize] = touch;+ for (mine, fitted) in pose.turns.iter_mut().zip(&fitted) {+ *mine = mine.slerp(*fitted, close);+ }+ }+ None if close > 0.0 => frame.touch[hold.side as usize] = curl(skel, &mut pose.turns, (at, turn), hold.side, &held, close),+ None => {}+ }+ // (the hand's skin, its fingers as they are this frame, keeps 2 cm off solids while it travels; on its hold,+ // 4 mm. Read with the fingers at rest, a hand opened for a box on a table put its little finger 34 mm in.)+ let mut skin = hand_points(skel, hold.side, &rest, Some(&skel.fk(&pose)));skin.1 = 0.004 + (skin.1 - 0.004).max(0.0) * (1.0 - u);let target = clear(w0.pos[arm[2]].lerp(at + off, u) + arc, end, &skin, &take.avoid);// elbows out and down, the way arms hang; where that puts the shoulder or the elbow past its range, the@@ -373,7 +408,7 @@ pub fn perform(skel: &Skeleton, base: &dyn Fn(f32) -> Pose, take: &Take, t: f32)// from frame to frame where a first-that-passes choice jumpedlet 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 })?;+ let solved = reach(skel, &pose, hold.side, target, ArmOptions { pole: Some(swung), end: Some(end), soft: 0.02, stiff: if again { 1.0 } else { give } })?;Some(forearm_twist(skel, &solved.pose, hold.side, 1.0))};let (mut sum, mut weights, mut least) = (0.0f32, 0.0f32, f32::MAX);@@ -406,38 +441,6 @@ pub fn perform(skel: &Skeleton, base: &dyn Fn(f32) -> Pose, take: &Take, t: f32)if t >= part.grab && away <= 0.0 {frame.miss = frame.miss.max((skel.fk(&pose).pos[arm[2]] - at).length());}- // the hand opens as it comes in, as a hand does before it takes something (the prior's open hand), then- // the fingers shut over the last moments of the reach, and open again as the hand leaves- let mut open = pose.turns.clone();- if shape(skel, &mut open, hold.side, &[OPEN]).is_some() {- let wide = smooth(span(t, part.start, part.grab - SHUT));- for (mine, open) in pose.turns.iter_mut().zip(&open) {- *mine = mine.slerp(*open, wide);- }- }- let close = smooth(span(t, part.grab - SHUT, part.grab)) * (1.0 - smooth(span(away, 0.0, 0.5)));- match hold.shape {- // a way of holding brings its hand's shape- // for the fingers that don't meet the thing; the ones that do are curled onto it as on any hold, so none- // sinks in- Some(z) => {- let (mut fitted, mut shaped) = (pose.turns.clone(), pose.turns.clone());- let touch = curl(skel, &mut fitted, (at, turn), hold.side, &held, 1.0);- if let (Some(touch), Some(())) = (touch, shape(skel, &mut shaped, hold.side, &z)) {- for (n, name) in raea_sys_body::rig::FINGERS.iter().enumerate() {- for j in skel.finger(name, hold.side).into_iter().flatten().filter(|_| !touch.on[n]) {- fitted[j] = shaped[j];- }- }- }- frame.touch[hold.side as usize] = touch;- for (mine, fitted) in pose.turns.iter_mut().zip(&fitted) {- *mine = mine.slerp(*fitted, close);- }- }- None if close > 0.0 => frame.touch[hold.side as usize] = curl(skel, &mut pose.turns, (at, turn), hold.side, &held, close),- None => {}- }}// the eyes go to the thing as the hands do, and mostly leave it once it is carriedlet watching = busy * (1.0 - 0.7 * smooth(span(t, take.grab, take.carried)));diff --git a/systems/grab/src/trunk.rs b/systems/grab/src/trunk.rsindex e86fad15..d622b2b0 100644--- a/systems/grab/src/trunk.rs+++ b/systems/grab/src/trunk.rs@@ -116,12 +116,14 @@ pub fn clear(wrist: Vec3, turn: Quat, hand: &(Vec<Vec3>, f32), solids: &[Thing])/// The points of a hand that `clear` keeps off solids, from the wrist in the hand's rest axes, and how far off: the/// hand's own skin (palm and fingers as they are at rest, 2 cm off, the room opened fingers need) where the body has samples of it; else the wrist,/// the palm and the fingers' reach, 2 cm off.-pub fn hand_points(skel: &Skeleton, s: Side, rest: &HandRest) -> (Vec<Vec3>, f32) {+pub fn hand_points(skel: &Skeleton, s: Side, rest: &HandRest, drawn: Option<&Posed>) -> (Vec<Vec3>, f32) {let Some(hand) = skel.arm(s).map(|arm| arm[2]) else { return (Vec::new(), 0.0) };let wrist = skel.joints[hand].head;let mut joints = vec![hand];joints.extend(raea_sys_body::rig::FINGERS.iter().filter_map(|f| skel.finger(f, s)).flatten());- let skin: Vec<Vec3> = joints.iter().flat_map(|&j| skel.skin_of(j)).map(|x| x.at - wrist).collect();+ // (as the fingers are in a pose drawn, when one is given: opened for a reach they go further than at rest)+ let place = |x: &raea_sys_body::Sample| drawn.map_or(x.at - wrist, |w| w.rot[hand].inverse() * (skel.carried(x, |j| (w.pos[j], w.rot[j])) - w.pos[hand]));+ let skin: Vec<Vec3> = joints.iter().flat_map(|&j| skel.skin_of(j)).map(place).collect();if skin.is_empty() { (vec![Vec3::ZERO, rest.mid, rest.along * 0.17], 0.02) } else { (skin, 0.02) }}diff --git a/tools/hands-audit/src/main.rs b/tools/hands-audit/src/main.rsindex 41b03bff..3368c719 100644--- a/tools/hands-audit/src/main.rs+++ b/tools/hands-audit/src/main.rs@@ -30,8 +30,12 @@ struct Worst {where_worst: String,}+/// whether a part of the skin (a sample's name) is a hand's+fn hands_part(part: &str) -> bool {+ part == "palm" || ["thumb", "index", "middle", "ring", "pinky"].iter().any(|f| part.starts_with(f))+}+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);@@ -142,15 +146,25 @@ 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();+ // the body's own motion: standing, arms hanging (the rest pose holds them out), as near the sides as keeps the+ // hands' skin out of the thighs (at a fixed 0.12 SOMA's fingers hung 31 mm inside them before any take began)+ let hang = |out: f32| {+ 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(out * 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();+ }}- }+ stand+ };+ let inside = |pose: &Pose| {+ let at = skel.fk(pose);+ let own = own_solids(&skel, &at);+ skel.surface.iter().zip(skel.skin(&at)).filter(|(x, _)| hands_part(&x.part) || x.part == "foreArm").any(|(_, p)| own.iter().any(|s| s.distance(p) < 0.005))+ };+ let stand = (3..=12).map(|k| hang(k as f32 * 0.04)).find(|p| !inside(p)).unwrap_or_else(|| hang(0.48));let base = move |_: f32| stand.clone();let root = base(0.0).root;let top = 0.95;