bevy_xpbd icon indicating copy to clipboard operation
bevy_xpbd copied to clipboard

Rename raycasting and shapecasting methods in `SpatialQuery`

Open Jondolf opened this issue 1 year ago • 0 comments
trafficstars

Objective

Currently, the following names are used for raycasting/shapecasting methods:

  • cast_ray
  • ray_hits
  • ray_hits_callback
  • cast_shape
  • shape_hits
  • shape_hits_callback

While these are fine, they could be improved. The distinction between cast_ray and ray_hits isn't immediately obvious from the name, and the naming isn't very consistent. In addition, a more common and perhaps cleaner name for cast_ray is raycast.

Solution

Rename the methods to be cleaner and more consistent:

  • cast_rayraycast
  • ray_hitsraycast_many
  • ray_hits_callbackraycast_callback
  • cast_shapeshapecast
  • shape_hitsshapecast_many
  • shape_hits_callbackshapecast_callback

The old methods still exist, but have been deprecated and will be removed after the next release.


Migration Guide

let before = spatial.cast_ray(...);
let after = spatial.raycast(...);

let before = spatial.ray_hits(...);
let after = spatial.raycast_many(...);

let before = spatial.ray_hits_callback(...);
let after = spatial.raycast_callback(...);

let before = spatial.cast_shape(...);
let after = spatial.shapecast(...);

let before = spatial.shape_hits(...);
let after = spatial.shapecast_many(...);

let before = spatial.shape_hits_callback(...);
let after = spatial.shapecast_callback(...);

Jondolf avatar Nov 30 '23 19:11 Jondolf