Skip to content

Commit

Permalink
Add old methods as deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
Jondolf committed Nov 30, 2023
1 parent ab21902 commit b424e2d
Showing 1 changed file with 137 additions and 0 deletions.
137 changes: 137 additions & 0 deletions src/plugins/spatial_query/system_param.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,19 @@ impl<'w, 's> SpatialQuery<'w, 's> {
.raycast(origin, direction, max_time_of_impact, solid, query_filter)
}

/// Deprecated, use [`SpatialQuery::raycast()`] instead.
#[deprecated(since = "0.4.0", note = "renamed, please use `raycast` instead")]
pub fn cast_ray(
&self,
origin: Vector,
direction: Vector,
max_time_of_impact: Scalar,
solid: bool,
query_filter: SpatialQueryFilter,
) -> Option<RayHitData> {
self.raycast(origin, direction, max_time_of_impact, solid, query_filter)
}

/// Casts a [ray](spatial_query#raycasting) and computes all [hits](RayHitData) until `max_hits` is reached.
///
/// Note that the order of the results is not guaranteed, and if there are more hits than `max_hits`,
Expand Down Expand Up @@ -194,6 +207,27 @@ impl<'w, 's> SpatialQuery<'w, 's> {
)
}

/// Deprecated, use [`SpatialQuery::raycast_many()`] instead.
#[deprecated(since = "0.4.0", note = "renamed, please use `raycast_many` instead")]
pub fn ray_hits(
&self,
origin: Vector,
direction: Vector,
max_time_of_impact: Scalar,
max_hits: u32,
solid: bool,
query_filter: SpatialQueryFilter,
) -> Vec<RayHitData> {
self.raycast_many(
origin,
direction,
max_time_of_impact,
max_hits,
solid,
query_filter,
)
}

/// Casts a [ray](spatial_query#raycasting) and computes all [hits](RayHitData), calling the given `callback`
/// for each hit. The raycast stops when `callback` returns false or all hits have been found.
///
Expand Down Expand Up @@ -260,6 +294,30 @@ impl<'w, 's> SpatialQuery<'w, 's> {
)
}

/// Deprecated, use [`SpatialQuery::raycast_many()`] instead.
#[deprecated(
since = "0.4.0",
note = "renamed, please use `raycast_callback` instead"
)]
pub fn ray_hits_callback(
&self,
origin: Vector,
direction: Vector,
max_time_of_impact: Scalar,
solid: bool,
query_filter: SpatialQueryFilter,
callback: impl FnMut(RayHitData) -> bool,
) {
self.raycast_callback(
origin,
direction,
max_time_of_impact,
solid,
query_filter,
callback,
)
}

/// Casts a [shape](spatial_query#shapecasting) with a given rotation and computes the closest [hit](ShapeHits)
/// with a collider. If there are no hits, `None` is returned.
///
Expand Down Expand Up @@ -324,6 +382,30 @@ impl<'w, 's> SpatialQuery<'w, 's> {
)
}

/// Deprecated, use [`SpatialQuery::shapecast()`] instead.
#[deprecated(since = "0.4.0", note = "renamed, please use `shapecast` instead")]
#[allow(clippy::too_many_arguments)]
pub fn cast_shape(
&self,
shape: &Collider,
origin: Vector,
shape_rotation: RotationValue,
direction: Vector,
max_time_of_impact: Scalar,
ignore_origin_penetration: bool,
query_filter: SpatialQueryFilter,
) -> Option<ShapeHitData> {
self.query_pipeline.shapecast(
shape,
origin,
shape_rotation,
direction,
max_time_of_impact,
ignore_origin_penetration,
query_filter,
)
}

/// Casts a [shape](spatial_query#shapecasting) with a given rotation and computes computes all [hits](ShapeHitData)
/// in the order of the time of impact until `max_hits` is reached.
///
Expand Down Expand Up @@ -394,6 +476,32 @@ impl<'w, 's> SpatialQuery<'w, 's> {
)
}

/// Deprecated, use [`SpatialQuery::shapecast_many()`] instead.
#[deprecated(since = "0.4.0", note = "renamed, please use `shapecast_many` instead")]
#[allow(clippy::too_many_arguments)]
pub fn shape_hits(
&self,
shape: &Collider,
origin: Vector,
shape_rotation: RotationValue,
direction: Vector,
max_time_of_impact: Scalar,
max_hits: u32,
ignore_origin_penetration: bool,
query_filter: SpatialQueryFilter,
) -> Vec<ShapeHitData> {
self.query_pipeline.shapecast_many(
shape,
origin,
shape_rotation,
direction,
max_time_of_impact,
max_hits,
ignore_origin_penetration,
query_filter,
)
}

/// Casts a [shape](spatial_query#shapecasting) with a given rotation and computes computes all [hits](ShapeHitData)
/// in the order of the time of impact, calling the given `callback` for each hit. The shapecast stops when
/// `callback` returns false or all hits have been found.
Expand Down Expand Up @@ -469,6 +577,35 @@ impl<'w, 's> SpatialQuery<'w, 's> {
)
}

/// Deprecated, use [`SpatialQuery::shapecast_callback()`] instead.
#[deprecated(
since = "0.4.0",
note = "renamed, please use `shapecast_callback` instead"
)]
#[allow(clippy::too_many_arguments)]
pub fn shape_hits_callback(
&self,
shape: &Collider,
origin: Vector,
shape_rotation: RotationValue,
direction: Vector,
max_time_of_impact: Scalar,
ignore_origin_penetration: bool,
query_filter: SpatialQueryFilter,
callback: impl FnMut(ShapeHitData) -> bool,
) {
self.query_pipeline.shapecast_callback(
shape,
origin,
shape_rotation,
direction,
max_time_of_impact,
ignore_origin_penetration,
query_filter,
callback,
)
}

/// Finds the [projection](spatial_query#point-projection) of a given point on the closest [collider](Collider).
/// If one isn't found, `None` is returned.
///
Expand Down

0 comments on commit b424e2d

Please sign in to comment.