mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
More relative motion changes
This commit is contained in:
parent
0b954f8db8
commit
33920f31ac
@ -164,7 +164,7 @@ impl Body {
|
|||||||
quadruped_low::Species::Lavadrake => 4.0,
|
quadruped_low::Species::Lavadrake => 4.0,
|
||||||
_ => 6.0,
|
_ => 6.0,
|
||||||
},
|
},
|
||||||
Body::Ship(_) => 0.1,
|
Body::Ship(_) => 0.5,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -453,6 +453,8 @@ impl<'a> PhysicsSystemData<'a> {
|
|||||||
Vec3::zero()
|
Vec3::zero()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let was_on_ground = physics_state.on_ground;
|
||||||
|
|
||||||
match &*collider {
|
match &*collider {
|
||||||
Collider::Voxel { .. } => {
|
Collider::Voxel { .. } => {
|
||||||
// for now, treat entities with voxel colliders as their bounding
|
// for now, treat entities with voxel colliders as their bounding
|
||||||
@ -473,6 +475,7 @@ impl<'a> PhysicsSystemData<'a> {
|
|||||||
Vec3::zero(),
|
Vec3::zero(),
|
||||||
&psdr.dt,
|
&psdr.dt,
|
||||||
true,
|
true,
|
||||||
|
was_on_ground,
|
||||||
|entity, vel| land_on_grounds.push((entity, vel)),
|
|entity, vel| land_on_grounds.push((entity, vel)),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@ -498,6 +501,7 @@ impl<'a> PhysicsSystemData<'a> {
|
|||||||
Vec3::zero(),
|
Vec3::zero(),
|
||||||
&psdr.dt,
|
&psdr.dt,
|
||||||
true,
|
true,
|
||||||
|
was_on_ground,
|
||||||
|entity, vel| land_on_grounds.push((entity, vel)),
|
|entity, vel| land_on_grounds.push((entity, vel)),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@ -625,6 +629,7 @@ impl<'a> PhysicsSystemData<'a> {
|
|||||||
transform_to.mul_direction(vel_other.0),
|
transform_to.mul_direction(vel_other.0),
|
||||||
&psdr.dt,
|
&psdr.dt,
|
||||||
false,
|
false,
|
||||||
|
was_on_ground,
|
||||||
|entity, vel| land_on_grounds.push((entity, Vel(transform_from.mul_direction(vel.0)))),
|
|entity, vel| land_on_grounds.push((entity, Vel(transform_from.mul_direction(vel.0)))),
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -739,6 +744,7 @@ fn cylinder_voxel_collision<'a, T: BaseVol<Vox = Block> + ReadVol>(
|
|||||||
ground_vel: Vec3<f32>,
|
ground_vel: Vec3<f32>,
|
||||||
dt: &DeltaTime,
|
dt: &DeltaTime,
|
||||||
apply_velocity_step: bool, // Stupid hack
|
apply_velocity_step: bool, // Stupid hack
|
||||||
|
was_on_ground: bool,
|
||||||
mut land_on_ground: impl FnMut(Entity, Vel),
|
mut land_on_ground: impl FnMut(Entity, Vel),
|
||||||
) {
|
) {
|
||||||
let (radius, z_min, z_max) = cylinder;
|
let (radius, z_min, z_max) = cylinder;
|
||||||
@ -814,7 +820,6 @@ fn cylinder_voxel_collision<'a, T: BaseVol<Vox = Block> + ReadVol>(
|
|||||||
> 0
|
> 0
|
||||||
}
|
}
|
||||||
|
|
||||||
let was_on_ground = physics_state.on_ground;
|
|
||||||
physics_state.on_ground = false;
|
physics_state.on_ground = false;
|
||||||
|
|
||||||
let mut on_ground = false;
|
let mut on_ground = false;
|
||||||
@ -937,7 +942,7 @@ fn cylinder_voxel_collision<'a, T: BaseVol<Vox = Block> + ReadVol>(
|
|||||||
{
|
{
|
||||||
// ...block-hop!
|
// ...block-hop!
|
||||||
pos.0.z = (pos.0.z + 0.1).floor() + block_height;
|
pos.0.z = (pos.0.z + 0.1).floor() + block_height;
|
||||||
vel.0.z = 0.0;
|
vel.0.z = vel.0.z.max(0.0);
|
||||||
on_ground = true;
|
on_ground = true;
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
@ -945,7 +950,7 @@ fn cylinder_voxel_collision<'a, T: BaseVol<Vox = Block> + ReadVol>(
|
|||||||
vel.0 = vel.0.map2(
|
vel.0 = vel.0.map2(
|
||||||
resolve_dir,
|
resolve_dir,
|
||||||
|e, d| {
|
|e, d| {
|
||||||
if d * e.signum() < 0.0 { 0.0 } else { e }
|
if d * e.signum() < 0.0 { if d < 0.0 { d.max(0.0) } else { d.min(0.0) } } else { e }
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
pos_delta *= resolve_dir.map(|e| if e != 0.0 { 0.0 } else { 1.0 });
|
pos_delta *= resolve_dir.map(|e| if e != 0.0 { 0.0 } else { 1.0 });
|
||||||
@ -981,7 +986,7 @@ fn cylinder_voxel_collision<'a, T: BaseVol<Vox = Block> + ReadVol>(
|
|||||||
near_iter.clone(),
|
near_iter.clone(),
|
||||||
radius,
|
radius,
|
||||||
z_range.clone(),
|
z_range.clone(),
|
||||||
) && vel.0.z < 0.0
|
) && vel.0.z < 0.01
|
||||||
&& vel.0.z > -1.5
|
&& vel.0.z > -1.5
|
||||||
&& was_on_ground
|
&& was_on_ground
|
||||||
&& !collision_with(
|
&& !collision_with(
|
||||||
|
@ -455,10 +455,11 @@ impl State {
|
|||||||
for event in events {
|
for event in events {
|
||||||
let mut velocities = self.ecs.write_storage::<comp::Vel>();
|
let mut velocities = self.ecs.write_storage::<comp::Vel>();
|
||||||
let mut controllers = self.ecs.write_storage::<comp::Controller>();
|
let mut controllers = self.ecs.write_storage::<comp::Controller>();
|
||||||
|
let physics = self.ecs.read_storage::<comp::PhysicsState>();
|
||||||
match event {
|
match event {
|
||||||
LocalEvent::Jump(entity) => {
|
LocalEvent::Jump(entity) => {
|
||||||
if let Some(vel) = velocities.get_mut(entity) {
|
if let Some(vel) = velocities.get_mut(entity) {
|
||||||
vel.0.z = HUMANOID_JUMP_ACCEL;
|
vel.0.z = HUMANOID_JUMP_ACCEL + physics.get(entity).map_or(0.0, |ps| ps.ground_vel.z);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
LocalEvent::ApplyImpulse { entity, impulse } => {
|
LocalEvent::ApplyImpulse { entity, impulse } => {
|
||||||
|
@ -130,7 +130,7 @@ pub fn handle_shoot(
|
|||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
let vel = *dir * speed;
|
let vel = *dir * speed + state.ecs().read_storage::<Vel>().get(entity).map_or(Vec3::zero(), |v| v.0);
|
||||||
|
|
||||||
// Add an outcome
|
// Add an outcome
|
||||||
state
|
state
|
||||||
|
Loading…
Reference in New Issue
Block a user