Skip to content

Commit

Permalink
split joints and colliders out of rapier context
Browse files Browse the repository at this point in the history
I'm not totally convinced yet, this leads to unfortunate API impacts to users, + bevy_mod_debugdump a bit difficult to parse, see jakobhellermann/bevy_mod_debugdump#50
  • Loading branch information
Vrixyz committed Sep 11, 2024
1 parent ad498ee commit c7ee449
Show file tree
Hide file tree
Showing 15 changed files with 582 additions and 349 deletions.
2 changes: 2 additions & 0 deletions bevy_rapier3d/examples/ray_casting3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ pub fn cast_ray(
mut commands: Commands,
windows: Query<&Window, With<PrimaryWindow>>,
rapier_context: ReadDefaultRapierContext,
rapier_context_colliders: ReadDefaultRapierContextColliders,
cameras: Query<(&Camera, &GlobalTransform)>,
) {
let window = windows.single();
Expand All @@ -94,6 +95,7 @@ pub fn cast_ray(

// Then cast the ray.
let hit = rapier_context.cast_ray(
&rapier_context_colliders,
ray.origin,
ray.direction.into(),
f32::MAX,
Expand Down
6 changes: 3 additions & 3 deletions src/control/character_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::geometry::{Collider, CollisionGroups, ShapeCastHit};
use crate::math::{Real, Rot, Vect};
use bevy::prelude::*;

use crate::plugin::RapierContext;
use crate::plugin::{RapierContext, RapierContextColliders};
pub use rapier::control::CharacterAutostep;
pub use rapier::control::CharacterLength;
use rapier::prelude::{ColliderSet, QueryFilterFlags};
Expand All @@ -26,7 +26,7 @@ pub struct CharacterCollision {

impl CharacterCollision {
pub(crate) fn from_raw(
ctxt: &RapierContext,
ctxt: &RapierContextColliders,
c: &rapier::control::CharacterCollision,
) -> Option<Self> {
Self::from_raw_with_set(&ctxt.colliders, c, true)
Expand All @@ -37,7 +37,7 @@ impl CharacterCollision {
c: &rapier::control::CharacterCollision,
details_always_computed: bool,
) -> Option<Self> {
RapierContext::collider_entity_with_set(colliders, c.handle).map(|entity| {
RapierContextColliders::collider_entity_with_set(colliders, c.handle).map(|entity| {
CharacterCollision {
entity,
character_translation: c.character_pos.translation.vector.into(),
Expand Down
Loading

0 comments on commit c7ee449

Please sign in to comment.