From 3994c1c744537fd6c8c7fb89a545b645719c97c2 Mon Sep 17 00:00:00 2001 From: Nolan Darilek Date: Wed, 9 Jun 2021 17:24:56 -0500 Subject: [PATCH] Avoid unnecessary coordinate changes. --- src/core.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/core.rs b/src/core.rs index 139422f..69be08c 100644 --- a/src/core.rs +++ b/src/core.rs @@ -565,11 +565,15 @@ fn copy_coordinates_to_transform( } fn copy_rigid_body_position_to_coordinates( - mut query: Query<(&mut Coordinates, &RigidBodyPosition)>, + mut query: Query<(&mut Coordinates, &RigidBodyPosition), Changed>, ) { for (mut coordinates, position) in query.iter_mut() { - coordinates.0 .0 = position.position.translation.x; - coordinates.0 .1 = position.position.translation.y; + if coordinates.0 .0 != position.position.translation.x { + coordinates.0 .0 = position.position.translation.x; + } + if coordinates.0 .1 != position.position.translation.y { + coordinates.0 .1 = position.position.translation.y; + } } }