Skip to content

Commit ae1d479

Browse files
authored
Add serde derives to Pd, Pid and DynamicRaycastVehicle controllers (#883)
* Add serde derives to Pd, Pid and DynamicRaycastVehicle controllers * Add Clone and Debug derives to DynamicRayCastVehicleController
1 parent 3ac5ed4 commit ae1d479

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/control/pid_controller.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use parry::math::AngVector;
1010
/// This is a [PID controller](https://en.wikipedia.org/wiki/Proportional%E2%80%93integral%E2%80%93derivative_controller)
1111
/// without the Integral part to keep the API immutable, while having a behaviour generally
1212
/// sufficient for games.
13+
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
1314
#[derive(Debug, Copy, Clone, PartialEq)]
1415
pub struct PdController {
1516
/// The Proportional gain applied to the instantaneous linear position errors.
@@ -51,6 +52,7 @@ impl Default for PdController {
5152
///
5253
/// For video games, the Proportional-Derivative [`PdController`] is generally sufficient and
5354
/// offers an immutable API.
55+
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
5456
#[derive(Debug, Copy, Clone, PartialEq)]
5557
pub struct PidController {
5658
/// The Proportional-Derivative (PD) part of this PID controller.

src/control/ray_cast_vehicle_controller.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ use crate::prelude::QueryPipelineMut;
88
use crate::utils::{SimdCross, SimdDot};
99

1010
/// A character controller to simulate vehicles using ray-casting for the wheels.
11+
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
12+
#[derive(Clone, Debug)]
1113
pub struct DynamicRayCastVehicleController {
1214
wheels: Vec<Wheel>,
1315
forward_ws: Vec<Vector<Real>>,
@@ -23,6 +25,7 @@ pub struct DynamicRayCastVehicleController {
2325
pub index_forward_axis: usize,
2426
}
2527

28+
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
2629
#[derive(Copy, Clone, Debug, PartialEq)]
2730
/// Parameters affecting the physical behavior of a wheel.
2831
pub struct WheelTuning {
@@ -101,6 +104,7 @@ struct WheelDesc {
101104
pub side_friction_stiffness: Real,
102105
}
103106

107+
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
104108
#[derive(Copy, Clone, Debug, PartialEq)]
105109
/// A wheel attached to a vehicle.
106110
pub struct Wheel {
@@ -225,6 +229,7 @@ impl Wheel {
225229

226230
/// Information about suspension and the ground obtained from the ray-casting
227231
/// to simulate a wheel’s suspension.
232+
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
228233
#[derive(Copy, Clone, Debug, PartialEq, Default)]
229234
pub struct RayCastInfo {
230235
/// The (world-space) contact normal between the wheel and the floor.

0 commit comments

Comments
 (0)