forked from StrafesNET/strafe-client
tweak unit tests
This commit is contained in:
parent
3d426c0859
commit
1a05449315
@ -1650,37 +1650,37 @@ impl crate::instruction::InstructionConsumer<PhysicsInstruction> for PhysicsStat
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
fn hit_the_ground(relative_body:Body,expected_collision_time:Option<Time>){
|
fn test_collision(relative_body:Body,expected_collision_time:Option<Time>){
|
||||||
let h0=Hitbox::from_mesh_scale_offset(PhysicsMesh::from(&crate::primitives::unit_cylinder()),Planar64Vec3::int(2,5,2)/2,Planar64Vec3::int(10,0,10));
|
let h0=Hitbox::from_mesh_scale(PhysicsMesh::from(&crate::primitives::unit_cylinder()),Planar64Vec3::int(5,1,5)/2);
|
||||||
let h1=Hitbox::roblox();
|
let h1=Hitbox::roblox();
|
||||||
let hitbox_mesh=h1.transformed_mesh();
|
let hitbox_mesh=h1.transformed_mesh();
|
||||||
let platform_mesh=h0.transformed_mesh();
|
let platform_mesh=h0.transformed_mesh();
|
||||||
let minkowski=crate::model_physics::MinkowskiMesh::minkowski_sum(&platform_mesh,&hitbox_mesh);
|
let minkowski=crate::model_physics::MinkowskiMesh::minkowski_sum(&platform_mesh,&hitbox_mesh);
|
||||||
let collision=minkowski.predict_collision_in(&relative_body,Time::ONE_SECOND);
|
let collision=minkowski.predict_collision_in(&relative_body,Time::MAX);
|
||||||
assert_eq!(collision.map(|tup|tup.1),expected_collision_time,"Incorrect time of collision");
|
assert_eq!(collision.map(|tup|tup.1),expected_collision_time,"Incorrect time of collision");
|
||||||
}
|
}
|
||||||
#[test]
|
#[test]
|
||||||
fn hit_the_ground_degenerate(){
|
fn test_collision_degenerate(){
|
||||||
hit_the_ground(Body::new(
|
test_collision(Body::new(
|
||||||
Planar64Vec3::ONE*10,
|
Planar64Vec3::int(0,5,0),
|
||||||
Planar64Vec3::int(0,-10,0),
|
Planar64Vec3::int(0,-1,0),
|
||||||
Planar64Vec3::ZERO,
|
Planar64Vec3::ZERO,
|
||||||
Time::ZERO
|
Time::ZERO
|
||||||
),Some(Time::ONE_SECOND/2));
|
),Some(Time::from_secs(2)));
|
||||||
}
|
}
|
||||||
#[test]
|
#[test]
|
||||||
fn hit_the_ground_oblique(){
|
fn test_collision_oblique(){
|
||||||
hit_the_ground(Body::new(
|
test_collision(Body::new(
|
||||||
Planar64Vec3::ONE*10,
|
Planar64Vec3::int(0,5,0),
|
||||||
Planar64Vec3::int(1,-160,2)/16,
|
Planar64Vec3::int(1,-64,2)/64,
|
||||||
Planar64Vec3::ZERO,
|
Planar64Vec3::ZERO,
|
||||||
Time::ZERO
|
Time::ZERO
|
||||||
),Some(Time::ONE_SECOND/2));
|
),Some(Time::from_secs(2)));
|
||||||
}
|
}
|
||||||
#[test]
|
#[test]
|
||||||
fn zoom_hit_nothing(){
|
fn zoom_hit_nothing(){
|
||||||
hit_the_ground(Body::new(
|
test_collision(Body::new(
|
||||||
Planar64Vec3::ONE*10,
|
Planar64Vec3::int(0,10,0),
|
||||||
Planar64Vec3::int(10,0,0),
|
Planar64Vec3::int(10,0,0),
|
||||||
Planar64Vec3::int(0,100,0),
|
Planar64Vec3::int(0,100,0),
|
||||||
Time::ZERO
|
Time::ZERO
|
||||||
@ -1688,8 +1688,8 @@ fn zoom_hit_nothing(){
|
|||||||
}
|
}
|
||||||
#[test]
|
#[test]
|
||||||
fn already_inside_hit_nothing(){
|
fn already_inside_hit_nothing(){
|
||||||
hit_the_ground(Body::new(
|
test_collision(Body::new(
|
||||||
Planar64Vec3::int(10,5,10),
|
Planar64Vec3::ZERO,
|
||||||
Planar64Vec3::int(10,0,0),
|
Planar64Vec3::int(10,0,0),
|
||||||
Planar64Vec3::int(0,100,0),
|
Planar64Vec3::int(0,100,0),
|
||||||
Time::ZERO
|
Time::ZERO
|
||||||
|
Loading…
Reference in New Issue
Block a user