gizmo_physics_rigid/components/
velocity.rs1use gizmo_math::Vec3;
2use serde::{Deserialize, Serialize};
3#[cfg(feature = "reflect")]
4use bevy_reflect::Reflect;
5
6#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
7#[cfg_attr(feature = "reflect", derive(Reflect))]
8pub struct Velocity {
9 pub linear: Vec3,
10 pub angular: Vec3,
11 #[serde(skip)]
13 #[cfg_attr(feature = "reflect", reflect(ignore))]
14 pub pre_linear: Vec3,
15 #[serde(skip)]
16 #[cfg_attr(feature = "reflect", reflect(ignore))]
17 pub pre_angular: Vec3,
18}
19
20impl Velocity {
21 pub fn new(linear: Vec3) -> Self {
22 Self {
23 linear,
24 angular: Vec3::ZERO,
25 pre_linear: linear,
26 pre_angular: Vec3::ZERO,
27 }
28 }
29
30 pub fn with_angular(mut self, angular: Vec3) -> Self {
31 self.angular = angular;
32 self.pre_angular = angular;
33 self
34 }
35}
36
37impl Default for Velocity {
38 fn default() -> Self {
39 Self::new(Vec3::ZERO)
40 }
41}
42
43gizmo_core::impl_component!(Velocity);