Feature Request: `cast_shape` enhancements
- Dominant language
- Rust
- Stars
- 867
- Forks
- 157
- Avg merge
- 7d 13h
- Merged PRs (30d)
- 2
Description
**Version:** parry v0.26.0
I just struggled through implementing a sliding, 2d character controller using `cast_shape` and `Bvh`, and while I got it working in the end, there are two changes that would have made it a lot easier.
1. Allow negative `time_of_impact` results, indicating shapes are already overlapping. E.g. positive means not overlapping, zero means touching, negative means overlapping. The contact Api's already do this.
I repeatedly ran into the case where moving things based on the returned ToI would put objects in contact or even overlapping. Once that happens, getting them unstuck is tricky because `cast_shape` always returns a zero ToI. I ended up doing 1) `cast_shape`, 2) update position, 3) calculate contact at new position, 4) push objects out of contact if needed. If `cast_shape` returned negative ToI for overlapping objects, I could have just unconditionally used ToI, and been done with it.
1. Allow `cast_shape` to work when shapes are touching. E.g. if two cubiods are touching, they should still be able to cast perpendicular to each other. (I imagine this is as easy as using a `<` instead of `<=` somewhere, or something similar)
With the work around for point 1 above in place, I no longer got stuck, but I often couldn't slide because `cast_shape` returns a zero ToI for touching shapes. My very sophisticated (*cough*) work around for this was to scale the cast shape by `0.9999` before calling `cast_shape`. Effectively, this makes it look like touching shapes aren't actually touching.
Btw, I just want to say the new `Bvh` is much nicer to use than the old `Qbvh`. Thanks a lot!
Contributor guide
Assessment
This issue has not been assessed yet.