Skip to content

Commit

Permalink
Fix time of impact description (#340)
Browse files Browse the repository at this point in the history
# Objective

As reported by `@nezuo` on the Bevy Discord, the documentation for the `time_of_impact` in `ShapeHits` is inaccurate and contradictory.

> How long the shape travelled before the initial hit, i.e. the distance between the origin and the point of intersection.

These are two separate things: "the distance between the origin and the point of intersection" implies that it corresponds to the blue line, but in reality it is the orange line.

![TOI visualized](https://github.com/Jondolf/bevy_xpbd/assets/57632562/80210b86-3439-48e0-94db-0f15f2dde0f0)

## Solution

Clarify the doc comment and remove the incorrect part:

> The time of impact (TOI), or how long the shape travelled before the initial hit.
  • Loading branch information
Jondolf authored Feb 29, 2024
1 parent 164f252 commit 4d17473
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/plugins/spatial_query/shape_caster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -412,8 +412,7 @@ impl MapEntities for ShapeHits {
pub struct ShapeHitData {
/// The entity of the collider that was hit by the shape.
pub entity: Entity,
/// How long the shape travelled before the initial hit,
/// i.e. the distance between the origin and the point of intersection.
/// The time of impact (TOI), or how long the shape travelled before the initial hit.
pub time_of_impact: Scalar,
/// The closest point on the collider that was hit by the shapecast, at the time of impact,
/// expressed in the local space of the collider shape.
Expand Down

0 comments on commit 4d17473

Please sign in to comment.