Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples2d/debug_intersection2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ pub fn init_world(testbed: &mut Testbed) {
);

for intersection in query_pipeline.intersect_shape(
&Isometry::translation(slow_time.cos() * 10.0, slow_time.sin() * 10.0),
Isometry::translation(slow_time.cos() * 10.0, slow_time.sin() * 10.0),
&Ball::new(rad / 2.0),
) {
if let Some(graphics) = graphics.as_deref_mut() {
Expand Down
4 changes: 2 additions & 2 deletions examples2d/utils/character.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ fn update_kinematic_controller(
let Some(broad_phase) = phx.broad_phase.downcast_ref::<BroadPhaseBvh>() else {
return;
};
let query_pipeline = broad_phase.as_query_pipeline_mut(
let mut query_pipeline = broad_phase.as_query_pipeline_mut(
phx.narrow_phase.query_dispatcher(),
&mut phx.bodies,
&mut phx.colliders,
Expand All @@ -165,7 +165,7 @@ fn update_kinematic_controller(

controller.solve_character_collision_impulses(
phx.integration_parameters.dt,
query_pipeline,
&mut query_pipeline,
&*character_shape,
character_mass,
&*collisions,
Expand Down
4 changes: 2 additions & 2 deletions examples3d/utils/character.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ fn update_kinematic_controller(
let Some(broad_phase) = phx.broad_phase.downcast_ref::<BroadPhaseBvh>() else {
return;
};
let query_pipeline = broad_phase.as_query_pipeline_mut(
let mut query_pipeline = broad_phase.as_query_pipeline_mut(
phx.narrow_phase.query_dispatcher(),
&mut phx.bodies,
&mut phx.colliders,
Expand All @@ -175,7 +175,7 @@ fn update_kinematic_controller(

controller.solve_character_collision_impulses(
phx.integration_parameters.dt,
query_pipeline,
&mut query_pipeline,
&*character_shape,
character_mass,
&*collisions,
Expand Down
11 changes: 4 additions & 7 deletions src/control/character_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ impl KinematicCharacterController {

let mut grounded = false;

'outer: for (_, collider) in queries.intersect_aabb_conservative(&character_aabb) {
'outer: for (_, collider) in queries.intersect_aabb_conservative(character_aabb) {
manifolds.clear();
let pos12 = character_pos.inv_mul(collider.position());
let _ = dispatcher.contact_manifolds(
Expand Down Expand Up @@ -770,15 +770,15 @@ impl KinematicCharacterController {
pub fn solve_character_collision_impulses<'a>(
&self,
dt: Real,
mut queries: QueryPipelineMut,
queries: &mut QueryPipelineMut,
character_shape: &dyn Shape,
character_mass: Real,
collisions: impl IntoIterator<Item = &'a CharacterCollision>,
) {
for collision in collisions {
self.solve_single_character_collision_impulse(
dt,
&mut queries,
queries,
character_shape,
character_mass,
collision,
Expand Down Expand Up @@ -813,10 +813,7 @@ impl KinematicCharacterController {
.compute_aabb(&collision.character_pos)
.loosened(prediction);

for (_, collider) in queries
.as_ref()
.intersect_aabb_conservative(&character_aabb)
{
for (_, collider) in queries.as_ref().intersect_aabb_conservative(character_aabb) {
if let Some(parent) = collider.parent {
if let Some(body) = queries.bodies.get(parent.handle) {
if body.is_dynamic() {
Expand Down
6 changes: 3 additions & 3 deletions src/dynamics/ccd/ccd_solver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ impl CCDSolver {
.shape
.compute_swept_aabb(&co1.pos, &predicted_collider_pos1);

for (ch2, _) in query_pipeline.intersect_aabb_conservative(&aabb1) {
for (ch2, _) in query_pipeline.intersect_aabb_conservative(aabb1) {
if *ch1 == ch2 {
// Ignore self-intersection.
continue;
Expand Down Expand Up @@ -301,7 +301,7 @@ impl CCDSolver {
.shape
.compute_swept_aabb(&co1.pos, &predicted_collider_pos1);

for (ch2, _) in query_pipeline.intersect_aabb_conservative(&aabb1) {
for (ch2, _) in query_pipeline.intersect_aabb_conservative(aabb1) {
if *ch1 == ch2 {
// Ignore self-intersection.
continue;
Expand Down Expand Up @@ -433,7 +433,7 @@ impl CCDSolver {
let co_next_pos1 = rb1.pos.next_position * co1_parent.pos_wrt_parent;
let aabb = co1.shape.compute_swept_aabb(&co1.pos, &co_next_pos1);

for (ch2, _) in query_pipeline.intersect_aabb_conservative(&aabb) {
for (ch2, _) in query_pipeline.intersect_aabb_conservative(aabb) {
let co2 = &colliders[ch2];

let bh1 = co1.parent.map(|p| p.handle);
Expand Down
20 changes: 10 additions & 10 deletions src/pipeline/query_pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,19 +211,19 @@ impl<'a> QueryPipeline<'a> {
#[profiling::function]
pub fn intersect_ray(
&'a self,
ray: &'a Ray,
ray: Ray,
max_toi: Real,
solid: bool,
) -> impl Iterator<Item = (ColliderHandle, &'a Collider, RayIntersection)> + 'a {
// TODO: add this to CompositeShapeRef?
self.bvh
.leaves(move |node: &BvhNode| node.aabb().intersects_local_ray(ray, max_toi))
.leaves(move |node: &BvhNode| node.aabb().intersects_local_ray(&ray, max_toi))
.filter_map(move |leaf| {
let (co, co_handle) = self.colliders.get_unknown_gen(leaf)?;
if self.filter.test(self.bodies, co_handle, co) {
if let Some(intersection) =
co.shape
.cast_ray_and_get_normal(co.position(), ray, max_toi, solid)
.cast_ray_and_get_normal(co.position(), &ray, max_toi, solid)
{
return Some((co_handle, co, intersection));
}
Expand Down Expand Up @@ -259,15 +259,15 @@ impl<'a> QueryPipeline<'a> {
#[profiling::function]
pub fn intersect_point(
&'a self,
point: &'a Point<Real>,
point: Point<Real>,
) -> impl Iterator<Item = (ColliderHandle, &'a Collider)> + 'a {
// TODO: add to CompositeShapeRef?
self.bvh
.leaves(move |node: &BvhNode| node.aabb().contains_local_point(point))
.leaves(move |node: &BvhNode| node.aabb().contains_local_point(&point))
.filter_map(move |leaf| {
let (co, co_handle) = self.colliders.get_unknown_gen(leaf)?;
if self.filter.test(self.bodies, co_handle, co)
&& co.shape.contains_point(co.position(), point)
&& co.shape.contains_point(co.position(), &point)
{
return Some((co_handle, co));
}
Expand Down Expand Up @@ -299,11 +299,11 @@ impl<'a> QueryPipeline<'a> {
#[profiling::function]
pub fn intersect_aabb_conservative(
&'a self,
aabb: &'a Aabb,
aabb: Aabb,
) -> impl Iterator<Item = (ColliderHandle, &'a Collider)> + 'a {
// TODO: add to ColliderRef?
self.bvh
.leaves(move |node: &BvhNode| node.aabb().intersects(aabb))
.leaves(move |node: &BvhNode| node.aabb().intersects(&aabb))
.filter_map(move |leaf| {
let (co, co_handle) = self.colliders.get_unknown_gen(leaf)?;
// NOTE: do **not** recompute and check the latest collider AABB.
Expand Down Expand Up @@ -388,11 +388,11 @@ impl<'a> QueryPipeline<'a> {
#[profiling::function]
pub fn intersect_shape(
&'a self,
shape_pos: &'a Isometry<Real>,
shape_pos: Isometry<Real>,
shape: &'a dyn Shape,
) -> impl Iterator<Item = (ColliderHandle, &'a Collider)> + 'a {
// TODO: add this to CompositeShapeRef?
let shape_aabb = shape.compute_aabb(shape_pos);
let shape_aabb = shape.compute_aabb(&shape_pos);
self.bvh
.leaves(move |node: &BvhNode| node.aabb().intersects(&shape_aabb))
.filter_map(move |leaf| {
Expand Down