welp this works better
This commit is contained in:
@@ -302,7 +302,7 @@ fn spawn_physics_hands(mut commands: Commands) {
|
|||||||
),
|
),
|
||||||
RigidBody::KinematicVelocityBased,
|
RigidBody::KinematicVelocityBased,
|
||||||
Velocity::default(),
|
Velocity::default(),
|
||||||
// CollisionGroups::new(self_group, interaction_group),
|
CollisionGroups::new(Group::from_bits(0b1110).unwrap(), Group::from_bits(0b0001).unwrap()),
|
||||||
// SolverGroups::new(self_group, interaction_group),
|
// SolverGroups::new(self_group, interaction_group),
|
||||||
bone.clone(),
|
bone.clone(),
|
||||||
BoneInitState::False,
|
BoneInitState::False,
|
||||||
@@ -355,6 +355,7 @@ fn update_physics_hands(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
match *bone.3 {
|
match *bone.3 {
|
||||||
BoneInitState::True => {
|
BoneInitState::True => {
|
||||||
match matching {
|
match matching {
|
||||||
@@ -373,18 +374,14 @@ fn update_physics_hands(
|
|||||||
/ time.delta_seconds();
|
/ time.delta_seconds();
|
||||||
bone.5.linvel = diff;
|
bone.5.linvel = diff;
|
||||||
//calculate angular velocity?
|
//calculate angular velocity?
|
||||||
let why = direction.xy();
|
let desired_forward = start_components.unwrap().0.clone().looking_at(end_components.unwrap().0.translation, Vec3::Y).rotation;
|
||||||
let desired_forward = Quat::from_rotation_arc(bone.0.forward(), direction.normalize());
|
let some: Vec3 = help_me(bone.0.rotation,desired_forward);
|
||||||
let ang: Vec3 = why_god(
|
|
||||||
bone.0.rotation,
|
|
||||||
desired_forward,
|
|
||||||
time.delta_seconds(),
|
|
||||||
);
|
|
||||||
if *bone.2 == PhysicsHandBone::IndexIntermediate && *bone.4 == Hand::Right {
|
if *bone.2 == PhysicsHandBone::IndexIntermediate && *bone.4 == Hand::Right {
|
||||||
info!("{}", ang);
|
info!("{}", some);
|
||||||
// info!("{}", forward);
|
// info!("{}", forward);
|
||||||
}
|
}
|
||||||
bone.5.angvel = ang * PI / 180.0;
|
bone.5.angvel = 5.0 * some / time.delta_seconds();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -409,15 +406,18 @@ fn update_physics_hands(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn why_god(q1: Quat, q2: Quat, dt: f32) -> Vec3 {
|
fn help_me(rotation: Quat, desired_forward: Quat) -> Vec3 {
|
||||||
let huh = Vec3 {
|
let conj = rotation.conjugate();
|
||||||
x: (q1.w * q2.x) - (q1.x * q2.x) - (q1.y * q2.z) + (q1.z * q2.y),
|
let diff = desired_forward.mul_quat(conj);
|
||||||
y: (q1.w * q2.y) - (q1.x * q2.z) - (q1.y * q2.w) + (q1.z * q2.x),
|
let mut test = diff.to_axis_angle();
|
||||||
z: (q1.w * q2.z) - (q1.x * q2.y) - (q1.y * q2.x) + (q1.z * q2.w),
|
if test.0.x.is_infinite() {
|
||||||
};
|
return Vec3::ZERO;
|
||||||
let why = 2.0 / dt;
|
}
|
||||||
let help = why * huh;
|
// if test.1 > 180.0 {
|
||||||
return help;
|
// test.1 = test.1 - 360.0;
|
||||||
|
// }
|
||||||
|
let ang = (0.99 * (PI / 180.0) * test.1) * test.0;
|
||||||
|
return ang;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_start_and_end_entities(
|
fn get_start_and_end_entities(
|
||||||
|
|||||||
Reference in New Issue
Block a user