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 hold's finger direction uses the maths library's own projection (no copied helper)

shinyobjectz4a0dacc29bd1
diff --git a/systems/grab/src/hand.rs b/systems/grab/src/hand.rs
index aa946b89..547fa5f8 100644
--- a/systems/grab/src/hand.rs
+++ b/systems/grab/src/hand.rs
@@ -93,9 +93,8 @@ pub fn wrist_for(skel: &Skeleton, thing: &Thing, hold: &Hold, facing: Vec3) -> O
// the fingers point the way asked, as near as the surface lets them. An asking nearly straight into the surface
// says little, and less the straighter it is: there the fingers turn toward upright (or, on a level surface,
// toward the holder's left), by as much as the asking falls short, so the way they point never flips
- let flat = |v: Vec3| v - n * v.dot(n);
- let (asked, up) = (flat(facing), flat(Vec3::Y));
- let spare = if up.length() > 0.3 { up.normalize() } else { flat(Vec3::X).normalize_or(Vec3::X) };
+ let (asked, up) = (facing.reject_from_normalized(n), Vec3::Y.reject_from_normalized(n));
+ let spare = if up.length() > 0.3 { up.normalize() } else { Vec3::X.reject_from_normalized(n).normalize_or(Vec3::X) };
let along = (asked + spare * (1.0 - asked.length()).max(0.0) * 0.6).normalize_or(spare);
let frame = |a: Vec3, p: Vec3| Mat3::from_cols(a, p, a.cross(p));
let turn = Quat::from_mat3(&(frame(along, -n) * frame(rest.along, rest.palm).transpose())).normalize();