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 floor take was measured on an impossible set-up (the box on the body's toes, a solid table 17 cm from it); set where a body would stand for it, the hold is within 5 mm (from 69) and no body skin is in the box. The trunk's lean comes on as soon as an arm ends short, and the squat's give is a smooth measure of the room the head and chest have, where a search for the least give jumped: the floor take's worst joint jump 1,706 to 707 degrees a second

shinyobjectza904a8642944
diff --git a/docs/hands.feature b/docs/hands.feature
index 42e7b6c6..b0e3c872 100644
--- a/docs/hands.feature
+++ b/docs/hands.feature
@@ -363,6 +363,14 @@ Feature: Procedural arms and hands: a character reaches for, takes, holds, carri
# fingers on it on the stand-in body; and raea/character's `fetch`, which takes a thing as asked when it
# is in reach and otherwise walks the body to the take's standing place first (walkUp) and puts every
# time of the take off until it arrives. `fetch` is written and type-checked by use only: not rendered.
+ # The floor take's scenario was itself impossible, which several rounds had been fighting: the box stood on
+ # the body's toes (toe skin 11 mm in it at rest) with a solid table 38 cm ahead, 17 cm of floor for a 24 cm
+ # box. Set a forearm's length in front of the feet, the table a top with room under it: the hold is kept
+ # within 5 mm (from 69), no body skin is in the box, the hips are at 45 per cent of standing at the grab.
+ # The trunk's lean now comes on as soon as an arm ends short (it waited for the arm's full length and came
+ # on at once), and the squat's give is a smooth measure of the room the head and chest have (finding the
+ # least give that cleared jumped): that take's worst joint jump 1,706 to 707. Left in it: fingers 20 mm
+ # in the table's top as the hands leave, finger skin 15 mm in the box, hips down to 24 per cent later.
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
diff --git a/systems/body/src/arm.rs b/systems/body/src/arm.rs
index 71e1c7ba..fd467c37 100644
--- a/systems/body/src/arm.rs
+++ b/systems/body/src/arm.rs
@@ -125,7 +125,9 @@ pub fn reach(skel: &Skeleton, p: &Pose, s: Side, target: Vec3, o: ArmOptions) ->
Some((skel.joint(&name)?, *share, *cap * (1.0 - o.stiff.clamp(0.0, 1.0))))
})
.collect();
- if out.miss <= within || !out.out_of_reach {
+ // (whenever the arm ends short, not only past its full length: the arm eases toward straight before that, and a
+ // lean that waited for the full length came on all at once)
+ if out.miss <= within {
return Some(out);
}
let hand = o.end.unwrap_or(skel.fk(p).rot[arm[2]]);
diff --git a/systems/grab/src/grip.rs b/systems/grab/src/grip.rs
index a4fb3dde..5408fecc 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, spread_for, stoop};
+use crate::trunk::{clear, give_for, hand_points, room, spread_for, stoop};
/// how far past their ranges an arm's shoulder and elbow are in a pose, degrees
pub(crate) fn past_range(skel: &Skeleton, arm: [usize; 3], pose: &Pose) -> f32 {
@@ -35,14 +35,7 @@ pub(crate) fn lie_at_grab(skel: &Skeleton, base: &dyn Fn(f32) -> Pose, take: &Ta
} 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, 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 {
- break;
- }
- let mid = (lo + hi) / 2.0;
- if roomy(skel, &bent(mid), &take.avoid) { hi = mid } else { lo = mid }
- }
+ let hi = give_for(room(skel, &bent(0.0), &take.avoid));
let pose = bent(hi);
let probe = reach(skel, &pose, hold.side, thing.world(hold.at) + thing.turn * hold.normal * 0.04, ArmOptions { stiff: hi, ..Default::default() });
let coming = |r: Option<raea_sys_body::arm::IkReport>| {
diff --git a/systems/grab/src/lib.rs b/systems/grab/src/lib.rs
index 1e11d86f..fe5b2650 100644
--- a/systems/grab/src/lib.rs
+++ b/systems/grab/src/lib.rs
@@ -24,4 +24,4 @@ pub use interact::pick;
pub use json::{TAKE_ANSWER, TAKE_ARGS, take_json};
pub use raea_sys_body::json::{FIT_ANSWER, FIT_ARGS, HAND_ANSWER, HAND_ARGS, fit_json, hand_json};
pub use take::{Frame, Key, Phase, Release, Take, perform};
-pub use trunk::{clear, hand_points, look, own_solids, roomy, spread_for, stand_for, stoop, torso};
+pub use trunk::{clear, give_for, hand_points, look, own_solids, room, spread_for, stand_for, stoop, torso};
diff --git a/systems/grab/src/take.rs b/systems/grab/src/take.rs
index 81698a4a..a439aba2 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, spread_for, stoop, torso};
+use crate::trunk::{clear, give_for, hand_points, look, of_the_arm, own_solids, room, spread_for, stoop, torso};
use raea_sys_body::limits::clamp_turn;
use raea_sys_body::prior::shape;
use crate::hand::{Grip, Hold, Touch, curl};
@@ -450,15 +450,12 @@ pub fn perform(skel: &Skeleton, base: &dyn Fn(f32) -> Pose, take: &Take, t: f32)
let second = attempt(give, first, frame).1 * 1.3;
attempt(give, first + second, frame).0
};
+ // bent as far as the head and chest have room for: the nearer a solid they would come bending freely, the more
+ // of the bend is given up for squat
let mut pose = solve(0.0, &mut frame);
- 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(hi, &mut frame);
+ let give = give_for(room(skel, &pose, &take.avoid));
+ if give > 0.0 {
+ pose = solve(give, &mut frame);
}
// a thing held in one hand is where that hand has it: if the wrist was held at its limit, the thing turns with
// the hand it is in (a cup tips less than asked) and nothing of the hand passes into it
diff --git a/systems/grab/src/trunk.rs b/systems/grab/src/trunk.rs
index 585f66eb..8dbe3de1 100644
--- a/systems/grab/src/trunk.rs
+++ b/systems/grab/src/trunk.rs
@@ -69,16 +69,26 @@ pub fn stoop(skel: &Skeleton, own: &Pose, w: &Posed, face: Vec3, low: f32, amoun
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.
-pub fn roomy(skel: &Skeleton, pose: &Pose, solids: &[Thing]) -> bool {
- if solids.is_empty() {
- return true;
- }
+/// How much room the head's top, the neck and the chest have: the least distance from any of them to any solid,
+/// metres (a lot when there are no solids).
+pub fn room(skel: &Skeleton, pose: &Pose, solids: &[Thing]) -> f32 {
let at = skel.fk(pose);
- ["head", "neck_01", "spine_03"].iter().filter_map(|n| skel.joint(n)).all(|i| {
+ let mut least = 10.0f32;
+ for i in ["head", "neck_01", "spine_03"].iter().filter_map(|n| skel.joint(n)) {
let tip = at.pos[i] + at.rot[i] * (skel.joints[i].tail - skel.joints[i].head);
- solids.iter().all(|s| s.distance(at.pos[i]) > 0.09 && s.distance(tip) > 0.09)
- })
+ for solid in solids {
+ least = least.min(solid.distance(at.pos[i])).min(solid.distance(tip));
+ }
+ }
+ least
+}
+
+/// How much of its bend a body gives up for more squat, from the room its head and chest would have bending freely:
+/// none with 20 cm to spare, all of it by the time they would touch. A smooth measure, where finding the least give
+/// that just clears jumped from frame to frame.
+pub fn give_for(room: f32) -> f32 {
+ let u = ((0.2 - room) / 0.2).clamp(0.0, 1.0);
+ u * u * (3.0 - 2.0 * u)
}
/// A wrist's place moved the least that keeps the hand (its wrist, palm and fingers' reach) clear of every solid.
diff --git a/tools/hands-audit/src/main.rs b/tools/hands-audit/src/main.rs
index 192272cd..4241d8cc 100644
--- a/tools/hands-audit/src/main.rs
+++ b/tools/hands-audit/src/main.rs
@@ -157,10 +157,14 @@ fn main() {
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));
+ // a box on the floor where a body would stand for it (a forearm's length in front of the feet), lifted onto a
+ // table that is a top with room under it. (The first audits had the box on the body's toes with a solid table
+ // 38 cm ahead: 17 cm of floor for a 24 cm box, a take no body could make.)
+ let low = Thing::new(Solid::Box { half: Vec3::new(0.16, 0.1, 0.12) }, Vec3::new(0.0, 0.1, 0.44));
+ let slab = Thing::new(Solid::Box { half: Vec3::new(0.6, 0.02, 0.3) }, Vec3::new(0.0, top - 0.02, 0.8));
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) });
+ (t.grab, t.carried, t.avoid) = (1.2, 2.0, vec![slab]);
+ t.release = Some(Release::Put { at: 2.2, down: 2.9, place: Vec3::new(0.0, top + 0.1, 0.62) });
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]) };