use gizmo_math::Vec3;
use serde::{Deserialize, Serialize};
use bevy_reflect::Reflect;
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, Reflect)]
pub struct Velocity {
pub linear: Vec3,
pub angular: Vec3,
#[serde(skip)]
#[reflect(ignore)]
pub pre_linear: Vec3,
#[serde(skip)]
#[reflect(ignore)]
pub pre_angular: Vec3,
}
impl Velocity {
pub fn new(linear: Vec3) -> Self {
Self {
linear,
angular: Vec3::ZERO,
pre_linear: linear,
pre_angular: Vec3::ZERO,
}
}
pub fn with_angular(mut self, angular: Vec3) -> Self {
self.angular = angular;
self.pre_angular = angular;
self
}
}
impl Default for Velocity {
fn default() -> Self {
Self::new(Vec3::ZERO)
}
}
gizmo_core::impl_component!(Velocity);