Skip to content

Commit

Permalink
Fix boost pad locations
Browse files Browse the repository at this point in the history
  • Loading branch information
VirxEC committed Nov 3, 2023
1 parent ff60b4a commit 160bfab
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pytest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import rlviser_py as vis
import RocketSim as rs

game_mode = rs.GameMode.SOCCAR
game_mode = rs.GameMode.HOOPS

# Create example arena
arena = rs.Arena(game_mode)
Expand Down
9 changes: 4 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ macro_rules! pynamedmodule {
};
}

pub const BOOST_PADS_LENGTH: usize = 34;

pynamedmodule! {
doc: "rlviser_py is a module for interacting with RLViser from Python",
name: rlviser_py,
Expand All @@ -31,13 +29,14 @@ pynamedmodule! {
}

thread_local! {
static BOOST_PAD_LOCATIONS: RefCell<[Vec3; BOOST_PADS_LENGTH]> = RefCell::new([Vec3::ZERO; BOOST_PADS_LENGTH]);
static BOOST_PAD_LOCATIONS: RefCell<Vec<Vec3>> = RefCell::new(Vec::new());
}

/// Set the boost pad locations to send to RLViser in each packet
#[pyfunction]
fn set_boost_pad_locations(locations: [[f32; 3]; BOOST_PADS_LENGTH]) {
fn set_boost_pad_locations(locations: Vec<[f32; 3]>) {
BOOST_PAD_LOCATIONS.with_borrow_mut(|locs| {
locs.resize(locations.len(), Vec3::ZERO);
locs.iter_mut()
.zip(locations)
.for_each(|(rloc, pyloc)| *rloc = Vec3::from_array(pyloc));
Expand All @@ -49,7 +48,7 @@ fn render(
tick_count: u64,
tick_rate: f32,
game_mode: u8,
boost_pad_states: [bool; BOOST_PADS_LENGTH],
boost_pad_states: Vec<bool>,
ball: BallState,
cars: Vec<(u32, u8, CarConfig, CarState)>,
) {
Expand Down

0 comments on commit 160bfab

Please sign in to comment.