Skip to content

Commit

Permalink
Merge branch 'master' into split_rapiercontext
Browse files Browse the repository at this point in the history
  • Loading branch information
Vrixyz committed Nov 18, 2024
2 parents 3e98da1 + ce3847c commit a8c94b4
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 16 deletions.
13 changes: 12 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ which was its hardcoded behaviour.
### Modified

- Rapier now supports multiple independent physics worlds, see example `multi_world3` for usage details.
- `RapierContext`, `RapierConfiguration` and `SimulationToRenderTime` are no longer a resource.
- `RapierContext`, `RapierConfiguration` and `SimulationToRenderTime` are no longer `Resource`s.
- They have been split in multiple `Component`s:
- `RapierContextColliders`
- `RapierContextJoints`
Expand All @@ -42,6 +42,17 @@ which was its hardcoded behaviour.
- If you are building a library on top of `bevy_rapier` and would want to support multiple independent physics worlds too,
you can check out the details of [#545](https://github.com/dimforge/bevy_rapier/pull/545)
to find more information.
- Rapier now supports multiple independent physics worlds, see example `multi_world3` for usage details.
- Migration guide:
- `ResMut<mut RapierContext>` -> `WriteDefaultRapierContext`
- `Res<RapierContext>` -> `ReadDefaultRapierContext`
- Access to `RapierConfiguration` and `RenderToSimulationTime` should query for it
on the responsible entity owning the `RenderContext`.
- If you are building a library on top of `bevy_rapier` and would want to support multiple independent physics worlds too,
you can check out the details of [#545](https://github.com/dimforge/bevy_rapier/pull/545)
to get more context and information.
- `colliders_with_aabb_intersecting_aabb` now takes `bevy::math::bounding::Aabb3d` (or `[..]::Aabb2d` in 2D) as parameter.
- it is now accessible with `headless` feature enabled.

## v0.27.0 (07 July 2024)

Expand Down
14 changes: 4 additions & 10 deletions src/plugin/context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -455,22 +455,16 @@ impl RapierQueryPipeline {
}

/// Finds all entities of all the colliders with an Aabb intersecting the given Aabb.
#[cfg(not(feature = "headless"))]
pub fn colliders_with_aabb_intersecting_aabb(
&self,
rapier_colliders: &RapierContextColliders,
aabb: bevy::render::primitives::Aabb,
#[cfg(feature = "dim2")] aabb: bevy::math::bounding::Aabb2d,
#[cfg(feature = "dim3")] aabb: bevy::math::bounding::Aabb3d,
mut callback: impl FnMut(Entity) -> bool,
) {
#[cfg(feature = "dim2")]
let scaled_aabb = rapier::prelude::Aabb {
mins: aabb.min().xy().into(),
maxs: aabb.max().xy().into(),
};
#[cfg(feature = "dim3")]
let scaled_aabb = rapier::prelude::Aabb {
mins: aabb.min().into(),
maxs: aabb.max().into(),
mins: aabb.min.into(),
maxs: aabb.max.into(),
};
#[allow(clippy::redundant_closure)]
// False-positive, we can't move callback, closure becomes `FnOnce`
Expand Down
10 changes: 6 additions & 4 deletions src/plugin/context/systemparams/rapier_context_systemparam.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl<'w, 's, T: query::QueryFilter + 'static> ReadRapierContext<'w, 's, T> {
/// SAFETY: This method will panic if its underlying query fails.
///
/// Use the underlying query [`ReadRapierContext::rapier_context`] for safer alternatives.
pub fn single(&'_ self) -> RapierContext {
pub fn single(&self) -> RapierContext {
let (simulation, colliders, joints, query_pipeline, rigidbody_set) =
self.rapier_context.single();
RapierContext {
Expand Down Expand Up @@ -401,11 +401,12 @@ mod query_pipeline {
/// Shortcut to [`RapierQueryPipeline::colliders_with_aabb_intersecting_aabb`].
pub fn colliders_with_aabb_intersecting_aabb(
&self,
aabb: bevy::render::primitives::Aabb,
#[cfg(feature = "dim2")] aabb: bevy::math::bounding::Aabb2d,
#[cfg(feature = "dim3")] aabb: bevy::math::bounding::Aabb3d,
callback: impl FnMut(Entity) -> bool,
) {
self.query_pipeline.colliders_with_aabb_intersecting_aabb(
self.colliders,
&self.colliders,
aabb,
callback,
)
Expand Down Expand Up @@ -567,7 +568,8 @@ mod query_pipeline {
/// Shortcut to [`RapierQueryPipeline::colliders_with_aabb_intersecting_aabb`].
pub fn colliders_with_aabb_intersecting_aabb(
&self,
aabb: bevy::render::primitives::Aabb,
#[cfg(feature = "dim2")] aabb: bevy::math::bounding::Aabb2d,
#[cfg(feature = "dim3")] aabb: bevy::math::bounding::Aabb3d,
callback: impl FnMut(Entity) -> bool,
) {
self.query_pipeline.colliders_with_aabb_intersecting_aabb(
Expand Down
2 changes: 1 addition & 1 deletion src/plugin/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ impl<PhysicsHooksSystemParam> Default for RapierPhysicsPlugin<PhysicsHooksSystem
Self {
schedule: PostUpdate.intern(),
default_system_setup: true,
default_world_setup: default(),
default_world_setup: Default::default(),
_phantom: PhantomData,
}
}
Expand Down

0 comments on commit a8c94b4

Please sign in to comment.