aboutsummaryrefslogtreecommitdiff
path: root/azalea-physics/src/lib.rs
diff options
context:
space:
mode:
authormat <git@matdoes.dev>2025-03-16 19:01:31 +0000
committermat <git@matdoes.dev>2025-03-16 19:01:31 +0000
commitca2e0b3922da74799be812e5a534a20d611fce1a (patch)
treeeddfab9839d539a31071bb206493bb4a86fbd53e /azalea-physics/src/lib.rs
parentb0bd992adcff71ee294dd05060e00e652f62a7b2 (diff)
downloadazalea-drasl-ca2e0b3922da74799be812e5a534a20d611fce1a.tar.xz
entity collisions
Diffstat (limited to 'azalea-physics/src/lib.rs')
-rw-r--r--azalea-physics/src/lib.rs20
1 files changed, 17 insertions, 3 deletions
diff --git a/azalea-physics/src/lib.rs b/azalea-physics/src/lib.rs
index 2e8132c8..c1603710 100644
--- a/azalea-physics/src/lib.rs
+++ b/azalea-physics/src/lib.rs
@@ -21,13 +21,18 @@ use azalea_entity::{
use azalea_world::{Instance, InstanceContainer, InstanceName};
use bevy_app::{App, Plugin};
use bevy_ecs::{
+ entity::Entity,
query::With,
schedule::{IntoSystemConfigs, SystemSet},
system::{Query, Res},
world::Mut,
};
use clip::box_traverse_blocks;
-use collision::{BLOCK_SHAPE, BlockWithShape, MoverType, VoxelShape, move_colliding};
+use collision::{
+ BLOCK_SHAPE, BlockWithShape, MoverType, VoxelShape,
+ entity_collisions::{CollidableEntityQuery, PhysicsQuery},
+ move_colliding,
+};
/// A Bevy [`SystemSet`] for running physics that makes entities do things.
#[derive(SystemSet, Debug, Hash, PartialEq, Eq, Clone)]
@@ -352,7 +357,7 @@ fn get_block_pos_below_that_affects_movement(position: &Position) -> BlockPos {
}
/// Options for [`handle_relative_friction_and_calculate_movement`]
-struct HandleRelativeFrictionAndCalculateMovementOpts<'a> {
+struct HandleRelativeFrictionAndCalculateMovementOpts<'a, 'b, 'world, 'state> {
block_friction: f32,
world: &'a Instance,
physics: &'a mut Physics,
@@ -363,6 +368,9 @@ struct HandleRelativeFrictionAndCalculateMovementOpts<'a> {
on_climbable: &'a OnClimbable,
pose: Option<&'a Pose>,
jumping: &'a Jumping,
+ entity: Entity,
+ physics_query: &'a PhysicsQuery<'world, 'state, 'b>,
+ collidable_entity_query: &'a CollidableEntityQuery<'world, 'state>,
}
fn handle_relative_friction_and_calculate_movement(
HandleRelativeFrictionAndCalculateMovementOpts {
@@ -376,7 +384,10 @@ fn handle_relative_friction_and_calculate_movement(
on_climbable,
pose,
jumping,
- }: HandleRelativeFrictionAndCalculateMovementOpts<'_>,
+ entity,
+ physics_query,
+ collidable_entity_query,
+ }: HandleRelativeFrictionAndCalculateMovementOpts<'_, '_, '_, '_>,
) -> Vec3 {
move_relative(
physics,
@@ -397,6 +408,9 @@ fn handle_relative_friction_and_calculate_movement(
world,
&mut position,
physics,
+ Some(entity),
+ physics_query,
+ collidable_entity_query,
)
.expect("Entity should exist");
// let delta_movement = entity.delta;