Skip to content

Commit

Permalink
Use RapierContextEntityLink to detect the Rapir context
Browse files Browse the repository at this point in the history
  • Loading branch information
idanarye committed Dec 13, 2024
1 parent 32ce7f5 commit 18bcee3
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
9 changes: 8 additions & 1 deletion rapier2d/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,10 @@ fn get_collider(

#[allow(clippy::type_complexity)]
fn update_proximity_sensors_system(
rapier_context: ReadDefaultRapierContext,
rapier_context_query: RapierContextAccess,
mut query: Query<(
Entity,
&RapierContextEntityLink,
&GlobalTransform,
&mut TnuaProximitySensor,
Option<&TnuaRapier2dSensorShape>,
Expand All @@ -133,6 +134,7 @@ fn update_proximity_sensors_system(
query.par_iter_mut().for_each(
|(
owner_entity,
rapier_context_entity_link,
transform,
mut sensor,
shape,
Expand All @@ -145,6 +147,11 @@ fn update_proximity_sensors_system(
TnuaToggle::SenseOnly => {}
TnuaToggle::Enabled => {}
}

let Some(rapier_context) = rapier_context_query.try_context(rapier_context_entity_link) else {
return;
};

let cast_origin = transform.transform_point(sensor.cast_origin);
let cast_direction = sensor.cast_direction;

Expand Down
3 changes: 3 additions & 0 deletions rapier3d/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
NOTE: This changelog is shared between bevy-tnua-rapier2d and bevy-tnua-rapier3d.

## [Unreleased]
### Changed
- Use `RapierContextEntityLink` to detect the Rapir context. This means Tnua
should now support Rapier's multiple physics worlds feature.

## 0.8.0 - 2024-12-13
### Changed
Expand Down
9 changes: 8 additions & 1 deletion rapier3d/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,10 @@ fn get_collider(

#[allow(clippy::type_complexity)]
fn update_proximity_sensors_system(
rapier_context: ReadDefaultRapierContext,
rapier_context_query: RapierContextAccess,
mut query: Query<(
Entity,
&RapierContextEntityLink,
&GlobalTransform,
&mut TnuaProximitySensor,
Option<&TnuaRapier3dSensorShape>,
Expand All @@ -133,6 +134,7 @@ fn update_proximity_sensors_system(
query.par_iter_mut().for_each(
|(
owner_entity,
rapier_context_entity_link,
transform,
mut sensor,
shape,
Expand All @@ -145,6 +147,11 @@ fn update_proximity_sensors_system(
TnuaToggle::SenseOnly => {}
TnuaToggle::Enabled => {}
}

let Some(rapier_context) = rapier_context_query.try_context(rapier_context_entity_link) else {
return;
};

let cast_origin = transform.transform_point(sensor.cast_origin);
let cast_direction = sensor.cast_direction;

Expand Down

0 comments on commit 18bcee3

Please sign in to comment.