From 9d0ae295eec1d92a52bdb26b6eb4a501979fdc16 Mon Sep 17 00:00:00 2001 From: 2ndbeam <2ndbeam@disroot.org> Date: Sun, 15 Feb 2026 18:05:27 +0300 Subject: [PATCH] feat!: Got rid of UpdateShapes component - update_collider_shapes now filters by Changed --- src/lib.rs | 23 +++-------------------- tests/collider_position.rs | 9 +++------ 2 files changed, 6 insertions(+), 26 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 020f6e9..f1c6d15 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -130,29 +130,12 @@ impl Collider { } } -#[derive(Component, Debug)] -/// Add this component on entities, which have their [`Transform`] updated. -/// Used for [`update_collider_shapes`] system -pub struct UpdateShapes; - /// Update collider shapes to match new [`Transform`] pub fn update_collider_shapes( - mut commands: Commands, - colliders: Query<(&mut Collider, &Transform, Entity), Added>, + colliders: Query<(&mut Collider, &Transform), Changed>, ) { - for (mut collider, transform, entity) in colliders { + for (mut collider, transform) in colliders { collider.update_shapes_position(&transform.translation.xy()); - commands.entity(entity).remove::(); - } -} - -/// Detect new colliders and automatically insert [`UpdateShapes`] -pub fn detect_colliders( - mut commands: Commands, - query: Query>, -) { - for entity in query { - commands.entity(entity).insert(UpdateShapes); } } @@ -189,6 +172,6 @@ pub struct CollisionPlugin; impl Plugin for CollisionPlugin { fn build(&self, app: &mut App) { - app.add_systems(PostUpdate, (detect_colliders, update_collider_shapes, check_for_collisions).chain()); + app.add_systems(PostUpdate, (update_collider_shapes, check_for_collisions).chain()); } } diff --git a/tests/collider_position.rs b/tests/collider_position.rs index caad3b1..ded7c6b 100644 --- a/tests/collider_position.rs +++ b/tests/collider_position.rs @@ -1,5 +1,5 @@ use bevy::prelude::*; -use bevy_collision_plugin::{Collider, CollisionEvent, CollisionPlugin, CollisionShape, UpdateShapes}; +use bevy_collision_plugin::{Collider, CollisionEvent, CollisionPlugin, CollisionShape}; const CHECKED_GROUPS: usize = 1 << 0 | 1 << 1; @@ -48,13 +48,10 @@ fn firstgroup_collider_bundle() -> impl Bundle { } fn move_collider( - mut commands: Commands, - query: Query<(Entity, &mut Transform), With>, + query: Query<&mut Transform, With>, ) { - for (entity, mut transform) in query { + for mut transform in query { transform.translation.x += 50.; - commands.entity(entity) - .insert(UpdateShapes); } }