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
This commit is contained in:
Loki McKay
2025-10-09 19:59:58 +10:00
committed by GitHub
parent 3ac5ed4491
commit ae1d479857
2 changed files with 7 additions and 0 deletions

View File

@@ -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.

View File

@@ -8,6 +8,8 @@ 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))]
#[derive(Clone, Debug)]
pub struct DynamicRayCastVehicleController {
wheels: Vec<Wheel>,
forward_ws: Vec<Vector<Real>>,
@@ -23,6 +25,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 +104,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 +229,7 @@ impl Wheel {
/// Information about suspension and the ground obtained from the ray-casting
/// to simulate a wheels 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.