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:
@@ -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)
|
/// 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
|
/// without the Integral part to keep the API immutable, while having a behaviour generally
|
||||||
/// sufficient for games.
|
/// sufficient for games.
|
||||||
|
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
|
||||||
#[derive(Debug, Copy, Clone, PartialEq)]
|
#[derive(Debug, Copy, Clone, PartialEq)]
|
||||||
pub struct PdController {
|
pub struct PdController {
|
||||||
/// The Proportional gain applied to the instantaneous linear position errors.
|
/// 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
|
/// For video games, the Proportional-Derivative [`PdController`] is generally sufficient and
|
||||||
/// offers an immutable API.
|
/// offers an immutable API.
|
||||||
|
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
|
||||||
#[derive(Debug, Copy, Clone, PartialEq)]
|
#[derive(Debug, Copy, Clone, PartialEq)]
|
||||||
pub struct PidController {
|
pub struct PidController {
|
||||||
/// The Proportional-Derivative (PD) part of this PID controller.
|
/// The Proportional-Derivative (PD) part of this PID controller.
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ use crate::prelude::QueryPipelineMut;
|
|||||||
use crate::utils::{SimdCross, SimdDot};
|
use crate::utils::{SimdCross, SimdDot};
|
||||||
|
|
||||||
/// A character controller to simulate vehicles using ray-casting for the wheels.
|
/// 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 {
|
pub struct DynamicRayCastVehicleController {
|
||||||
wheels: Vec<Wheel>,
|
wheels: Vec<Wheel>,
|
||||||
forward_ws: Vec<Vector<Real>>,
|
forward_ws: Vec<Vector<Real>>,
|
||||||
@@ -23,6 +25,7 @@ pub struct DynamicRayCastVehicleController {
|
|||||||
pub index_forward_axis: usize,
|
pub index_forward_axis: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
|
||||||
#[derive(Copy, Clone, Debug, PartialEq)]
|
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||||
/// Parameters affecting the physical behavior of a wheel.
|
/// Parameters affecting the physical behavior of a wheel.
|
||||||
pub struct WheelTuning {
|
pub struct WheelTuning {
|
||||||
@@ -101,6 +104,7 @@ struct WheelDesc {
|
|||||||
pub side_friction_stiffness: Real,
|
pub side_friction_stiffness: Real,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
|
||||||
#[derive(Copy, Clone, Debug, PartialEq)]
|
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||||
/// A wheel attached to a vehicle.
|
/// A wheel attached to a vehicle.
|
||||||
pub struct Wheel {
|
pub struct Wheel {
|
||||||
@@ -225,6 +229,7 @@ impl Wheel {
|
|||||||
|
|
||||||
/// Information about suspension and the ground obtained from the ray-casting
|
/// Information about suspension and the ground obtained from the ray-casting
|
||||||
/// to simulate a wheel’s suspension.
|
/// to simulate a wheel’s suspension.
|
||||||
|
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
|
||||||
#[derive(Copy, Clone, Debug, PartialEq, Default)]
|
#[derive(Copy, Clone, Debug, PartialEq, Default)]
|
||||||
pub struct RayCastInfo {
|
pub struct RayCastInfo {
|
||||||
/// The (world-space) contact normal between the wheel and the floor.
|
/// The (world-space) contact normal between the wheel and the floor.
|
||||||
|
|||||||
Reference in New Issue
Block a user