fix(input): extra hand data
This commit is contained in:
@@ -7,16 +7,21 @@ use std::sync::Arc;
|
||||
|
||||
use super::{DistanceLink, InputSpecialization};
|
||||
|
||||
impl InputSpecialization for HandT {
|
||||
pub struct Hand {
|
||||
pub base: HandT,
|
||||
pub pinch_strength: f32,
|
||||
pub grab_strength: f32,
|
||||
}
|
||||
impl InputSpecialization for Hand {
|
||||
fn distance(&self, space: &Arc<Spatial>, field: &Field) -> f32 {
|
||||
let mut min_distance = f32::MAX;
|
||||
|
||||
for tip in [
|
||||
&self.thumb.tip.position,
|
||||
&self.index.tip.position,
|
||||
&self.middle.tip.position,
|
||||
&self.ring.tip.position,
|
||||
&self.little.tip.position,
|
||||
&self.base.thumb.tip.position,
|
||||
&self.base.index.tip.position,
|
||||
&self.base.middle.tip.position,
|
||||
&self.base.ring.tip.position,
|
||||
&self.base.little.tip.position,
|
||||
] {
|
||||
min_distance = min_distance.min(field.distance(space, vec3a(tip.x, tip.y, tip.z)));
|
||||
}
|
||||
@@ -32,7 +37,7 @@ impl InputSpecialization for HandT {
|
||||
InputDataRaw,
|
||||
flatbuffers::WIPOffset<flatbuffers::UnionWIPOffset>,
|
||||
) {
|
||||
let mut hand = self.clone();
|
||||
let mut hand = self.base.clone();
|
||||
let mut joints: Vec<&mut JointT> = Vec::new();
|
||||
|
||||
joints.extend([&mut hand.palm, &mut hand.wrist]);
|
||||
@@ -77,7 +82,9 @@ impl InputSpecialization for HandT {
|
||||
fn serialize_datamap(&self) -> Vec<u8> {
|
||||
let mut fbb = flexbuffers::Builder::default();
|
||||
let mut map = fbb.start_map();
|
||||
map.push("right", self.right);
|
||||
map.push("right", self.base.right);
|
||||
map.push("pinchStrength", self.pinch_strength);
|
||||
map.push("grabStrength", self.grab_strength);
|
||||
map.end_map();
|
||||
fbb.view().to_vec()
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
pub mod hand;
|
||||
pub mod pointer;
|
||||
|
||||
use self::hand::Hand;
|
||||
use self::pointer::Pointer;
|
||||
|
||||
use super::fields::Field;
|
||||
@@ -14,7 +15,6 @@ use glam::Mat4;
|
||||
use nanoid::nanoid;
|
||||
use parking_lot::Mutex;
|
||||
use stardust_xr_schemas::input::{InputData, InputDataArgs, InputDataRaw};
|
||||
use stardust_xr_schemas::input_hand::HandT;
|
||||
use std::ops::Deref;
|
||||
use std::sync::atomic::Ordering;
|
||||
use std::sync::{Arc, Weak};
|
||||
@@ -37,7 +37,7 @@ pub trait InputSpecialization: Send + Sync {
|
||||
}
|
||||
pub enum InputType {
|
||||
Pointer(Pointer),
|
||||
Hand(Box<HandT>),
|
||||
Hand(Box<Hand>),
|
||||
}
|
||||
impl Deref for InputType {
|
||||
type Target = dyn InputSpecialization;
|
||||
|
||||
Reference in New Issue
Block a user