From 7b2551b39e57456bc993937edb3f2b3657c1501d Mon Sep 17 00:00:00 2001 From: VirxEC Date: Wed, 14 Jun 2023 00:54:00 -0400 Subject: [PATCH] Fix array to quat --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/lib.rs | 16 +++++++--------- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a6ff602..b3f02a8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -175,7 +175,7 @@ dependencies = [ [[package]] name = "rlviser-py" -version = "0.2.0" +version = "0.2.1" dependencies = [ "glam", "once_cell", diff --git a/Cargo.toml b/Cargo.toml index 1f59fbf..68f2eb4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rlviser-py" -version = "0.2.0" +version = "0.2.1" edition = "2021" description = "Python implementation that manages a UDP connection to RLViser" license = "MIT" diff --git a/src/lib.rs b/src/lib.rs index 7666f7f..ce2828f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -72,13 +72,8 @@ pub const OCTANE: CarConfig = CarConfig { }; #[inline] -fn ball_to_quat(array: [f32; 4]) -> Quat { - Quat::from_xyzw(array[1], array[2], array[3], array[0]) -} - -#[inline] -fn car_to_mat3a(array: [f32; 4]) -> Mat3A { - Mat3A::from_quat(Quat::from_xyzw(-array[1], array[2], array[3], array[0])) +fn array_to_quat(array: [f32; 4]) -> Quat { + Quat::from_xyzw(-array[1], -array[2], array[3], array[0]) } /// Reads the RLGym state and sends it to RLViser to render @@ -93,7 +88,7 @@ fn render_rlgym(gym_state: GymState) { vel: gym_state.ball.linear_velocity.into(), ang_vel: gym_state.ball.angular_velocity.into(), }, - ball_rot: ball_to_quat(gym_state.ball.quaternion), + ball_rot: array_to_quat(gym_state.ball.quaternion), pads: BOOST_PAD_LOCATIONS .read() .unwrap() @@ -119,8 +114,11 @@ fn render_rlgym(gym_state: GymState) { pos: player.car_data.position.into(), vel: player.car_data.linear_velocity.into(), ang_vel: player.car_data.angular_velocity.into(), - rot_mat: car_to_mat3a(player.car_data.quaternion), + rot_mat: Mat3A::from_quat(array_to_quat(player.car_data.quaternion)), is_on_ground: player.on_ground != 0, + is_demoed: player.is_demoed != 0, + has_flipped: player.has_flip == 0, + has_jumped: player.has_jump == 0, ..Default::default() }, config: OCTANE,