From a18aa7187a915f85e707e70695d11cff3103ef03 Mon Sep 17 00:00:00 2001 From: Loki Date: Thu, 9 Oct 2025 16:42:20 +1000 Subject: [PATCH 1/2] Add serde derives to Pd, Pid and DynamicRaycastVehicle controllers --- src/control/pid_controller.rs | 2 ++ src/control/ray_cast_vehicle_controller.rs | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/src/control/pid_controller.rs b/src/control/pid_controller.rs index d24cd3781..39fd350b7 100644 --- a/src/control/pid_controller.rs +++ b/src/control/pid_controller.rs @@ -10,6 +10,7 @@ use parry::math::AngVector; /// This is a [PID controller](https://en.wikipedia.org/wiki/Proportional%E2%80%93integral%E2%80%93derivative_controller) /// without the Integral part to keep the API immutable, while having a behaviour generally /// sufficient for games. +#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))] #[derive(Debug, Copy, Clone, PartialEq)] pub struct PdController { /// The Proportional gain applied to the instantaneous linear position errors. @@ -51,6 +52,7 @@ impl Default for PdController { /// /// For video games, the Proportional-Derivative [`PdController`] is generally sufficient and /// offers an immutable API. +#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))] #[derive(Debug, Copy, Clone, PartialEq)] pub struct PidController { /// The Proportional-Derivative (PD) part of this PID controller. diff --git a/src/control/ray_cast_vehicle_controller.rs b/src/control/ray_cast_vehicle_controller.rs index 2f1744214..754891702 100644 --- a/src/control/ray_cast_vehicle_controller.rs +++ b/src/control/ray_cast_vehicle_controller.rs @@ -8,6 +8,7 @@ use crate::prelude::QueryPipelineMut; use crate::utils::{SimdCross, SimdDot}; /// A character controller to simulate vehicles using ray-casting for the wheels. +#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))] pub struct DynamicRayCastVehicleController { wheels: Vec, forward_ws: Vec>, @@ -23,6 +24,7 @@ pub struct DynamicRayCastVehicleController { pub index_forward_axis: usize, } +#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))] #[derive(Copy, Clone, Debug, PartialEq)] /// Parameters affecting the physical behavior of a wheel. pub struct WheelTuning { @@ -101,6 +103,7 @@ struct WheelDesc { pub side_friction_stiffness: Real, } +#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))] #[derive(Copy, Clone, Debug, PartialEq)] /// A wheel attached to a vehicle. pub struct Wheel { @@ -225,6 +228,7 @@ impl Wheel { /// Information about suspension and the ground obtained from the ray-casting /// to simulate a wheel’s suspension. +#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))] #[derive(Copy, Clone, Debug, PartialEq, Default)] pub struct RayCastInfo { /// The (world-space) contact normal between the wheel and the floor. From ad2598bed9ab436289b7ee760f5370eb0e6c7be1 Mon Sep 17 00:00:00 2001 From: Loki Date: Thu, 9 Oct 2025 17:02:04 +1000 Subject: [PATCH 2/2] Add Clone and Debug derives to DynamicRayCastVehicleController --- src/control/ray_cast_vehicle_controller.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/control/ray_cast_vehicle_controller.rs b/src/control/ray_cast_vehicle_controller.rs index 754891702..c176e99ba 100644 --- a/src/control/ray_cast_vehicle_controller.rs +++ b/src/control/ray_cast_vehicle_controller.rs @@ -9,6 +9,7 @@ use crate::utils::{SimdCross, SimdDot}; /// A character controller to simulate vehicles using ray-casting for the wheels. #[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))] +#[derive(Clone, Debug)] pub struct DynamicRayCastVehicleController { wheels: Vec, forward_ws: Vec>,