Skip to content

Commit

Permalink
chore: clippy fix
Browse files Browse the repository at this point in the history
  • Loading branch information
sebcrozet committed Mar 23, 2024
1 parent 6b6c349 commit f9663f8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 25 deletions.
44 changes: 22 additions & 22 deletions src_testbed/physics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@ pub struct PhysicsSnapshot {
island_manager: Vec<u8>,
}

pub struct DeserializedPhysicsSnapshot {
pub timestep_id: usize,
pub broad_phase: BroadPhase,
pub narrow_phase: NarrowPhase,
pub island_manager: IslandManager,
pub bodies: RigidBodySet,
pub colliders: ColliderSet,
pub impulse_joints: ImpulseJointSet,
pub multibody_joints: MultibodyJointSet,
}

impl PhysicsSnapshot {
pub fn new(
timestep_id: usize,
Expand All @@ -41,28 +52,17 @@ impl PhysicsSnapshot {
})
}

pub fn restore(
&self,
) -> bincode::Result<(
usize,
BroadPhase,
NarrowPhase,
IslandManager,
RigidBodySet,
ColliderSet,
ImpulseJointSet,
MultibodyJointSet,
)> {
Ok((
self.timestep_id,
bincode::deserialize(&self.broad_phase)?,
bincode::deserialize(&self.narrow_phase)?,
bincode::deserialize(&self.island_manager)?,
bincode::deserialize(&self.bodies)?,
bincode::deserialize(&self.colliders)?,
bincode::deserialize(&self.impulse_joints)?,
bincode::deserialize(&self.multibody_joints)?,
))
pub fn restore(&self) -> bincode::Result<DeserializedPhysicsSnapshot> {
Ok(DeserializedPhysicsSnapshot {
timestep_id: self.timestep_id,
broad_phase: bincode::deserialize(&self.broad_phase)?,
narrow_phase: bincode::deserialize(&self.narrow_phase)?,
island_manager: bincode::deserialize(&self.island_manager)?,
bodies: bincode::deserialize(&self.bodies)?,
colliders: bincode::deserialize(&self.colliders)?,
impulse_joints: bincode::deserialize(&self.impulse_joints)?,
multibody_joints: bincode::deserialize(&self.multibody_joints)?,
})
}

pub fn print_snapshot_len(&self) {
Expand Down
6 changes: 3 additions & 3 deletions src_testbed/testbed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::num::NonZeroUsize;
use bevy::prelude::*;

use crate::debug_render::{DebugRenderPipelineResource, RapierDebugRenderPlugin};
use crate::physics::{PhysicsEvents, PhysicsSnapshot, PhysicsState};
use crate::physics::{DeserializedPhysicsSnapshot, PhysicsEvents, PhysicsSnapshot, PhysicsState};
use crate::plugin::TestbedPlugin;
use crate::ui;
use crate::{graphics::GraphicsManager, harness::RunState};
Expand Down Expand Up @@ -1271,7 +1271,7 @@ fn update_testbed(
.action_flags
.set(TestbedActionFlags::RESTORE_SNAPSHOT, false);
if let Some(snapshot) = &state.snapshot {
if let Ok((
if let Ok(DeserializedPhysicsSnapshot {
timestep_id,
broad_phase,
narrow_phase,
Expand All @@ -1280,7 +1280,7 @@ fn update_testbed(
colliders,
impulse_joints,
multibody_joints,
)) = snapshot.restore()
}) = snapshot.restore()
{
clear(&mut commands, &mut state, &mut graphics, &mut plugins);

Expand Down

0 comments on commit f9663f8

Please sign in to comment.