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