chore: make it easier to test ccd with linear vs. nonlinear shape-casting
This commit is contained in:
committed by
Sébastien Crozet
parent
0652b4592f
commit
f49d0206cb
@@ -1,7 +1,7 @@
|
|||||||
use crate::dynamics::{RigidBody, RigidBodyHandle};
|
use crate::dynamics::{RigidBody, RigidBodyHandle};
|
||||||
use crate::geometry::{Collider, ColliderHandle};
|
use crate::geometry::{Collider, ColliderHandle};
|
||||||
use crate::math::Real;
|
use crate::math::Real;
|
||||||
use parry::query::{NonlinearRigidMotion, QueryDispatcher};
|
use parry::query::{NonlinearRigidMotion, QueryDispatcher, ShapeCastOptions};
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
pub struct TOIEntry {
|
pub struct TOIEntry {
|
||||||
@@ -112,33 +112,38 @@ impl TOIEntry {
|
|||||||
// because the colliders may be in a separating trajectory.
|
// because the colliders may be in a separating trajectory.
|
||||||
let stop_at_penetration = is_pseudo_intersection_test;
|
let stop_at_penetration = is_pseudo_intersection_test;
|
||||||
|
|
||||||
// let pos12 = motion_c1
|
const USE_NONLINEAR_SHAPE_CAST: bool = true;
|
||||||
// .position_at_time(start_time)
|
|
||||||
// .inv_mul(&motion_c2.position_at_time(start_time));
|
|
||||||
// let vel12 = linvel2 - linvel1;
|
|
||||||
// let res_toi = query_dispatcher
|
|
||||||
// .time_of_impact(
|
|
||||||
// &pos12,
|
|
||||||
// &vel12,
|
|
||||||
// co1.shape.as_ref(),
|
|
||||||
// co2.shape.as_ref(),
|
|
||||||
// end_time - start_time,
|
|
||||||
// )
|
|
||||||
// .ok();
|
|
||||||
|
|
||||||
let res_toi = query_dispatcher
|
let toi = if USE_NONLINEAR_SHAPE_CAST {
|
||||||
.cast_shapes_nonlinear(
|
query_dispatcher
|
||||||
&motion_c1,
|
.cast_shapes_nonlinear(
|
||||||
co1.shape.as_ref(),
|
&motion_c1,
|
||||||
&motion_c2,
|
co1.shape.as_ref(),
|
||||||
co2.shape.as_ref(),
|
&motion_c2,
|
||||||
start_time,
|
co2.shape.as_ref(),
|
||||||
end_time,
|
start_time,
|
||||||
stop_at_penetration,
|
end_time,
|
||||||
)
|
stop_at_penetration,
|
||||||
.ok();
|
)
|
||||||
|
.ok()??
|
||||||
let toi = res_toi??;
|
} else {
|
||||||
|
let pos12 = motion_c1
|
||||||
|
.position_at_time(start_time)
|
||||||
|
.inv_mul(&motion_c2.position_at_time(start_time));
|
||||||
|
let vel12 = linvel2 - linvel1;
|
||||||
|
let options = ShapeCastOptions::with_max_time_of_impact(end_time - start_time);
|
||||||
|
let mut hit = query_dispatcher
|
||||||
|
.cast_shapes(
|
||||||
|
&pos12,
|
||||||
|
&vel12,
|
||||||
|
co1.shape.as_ref(),
|
||||||
|
co2.shape.as_ref(),
|
||||||
|
options,
|
||||||
|
)
|
||||||
|
.ok()??;
|
||||||
|
hit.time_of_impact += start_time;
|
||||||
|
hit
|
||||||
|
};
|
||||||
|
|
||||||
Some(Self::new(
|
Some(Self::new(
|
||||||
toi.time_of_impact,
|
toi.time_of_impact,
|
||||||
|
|||||||
Reference in New Issue
Block a user