fix angularmomentum command
This commit is contained in:
parent
0f375fab64
commit
cab5c8eaf5
|
@ -62,8 +62,6 @@ pub struct Actor {
|
||||||
pub id: String,
|
pub id: String,
|
||||||
pub hp: f32,
|
pub hp: f32,
|
||||||
pub m: f32, // mass
|
pub m: f32, // mass
|
||||||
pub v: Vec3, // velocity
|
|
||||||
pub angular_momentum: Quat,
|
|
||||||
pub inside_entity: u32,
|
pub inside_entity: u32,
|
||||||
pub camdistance: f32,
|
pub camdistance: f32,
|
||||||
}
|
}
|
||||||
|
@ -74,9 +72,7 @@ impl Default for Actor {
|
||||||
id: "".to_string(),
|
id: "".to_string(),
|
||||||
hp: 100.0,
|
hp: 100.0,
|
||||||
m: 100.0,
|
m: 100.0,
|
||||||
v: Vec3::ZERO,
|
|
||||||
inside_entity: NO_RIDE,
|
inside_entity: NO_RIDE,
|
||||||
angular_momentum: Quat::from_euler(EulerRot::XYZ, 0.001, 0.01, 0.003),
|
|
||||||
camdistance: 15.0,
|
camdistance: 15.0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ actor 0 0 0 suit
|
||||||
scale 1
|
scale 1
|
||||||
oxygen 0.008
|
oxygen 0.008
|
||||||
health 0.3
|
health 0.3
|
||||||
|
angularmomentum 0 0 0
|
||||||
collider capsule 2 1
|
collider capsule 2 1
|
||||||
thrust 1.2 1 1 1 1.5
|
thrust 1.2 1 1 1 1.5
|
||||||
engine monopropellant
|
engine monopropellant
|
||||||
|
@ -17,7 +18,7 @@ actor 300000 0 500000 jupiter
|
||||||
actor 3000 0 0 moonlet
|
actor 3000 0 0 moonlet
|
||||||
scale 500
|
scale 500
|
||||||
mass 10000000
|
mass 10000000
|
||||||
angularmomentum 0 0.0001 0
|
angularmomentum 0 0.15 0
|
||||||
|
|
||||||
actor 1000 20 300 monolith
|
actor 1000 20 300 monolith
|
||||||
scale 2
|
scale 2
|
||||||
|
@ -108,6 +109,7 @@ actor 10 -30 20 MeteorAceGT
|
||||||
collider sphere 1.5
|
collider sphere 1.5
|
||||||
camdistance 50
|
camdistance 50
|
||||||
mass 3000
|
mass 3000
|
||||||
|
angularmomentum 0.1 0.1 0.3
|
||||||
|
|
||||||
actor 10 0 70 suit
|
actor 10 0 70 suit
|
||||||
name Icarus
|
name Icarus
|
||||||
|
|
11
src/world.rs
11
src/world.rs
|
@ -97,7 +97,7 @@ pub fn setup(
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
actor::Actor::default(),
|
actor::Actor::default(),
|
||||||
RigidBody::Dynamic,
|
RigidBody::Dynamic,
|
||||||
AngularVelocity(Vec3::new(0.001, 0.001, 0.0003)),
|
AngularVelocity(Vec3::new(0.1, 0.1, 0.03)),
|
||||||
LinearVelocity(Vec3::new(0.0, 0.0, 0.35)),
|
LinearVelocity(Vec3::new(0.0, 0.0, 0.35)),
|
||||||
Collider::sphere(1.0),
|
Collider::sphere(1.0),
|
||||||
SceneBundle {
|
SceneBundle {
|
||||||
|
@ -202,7 +202,7 @@ struct ParserState {
|
||||||
model: String,
|
model: String,
|
||||||
model_scale: f32,
|
model_scale: f32,
|
||||||
rotation: Quat,
|
rotation: Quat,
|
||||||
angular_momentum: Quat,
|
angular_momentum: Vec3,
|
||||||
pronoun: String,
|
pronoun: String,
|
||||||
is_player: bool,
|
is_player: bool,
|
||||||
is_lifeform: bool,
|
is_lifeform: bool,
|
||||||
|
@ -248,7 +248,7 @@ impl Default for ParserState {
|
||||||
model: "".to_string(),
|
model: "".to_string(),
|
||||||
model_scale: 1.0,
|
model_scale: 1.0,
|
||||||
rotation: Quat::IDENTITY,
|
rotation: Quat::IDENTITY,
|
||||||
angular_momentum: default_actor.angular_momentum,
|
angular_momentum: Vec3::new(0.03, 0.3, 0.09),
|
||||||
pronoun: "they/them".to_string(),
|
pronoun: "they/them".to_string(),
|
||||||
is_player: false,
|
is_player: false,
|
||||||
is_lifeform: false,
|
is_lifeform: false,
|
||||||
|
@ -325,7 +325,6 @@ impl ParserState {
|
||||||
fn spawn_actor(&mut self, commands: &mut Commands, asset_server: &Res<AssetServer>) {
|
fn spawn_actor(&mut self, commands: &mut Commands, asset_server: &Res<AssetServer>) {
|
||||||
let mut actor = commands.spawn_empty();
|
let mut actor = commands.spawn_empty();
|
||||||
actor.insert(actor::Actor {
|
actor.insert(actor::Actor {
|
||||||
angular_momentum: self.angular_momentum,
|
|
||||||
id: self.id.clone(),
|
id: self.id.clone(),
|
||||||
camdistance: self.camdistance,
|
camdistance: self.camdistance,
|
||||||
..default()
|
..default()
|
||||||
|
@ -344,9 +343,11 @@ impl ParserState {
|
||||||
if self.has_physics {
|
if self.has_physics {
|
||||||
let fix_scale = 1.0 / self.model_scale.powf(3.0);
|
let fix_scale = 1.0 / self.model_scale.powf(3.0);
|
||||||
actor.insert(RigidBody::Dynamic);
|
actor.insert(RigidBody::Dynamic);
|
||||||
|
actor.insert(AngularVelocity(self.angular_momentum));
|
||||||
actor.insert(self.collider.clone());
|
actor.insert(self.collider.clone());
|
||||||
actor.insert(ColliderDensity(self.mass * fix_scale));
|
actor.insert(ColliderDensity(self.mass * fix_scale));
|
||||||
}
|
}
|
||||||
|
// TODO: angular velocity for objects without collisions, static objects
|
||||||
|
|
||||||
// Optional Components
|
// Optional Components
|
||||||
if self.is_player {
|
if self.is_player {
|
||||||
|
@ -516,7 +517,7 @@ pub fn load_defs(
|
||||||
["angularmomentum", x, y, z] => {
|
["angularmomentum", x, y, z] => {
|
||||||
if let (Ok(x_float), Ok(y_float), Ok(z_float)) =
|
if let (Ok(x_float), Ok(y_float), Ok(z_float)) =
|
||||||
(x.parse::<f32>(), y.parse::<f32>(), z.parse::<f32>()) {
|
(x.parse::<f32>(), y.parse::<f32>(), z.parse::<f32>()) {
|
||||||
state.angular_momentum = Quat::from_euler(EulerRot::XYZ, x_float, y_float, z_float);
|
state.angular_momentum = Vec3::new(x_float, y_float, z_float);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
error!("Can't parse float: {line}");
|
error!("Can't parse float: {line}");
|
||||||
|
|
Loading…
Reference in a new issue