Skip to content

Commit

Permalink
Fix touchscreen issue (#173)
Browse files Browse the repository at this point in the history
- Fixes #171
  • Loading branch information
Ughuuu authored Jul 31, 2024
1 parent 40e3d7c commit 26a1349
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/rapier_wrapper/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ impl PhysicsEngine {
}
let mut shape_vel2 = shape_vel2;
if shape_vel2 == Vector::zeros() {
shape_vel2 = Vector::identity() * 1e-3;
shape_vel2 = -Vector::identity() * 1e-3;
}
let mut result = ShapeCastResult::new();
if let Some(raw_shared_shape1) = self.get_shape(shape_info1.handle) {
Expand Down
12 changes: 7 additions & 5 deletions src/servers/rapier_physics_server_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,6 @@ impl RapierPhysicsServerImpl {
let rapier_a_motion = vector_to_rapier(motion_a);
let rapier_b_motion = vector_to_rapier(motion_b);
let results_out: *mut Vector = results as *mut Vector;
let vector2_slice: &mut [Vector] =
unsafe { std::slice::from_raw_parts_mut(results_out, result_max as usize) };
let result = physics_data.physics_engine.shape_collide(
rapier_a_motion,
shape_a_info,
Expand All @@ -255,9 +253,13 @@ impl RapierPhysicsServerImpl {
if !result.collided {
return false;
}
*result_count = 1;
vector2_slice[0] = vector_to_godot(result.pixel_witness1);
vector2_slice[1] = vector_to_godot(result.pixel_witness2);
if result_max >= 1 {
*result_count = 1;
let vector2_slice: &mut [Vector] =
unsafe { std::slice::from_raw_parts_mut(results_out, result_max as usize) };
vector2_slice[0] = vector_to_godot(result.pixel_witness1);
vector2_slice[1] = vector_to_godot(result.pixel_witness2);
}
true
}

Expand Down

0 comments on commit 26a1349

Please sign in to comment.