More optimizations to coordinate/position sync.
This commit is contained in:
parent
2abeb3b08c
commit
e6af8f7618
26
src/core.rs
26
src/core.rs
|
@ -550,7 +550,11 @@ fn copy_coordinates_to_transform(
|
|||
config: Res<CoreConfig>,
|
||||
mut query: Query<
|
||||
(&Coordinates, &mut Transform),
|
||||
(Without<RigidBodyPosition>, Without<ColliderPosition>),
|
||||
(
|
||||
Changed<Transform>,
|
||||
Without<RigidBodyPosition>,
|
||||
Without<ColliderPosition>,
|
||||
),
|
||||
>,
|
||||
) {
|
||||
for (coordinates, mut transform) in query.iter_mut() {
|
||||
|
@ -578,6 +582,22 @@ fn copy_rigid_body_position_to_coordinates(
|
|||
}
|
||||
}
|
||||
|
||||
fn copy_collider_position_to_coordinates(
|
||||
mut query: Query<
|
||||
(&mut Coordinates, &ColliderPosition),
|
||||
(Without<RigidBodyPosition>, Changed<ColliderPosition>),
|
||||
>,
|
||||
) {
|
||||
for (mut coordinates, position) in query.iter_mut() {
|
||||
if coordinates.0 .0 != position.translation.x {
|
||||
coordinates.0 .0 = position.translation.x;
|
||||
}
|
||||
if coordinates.0 .1 != position.translation.y {
|
||||
coordinates.0 .1 = position.translation.y;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub struct CoreConfig {
|
||||
pub pixels_per_unit: u8,
|
||||
|
@ -607,6 +627,10 @@ impl Plugin for CorePlugin {
|
|||
.add_system_to_stage(
|
||||
CoreStage::PostUpdate,
|
||||
copy_rigid_body_position_to_coordinates.system(),
|
||||
)
|
||||
.add_system_to_stage(
|
||||
CoreStage::PostUpdate,
|
||||
copy_collider_position_to_coordinates.system(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user