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
HG14: the body follows the hands down (where the arms fall short of where they are sent, the body goes down by that much more); the knees open for a low thing close in front of the feet, so it comes up between them. On turbo's skin the floor take: thigh skin in the box 18 to 11 mm, the hold 83 to 69 mm off. Still not right
shinyobjectz6df5edbde098
diff --git a/systems/grab/src/grip.rs b/systems/grab/src/grip.rsindex 01f7fd96..a4fb3dde 100644--- a/systems/grab/src/grip.rs+++ b/systems/grab/src/grip.rs@@ -9,7 +9,7 @@ use raea_sys_body::shape::Thing;use crate::hand::{facing, wrist_for};use crate::take::{Part, Release, Take, smooth, span, yaw};-use crate::trunk::{clear, hand_points, roomy, stoop};+use crate::trunk::{clear, hand_points, roomy, spread_for, stoop};/// how far past their ranges an arm's shoulder and elbow are in a pose, degreespub(crate) fn past_range(skel: &Skeleton, arm: [usize; 3], pose: &Pose) -> f32 {@@ -34,7 +34,7 @@ pub(crate) fn lie_at_grab(skel: &Skeleton, base: &dyn Fn(f32) -> Pose, take: &Talevel} else {// the body as it will be at the grab: bent for a low thing, with the give its head and chest need there- let bent = |give: f32| stoop(skel, &own, &w, face, level.0.y, 1.0, give, &take.avoid);+ let bent = |give: f32| stoop(skel, &own, &w, face, level.0.y, 1.0, give, spread_for(skel, &w, &thing), &take.avoid);let (mut lo, mut hi) = (0.0f32, if roomy(skel, &bent(0.0), &take.avoid) { 0.0 } else { 1.0 });for _ in 0..6 {if hi <= 0.0 {diff --git a/systems/grab/src/lib.rs b/systems/grab/src/lib.rsindex 7800117f..8a7fd49d 100644--- a/systems/grab/src/lib.rs+++ b/systems/grab/src/lib.rs@@ -23,4 +23,4 @@ pub use hand::{Grip, Hold, HoldOptions, Touch, curl, find_holds, wrist_for};pub use interact::pick;pub use json::{FIT_ANSWER, FIT_ARGS, HAND_ANSWER, HAND_ARGS, TAKE_ANSWER, TAKE_ARGS, fit_json, hand_json, take_json};pub use take::{Frame, Key, Phase, Release, Take, perform};-pub use trunk::{clear, hand_points, look, own_solids, roomy, stand_for, stoop, torso};+pub use trunk::{clear, hand_points, look, own_solids, roomy, spread_for, stand_for, stoop, torso};diff --git a/systems/grab/src/take.rs b/systems/grab/src/take.rsindex 2312c39a..f1fe142a 100644--- a/systems/grab/src/take.rs+++ b/systems/grab/src/take.rs@@ -10,7 +10,7 @@ use glam::{Quat, Vec3};use raea_sys_body::arm::{ArmOptions, forearm_twist, reach};use crate::grip::{lie_at_grab, past_range, swivel};-use crate::trunk::{clear, hand_points, look, of_the_arm, own_solids, roomy, stoop, torso};+use crate::trunk::{clear, hand_points, look, of_the_arm, own_solids, roomy, spread_for, stoop, torso};use raea_sys_body::limits::clamp_turn;use raea_sys_body::prior::shape;use crate::hand::{Grip, Hold, Touch, curl};@@ -231,7 +231,7 @@ impl Take {// (its skin as the body will be for a thing this low: squatting, its knees sat back from the thing)let mut around = self.avoid.clone();around.push(thing);- let low = skel.fk(&stoop(skel, &base(t), &body, ahead, thing.at.y, 1.0, 0.0, &around));+ let low = skel.fk(&stoop(skel, &base(t), &body, ahead, thing.at.y, 1.0, 0.0, spread_for(skel, &body, &thing), &around));let skin: Vec<Vec3> = skel.skin(&low).into_iter().zip(&skel.surface).filter(|(_, x)| !of_the_arm(&x.part)).map(|(p, _)| p).collect();let stood = thing.at;for _ in 0..10 {@@ -327,6 +327,8 @@ pub fn perform(skel: &Skeleton, base: &dyn Fn(f32) -> Pose, take: &Take, t: f32).collect();// a thing lower than the arms reach: the body bends and squats for it, as far as the hands have gotlet low = holds.iter().map(|h| h.4.0.y).fold(f32::MAX, f32::min);+ // a low thing close in front comes up between the knees: they open for it+ let spread = spread_for(skel, &w0, &thing) * busy;// what the knees keep out of: the scene's solids, and the thing itself while it stands (a squat sits back from a// box on the floor instead of putting its shins through it)let mut around = take.avoid.clone();@@ -335,8 +337,11 @@ pub fn perform(skel: &Skeleton, base: &dyn Fn(f32) -> Pose, take: &Take, t: f32)}// solved with the bend the body has room for: where bending or leaning would put the head or chest into a// solid, less of both and more squat, a step at a time- let solve = |give: f32, frame: &mut Frame| {- let mut pose = stoop(skel, &own, &w0, face, low, busy, give, &around);+ // (`lower`: how much further down the body goes than the hands' height alone asks; `short`, how far the worst+ // wrist ended from where it was sent)+ let attempt = |give: f32, lower: f32, frame: &mut Frame| {+ let mut pose = stoop(skel, &own, &w0, face, low - lower, busy, give, spread, &around);+ let mut short = 0.0f32;frame.miss = 0.0;// a heavy thing: the trunk leans back against it once it is off what it stood onif let (true, Some(waist)) = (take.weight > 0.0, skel.joint("spine_01")) {@@ -393,6 +398,7 @@ pub fn perform(skel: &Skeleton, base: &dyn Fn(f32) -> Pose, take: &Take, t: f32)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;+ short = short.max((skel.fk(&pose).pos[arm[2]] - target).length());let (wrist, by) = clamp_turn(skel, arm[2], pose.turns[arm[2]]);pose.turns[arm[2]] = wrist;frame.limited |= past >= 0.5 || by > 0.5;@@ -434,7 +440,14 @@ pub fn perform(skel: &Skeleton, base: &dyn Fn(f32) -> Pose, take: &Take, t: f32)}// 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)));- look(skel, &pose, thing.at, watching * (1.0 - 0.5 * give))+ (look(skel, &pose, thing.at, watching * (1.0 - 0.5 * give)), short)+ };+ // the body follows the hands: where the arms fall short of where they are sent (a thing low and out in front),+ // the body goes down by that much more, twice over, the same every frame so it stays smooth+ let solve = |give: f32, frame: &mut Frame| {+ let first = attempt(give, 0.0, frame).1 * 1.3;+ let second = attempt(give, first, frame).1 * 1.3;+ attempt(give, first + second, frame).0};let mut pose = solve(0.0, &mut frame);if !roomy(skel, &pose, &take.avoid) {diff --git a/systems/grab/src/trunk.rs b/systems/grab/src/trunk.rsindex b3215063..585f66eb 100644--- a/systems/grab/src/trunk.rs+++ b/systems/grab/src/trunk.rs@@ -19,7 +19,7 @@ const EASY: f32 = 0.88;/// that needs. `own` drawn is `w`; `face` is the level way the body faces. `give` (0 to 1) trades the bend for more/// squat, down to an upright, deep squat at 1: for a body that can't bend forward because something stands there/// (`roomy` says when it can).-pub fn stoop(skel: &Skeleton, own: &Pose, w: &Posed, face: Vec3, low: f32, amount: f32, give: f32, solids: &[Thing]) -> Pose {+pub fn stoop(skel: &Skeleton, own: &Pose, w: &Posed, face: Vec3, low: f32, amount: f32, give: f32, spread: f32, solids: &[Thing]) -> Pose {let (Some(l), Some(r)) = (skel.arm(Side::L), skel.arm(Side::R)) else { return own.clone() };let shoulders = (w.pos[l[0]].y + w.pos[r[0]].y) / 2.0;let arm = skel.offset(l[1]).length() + skel.offset(l[2]).length();@@ -52,7 +52,8 @@ pub fn stoop(skel: &Skeleton, own: &Pose, w: &Posed, face: Vec3, low: f32, amounlet x = s.sx();let leg = [format!("thigh_{x}"), format!("calf_{x}"), format!("foot_{x}")].map(|n| skel.joint(&n));let [Some(a), Some(b), Some(c)] = leg else { continue };- let pole = face + left * (0.25 * s.sign());+ // the knees a little out, as they bend; well out when a low thing sits between the feet (`spread`)+ let pole = face + left * ((0.25 + 1.2 * spread.clamp(0.0, 1.0)) * 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;}pose@@ -167,3 +168,13 @@ pub fn own_solids(skel: &Skeleton, at: &Posed) -> Vec<Thing> {}out}++/// How far the knees open for a thing (0 to 1): all the way for one that is low (under half the hips' height) and+/// close in front of the feet, so it comes up between the knees; none for one higher or farther off.+pub fn spread_for(skel: &Skeleton, own: &Posed, thing: &Thing) -> f32 {+ let ease = |u: f32| { let u = u.clamp(0.0, 1.0); u * u * (3.0 - 2.0 * u) };+ let hips = own.pos[0];+ let floor = ["foot_l", "foot_r"].iter().filter_map(|n| skel.joint(n)).map(|i| own.pos[i].y).fold(hips.y, f32::min);+ let (height, off) = ((thing.at.y - floor) / (hips.y - floor).max(0.1), Vec3::new(thing.at.x - hips.x, 0.0, thing.at.z - hips.z).length());+ ease((0.6 - height) / 0.25) * ease((0.55 - off) / 0.2)+}