Penetration queries work only sporadically with compound shapes
- Dominant language
- Rust
- Stars
- 926
- Forks
- 104
- PR merge metrics
- No merged PRs in 30d
Description
I have found that penetration queries seem to only sometimes work for compound shapes against compound shapes. I'm not sure what the circumstance is when they *do* work, but I have at least one test that consistently fails where it should seemingly return a penetration value:
In this test the north wall of the first room overlaps the south wall of the second. The walls are 0.2 thick.
```rust
#[test]
fn test_compound_penetration() {
let mut r1 = Room::new_with_centered_door(Point::new(0.0, 0.0), 10.0, 10.0, Direction::North);
r1.is_compound = true;
let starter_loc = r1.location();
let mut compound_rm = Compound::new(vec![(origin(), r1.shape())]);
let r2 = Room::new_with_centered_door(Point::new(0.0, 10.0), 10.0, 10.15, Direction::North);
let r2_s = r2.shape();
let r2_shape: &CollisionRect = r2_s.as_shape().unwrap();
let penetration = query::contact(&origin(), &compound_rm, &r2.location(), r2_shape,
WALL_THICKNESS);
assert!(penetration.is_some())
}
```
But the test fails.
For how the "Room" is constructed:
```rust
impl Collidable for Room {
fn location(&self) -> Isometry2 { Isometry2::new(self.center().coords, na::zero()) }
fn shape(&self) -> Shape2D {
let shapes = self.walls.iter().map(|&(w, _)| {
let cr: CollisionRect = w.into();
// Wall locations need to be represented relative to the center of the room
let loc = Isometry2::new(w.center().coords - self.center().coords, na::zero());
(loc, ShapeHandle::new(cr))
});
let whole_shape = Compound::new(shapes.collect());
ShapeHandle::new(whole_shape)
}
fn collision_group(&self) -> CollisionGroups { CollGroups::wall_cg() }
fn coltype(&self) -> CollidableType {
if self.is_compound { CollidableType::CompoundRoomWall } else { CollidableType::RoomWall }
}
}
```
Here is a picture of the rooms where walls are a not-fully-opaque green, so you can see the overlap as a slightly brighter green:

Am I doing something wrong here? Or is this a bug for compound shapes?
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.