diff --git a/Cargo.lock b/Cargo.lock index b333804d..644efa06 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -82,9 +82,9 @@ dependencies = [ [[package]] name = "bytemuck" -version = "1.18.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94bbb0ad554ad961ddc5da507a12a29b14e4ae5bda06b19f575a3e6079d2e2ae" +checksum = "8334215b81e418a0a7bdb8ef0849474f40bb10c8b71f1c4ed315cff49f32494d" [[package]] name = "byteorder" @@ -552,7 +552,7 @@ dependencies = [ [[package]] name = "parry2d" version = "0.17.1" -source = "git+https://github.com/ughuuu/parry?branch=custom-changes#4eb05f7b4267b0b8ce8508ef1f8d1ae44ef56360" +source = "git+https://github.com/ughuuu/parry?branch=custom-changes#d1740e893f04f74fc767fe7d2311ed4acbae162a" dependencies = [ "approx", "arrayvec", @@ -577,7 +577,7 @@ dependencies = [ [[package]] name = "parry2d-f64" version = "0.17.1" -source = "git+https://github.com/ughuuu/parry?branch=custom-changes#4eb05f7b4267b0b8ce8508ef1f8d1ae44ef56360" +source = "git+https://github.com/ughuuu/parry?branch=custom-changes#d1740e893f04f74fc767fe7d2311ed4acbae162a" dependencies = [ "approx", "arrayvec", @@ -602,7 +602,7 @@ dependencies = [ [[package]] name = "parry3d" version = "0.17.1" -source = "git+https://github.com/ughuuu/parry?branch=custom-changes#4eb05f7b4267b0b8ce8508ef1f8d1ae44ef56360" +source = "git+https://github.com/ughuuu/parry?branch=custom-changes#d1740e893f04f74fc767fe7d2311ed4acbae162a" dependencies = [ "approx", "arrayvec", @@ -628,7 +628,7 @@ dependencies = [ [[package]] name = "parry3d-f64" version = "0.17.1" -source = "git+https://github.com/ughuuu/parry?branch=custom-changes#4eb05f7b4267b0b8ce8508ef1f8d1ae44ef56360" +source = "git+https://github.com/ughuuu/parry?branch=custom-changes#d1740e893f04f74fc767fe7d2311ed4acbae162a" dependencies = [ "approx", "arrayvec", diff --git a/Cargo.toml b/Cargo.toml index f1724916..69b01613 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ publish = false crate-type = ["cdylib"] [features] -default = ["build3d", "test"] +default = ["build2d", "test"] test = [] build2d = ["single-dim2", "serde-serialize", "simd-stable"] build3d = ["single-dim3", "serde-serialize", "simd-stable"] diff --git a/src/rapier_wrapper/query.rs b/src/rapier_wrapper/query.rs index 1a4c624b..92671099 100644 --- a/src/rapier_wrapper/query.rs +++ b/src/rapier_wrapper/query.rs @@ -1,9 +1,11 @@ use std::ops::Mul; use godot::global::godot_error; +use godot::global::godot_warn; use nalgebra::zero; use rapier::parry; use rapier::parry::query::ShapeCastOptions; +use rapier::parry::query::ShapeCastStatus; use rapier::prelude::*; use crate::rapier_wrapper::prelude::*; @@ -239,6 +241,7 @@ impl PhysicsEngine { let shape_cast_options = ShapeCastOptions { max_time_of_impact: 1.0, stop_at_penetration: true, + compute_impact_geometry_on_penetration: true, ..Default::default() }; let toi_result = parry::query::cast_shapes( @@ -253,12 +256,19 @@ impl PhysicsEngine { match toi_result { Ok(None) => {} Ok(Some(hit)) => { + if hit.status == ShapeCastStatus::Failed + || hit.status == ShapeCastStatus::OutOfIterations + { + godot_warn!("shape collide status warn: {:?}", hit.status); + } result.collided = true; result.toi = hit.time_of_impact; result.normal1 = hit.normal1.into_inner(); result.normal2 = hit.normal2.into_inner(); - result.pixel_witness1 = hit.witness1.coords; - result.pixel_witness2 = hit.witness2.coords; + result.pixel_witness1 = + hit.witness1.coords + shape_info1.transform.translation.vector; + result.pixel_witness2 = + hit.witness2.coords + shape_info2.transform.translation.vector; } Err(err) => { godot_error!("toi error: {:?}", err); @@ -307,6 +317,7 @@ impl PhysicsEngine { let shape_cast_options = ShapeCastOptions { max_time_of_impact: 1.0, stop_at_penetration: true, + compute_impact_geometry_on_penetration: true, ..Default::default() }; if let Some((collider_handle, hit)) = @@ -320,6 +331,11 @@ impl PhysicsEngine { filter, ) { + if hit.status == ShapeCastStatus::Failed + || hit.status == ShapeCastStatus::OutOfIterations + { + godot_warn!("shape casting status warn: {:?}", hit.status); + } result.collided = true; result.toi = hit.time_of_impact; result.normal1 = hit.normal1.into_inner();