mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Fewer precision issues by using player-relative coordinate space
This commit is contained in:
parent
a32be4ac5a
commit
b2ab1046c8
@ -632,12 +632,16 @@ impl<'a> PhysicsData<'a> {
|
|||||||
let mut physics_state_delta = physics_state.clone();
|
let mut physics_state_delta = physics_state.clone();
|
||||||
// deliberately don't use scale yet here, because the 11.0/0.8
|
// deliberately don't use scale yet here, because the 11.0/0.8
|
||||||
// thing is in the comp::Scale for visual reasons
|
// thing is in the comp::Scale for visual reasons
|
||||||
let transform_from = Mat4::<f32>::translation_3d(pos_other.0)
|
let wpos = pos.0;
|
||||||
* Mat4::from(ori_other.0)
|
let transform_from =
|
||||||
* Mat4::<f32>::translation_3d(voxel_collider.translation);
|
Mat4::<f32>::translation_3d(pos_other.0 - wpos)
|
||||||
|
* Mat4::from(ori_other.0)
|
||||||
|
* Mat4::<f32>::translation_3d(voxel_collider.translation);
|
||||||
let transform_to = transform_from.inverted();
|
let transform_to = transform_from.inverted();
|
||||||
pos.0 = transform_to.mul_point(pos.0);
|
let ori_to = Mat4::from(ori_other.0);
|
||||||
vel.0 = transform_to.mul_direction(vel.0 - vel_other.0);
|
let ori_from = ori_to.inverted();
|
||||||
|
pos.0 = transform_to.mul_point(Vec3::zero());
|
||||||
|
vel.0 = ori_to.mul_direction(vel.0 - vel_other.0);
|
||||||
let cylinder = (radius, z_min, z_max);
|
let cylinder = (radius, z_min, z_max);
|
||||||
cylinder_voxel_collision(
|
cylinder_voxel_collision(
|
||||||
cylinder,
|
cylinder,
|
||||||
@ -647,20 +651,18 @@ impl<'a> PhysicsData<'a> {
|
|||||||
transform_to.mul_direction(pos_delta),
|
transform_to.mul_direction(pos_delta),
|
||||||
&mut vel,
|
&mut vel,
|
||||||
&mut physics_state_delta,
|
&mut physics_state_delta,
|
||||||
transform_to.mul_direction(vel_other.0),
|
ori_to.mul_direction(vel_other.0),
|
||||||
&read.dt,
|
&read.dt,
|
||||||
false,
|
false,
|
||||||
was_on_ground,
|
was_on_ground,
|
||||||
|entity, vel| {
|
|entity, vel| {
|
||||||
land_on_grounds.push((
|
land_on_grounds
|
||||||
entity,
|
.push((entity, Vel(ori_from.mul_direction(vel.0))))
|
||||||
Vel(transform_from.mul_direction(vel.0)),
|
|
||||||
))
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
pos.0 = transform_from.mul_point(pos.0);
|
pos.0 = transform_from.mul_point(pos.0) + wpos;
|
||||||
vel.0 = transform_from.mul_direction(vel.0) + vel_other.0;
|
vel.0 = ori_from.mul_direction(vel.0) + vel_other.0;
|
||||||
|
|
||||||
// union in the state updates, so that the state isn't just based on
|
// union in the state updates, so that the state isn't just based on
|
||||||
// the most recent terrain that collision was attempted with
|
// the most recent terrain that collision was attempted with
|
||||||
|
Loading…
Reference in New Issue
Block a user